Creating TEI XML content in Drupal
Now that you've developed a schema and configured it in your Drupal installation, you add an XML document to your site and validate it against the schema.
Creating TEI XML content in Drupal can now be undertaken in the usual Drupal manner:
- Navigate to Create Content in your navigation links.
- Choose TEI XML Document (the custom content type that you created in Figure 5—the page and story content types are Drupal's built-in types).
- Give your document a title.
- In the Body section of the Document form, create your TEI XML content or paste it in from a different editor.
- Below the Body section where you added your XML content, open the Input format display and select the TEI XML format, as indicated in Figure 11.
Figure 11. Select XML as the document input format
The main difference in the content creation process now is that when you preview or submit your content of the TEI XML Document type, the XML Content module uses the XML schema you assigned to the input filter earlier to do the following:
- Validate the XML content in the Body field against your schema
- Ensure that it is well-formed XML
If well-formedness or validation errors are present, you receive messages that can help you debug the input so that it validates. The validator first checks for well-formedness and reports any fatal XML errors as illustrated in Figure 12. The example lists three fatal errors: mismatched opening and end tags for p and div elements, data that ends prematurely in a div tag, and data that ends prematurely in a pb tag.
Figure 12. Example of well-formedness validation errors
If the document contents are well-formed XML, it runs the validation checks against your uploaded custom schema and reports any errors as in Figure 13. The example lists three validation errors: Expecting element publicationStmt, got sourceDesc; Element fileDesc failed to validate content; and Element teiHeader failed to validate content.
Figure 13. Example of schema validation errors
If the content is well-formed and validates against the schema, it is automatically saved in Drupal and is publishable (or published immediately if the publication settings were checked accordingly in the Add Content screen).
Although we are using TEI XML as an input format primarily for a Drupal content type labeled TEI XML Document, there are no restrictions to define how XML format is to be used in a site. After you add and activate the XML Content module, XML is an input format option for every other content type your site is customized to publish. And using the XML filter (Home > Administer > Site configuration > Input formats > TEI XML filter), you can adjust the XML Content module settings to permit, require, or preclude content in XML by content type and by user permission, as in Figure 14. [Roles options for TEI XML include authenticated user (selected) and anonymous user (not selected). Filters options include XML Content XSLT filter (selected) and HTML corrector, HTML filter, Line break converter, and URL filter (all unselected)]
Figure 14. Enable XML input by user type
Although the XML Content module specifies well-formedness and schema validation constraints for XML documents, none of the functionality you normally expect for the Drupal content type you are working with and have permissions for (for example, page content types allow for revision information, comment settings, authoring information, and publishing options) is affected by the addition of the module. For more information about these roles and their effects on content, look at the developerWorks series on Exploring Drupal V6, particularly Part 2 in this case (see Resources).
You just customized Drupal so that an XML document can be added and validated on your site. Now you're ready to consider how to display it using XSLT and CSS.