How to Create an XML Schema

An XML Schema defines the structure of your XML document. As opposed to XML DTDs (document type definitions) XML Schemas are more powerful and support both data types and namespaces. Knowing how to create an XML Schema will ensure proper functioning of your XML document

Steps

  1. Image titled Create an XML Schema Step 1
    1
    Purchase an XML editing software program that allows you to create XML schemas, if you do not already have such software.
  2. Image titled Create an XML Schema Step 2
    2
    Install the software on your computer and restart, if necessary.
  3. Image titled Create an XML Schema Step 3
    3
    Familiarize yourself with your XML editor's workspace, as well as with user resources that are available.
  4. Image titled Create an XML Schema Step 4
    4
    Create elements for your XML Schema.
    • Your schema must include the schema element as its root element. This element may also contain attributes.
    • Elements must include a start and end tag and may include other elements, text, attributes or any combination of these.
    • The names of your XML elements must not start with a number or special character and cannot start with "xml."
    • Ensure all elements are properly nested.
    • Use short, descriptive names for your elements.
  5. Image titled Create an XML Schema Step 5
    5
    Define which XML Schema elements are child elements.
  6. Image titled Create an XML Schema Step 6
    6
    Create your XML Schema attributes.
    • Attributes provide additional information about the elements contained within your XML document.
    • Attributes must appear within quotes.
    • Attributes can contain only one value.
    • Do not include tree structures in your attributes.
  7. Image titled Create an XML Schema Step 7
    7
    Create your XML Schema types to define the content of your elements and attributes.
  8. Image titled Create an XML Schema Step 8
    8
    Save your work.
  9. Image titled Create an XML Schema Step 9
    9
    Check your XML Schema to be sure XML elements and XML attributes are properly named and that there are no other errors.
  10. Image titled Create an XML Schema Step 10
    10
    Correct any errors you identify.
  11. Image titled Create an XML Schema Step 11
    11
    Validate your XML Schema using your XML editor's validation tool.
  12. Image titled Create an XML Schema Step 12
    12
    Correct any errors identified during validation.
  13. Image titled Create an XML Schema Step 13
    13
    Save your work.
  14. Image titled Create an XML Schema Step 14
    14
    Open the XML file or files for which you have created the XML Schema.
  15. Image titled Create an XML Schema Step 15
    15
    Include a reference to your XML Schema within your XML file or files.
  16. Image titled Create an XML Schema Step 16
    16
    Save your XML file.

Tips

  • You may supplement your XML Schema with other valid schemas using import, include or redefine elements.
  • Your XML Schema can also be used to define whether your elements are empty or are able to include text, as well as the data types and fixed values of elements and attributes.
  • Your XML Schema outlines elements and attributes that are allowable in your XML document. Your XML Schema also identifies child elements, as well as their number and order.
  • The language used to create XML schemas is also called XML Schema Definition (XSD).
  • By using an XML Schema instead of an XML DTD, it will be easier for you to describe what content is allowed, to work with data, define data facets and patterns, convert data and to validate your data.

Things You'll Need

  • Basic understanding of HTML
  • Basic understanding of XHTML
  • Basic understanding of XML
  • Basic understanding of XML namespaces
  • Basic understanding of XML DTDs
  • computer
  • XML file or files

Article Info

Categories: Internet | Software