How to Make XSD

The W3C, or World Wide Web Consortium, has recommended the XML Schema language (XSD) as a replacement to the older Document Type Definition language for defining the structure of XML databases and documents. XSD's syntax has a number of enhancements over DTD, including a more XML-like syntax and the standardization of many commonly used data types.

Instructions

    • 1

      Decide on the structure of the data you wish to define. You may wish to perform this step on a sheet of paper by either making an outline or drawing a graph. This tutorial will describe data for a company's employees with the following outline:

      Department
      --->Employee
      ------>First Name
      ------>Last Name

      We see here that the company has departments, which are divided up into employees, which in turn have first and last names. A real employee database would contain much more information than this, but this is enough to illustrate the example.

    • 2

      Open a new text file. Save the file with an XSD extension. If you use Windows and are using Notepad as opposed to a dedicated programming text editor, this may require turning on "Show File Extensions" in the "Folder Options" settings of "My Computer."

    • 3

      Type the following into your document:

      <?xml version="1.0" encoding="UTF-8" ?>
      <xs:schema xmlns:xs="http://w3.org/2001/XMLSchema">

      </xs:schema>

      The first line is the header that identifies this document as an XML document, and the rest are tags to enclose the full document. All code to follow will have to go between the lines <xs:schema....> and </xs:schema>. This is a common feature of the XML language: tags are opened with a command and closed with the same command preceded by a forward slash.

    • 4

      Define simple elements. A simple element is a piece of information that does not include other pieces of information within it. In the employee outline example given above, the simple elements are First Name and Last Name.

      <xs:element name="firstName" type="xs:string"/>
      <xs:element name="lastName" type="xs:string"/>

    • 5

      Define complex elements and establish references. Notice, the Employee element within Department is not a simple element, because it contains the element's first and last name. Employee and Department are complex elements.

      <xs:element name="employee">
      <xs:complexType>
      <xs:element ref="firstName"/>
      <xs:element ref="lastName"/>
      </xs:complexType>
      </xs:element>

      Notice that the xml parameter "ref=" refers to the simple elements defined above. Do the same for Department to indicate that it contains employees.

      <xs:element name="department">
      <xs:complexType>
      <xs:element ref="employee"/>
      </xs:complexType>
      </xs:element>

Tips & Warnings

  • Use an XML Editor. While it is entirely possible to write XML and XML Schema documents in a standard text editor, a dedicated XML editor or programming text editor will include advanced features to assist in using correct and standards-compliant syntax.

Related Searches:

References

Comments

You May Also Like

  • How to Create Xsd

    A file with a XSD file extension is one that contains information relating to an XML file on your computer. Both file...

  • How to Generate an XSD From an XML File

    If you use XML data in your applications, it can be useful to have an XSD to check your structures against. XSD...

  • How to Create an XSD From an XML File

    Extensible Markup Language (XML) provides a foundation for data standards. XML allows Web developers to lay out data on a page using...

  • How to Convert a XML File to XSD

    XML is the extension for the Extensible Markup Language file type. These are data files which use tags to define objects and...

  • How to Create XSLT From XSD

    The XSD file format is part of the Extensible Business Reporting Language (XBRL). XSD files are XBRL taxonomies, which are dictionaries used...

  • How to Make a Copyright Sign on a Keyboard

    Though you can't see it on your keyboard, you can create almost any special character you need on a document. With Windows...

  • How to Convert XML to Xsd Online

    XML means eXtensible Markup Language whereas XSD means XML Schema definition. XML documents transfer data to and from web services. XSD defines...

  • How to View Xsd Files

    Many different file types can be found on an operating system, some created by Windows itself, and others created by applications that...

  • How to Create .Rtf Files in Visual Basic 6

    Microsoft developed a file format in 1987 labeled "RTF" or Rich Text Format. This format was used to standardize text and graphical...

  • How to View XSD

    .XSD files are most commonly used by a program called XML Schema. They define the characteristics of an XML document and what...

Related Ads

Featured