XSD
XSD, XML Schema Definition, XML Schema - a language for describing the structure of an XML document. In particular, XML Schema describes:
- dictionary - names of elements and attributes;
- content model - the relationship between elements and attributes, as well as their
- structure of the document;
- used data types.
The advantages of XSD over DTD are as follows:
- DTD, unlike XSD, is not XML and has its own syntax. As a result, various problems with encoding and verifying XML documents can arise.
- When using XSD, the XML parser can check not only the syntax of an XML document, but also its structure, content model, and data types. In XML DTD, there is only one data type - a string, and if, for example, there is text in a numeric field, then the document will still be able to pass verification, since the XML DTD will not be able to check the data type.
- You cannot map more than one DTD to one XML document. Therefore, a document can be verified with only one DTD description. XSD is extensible and allows you to connect several dictionaries to describe typical tasks.
- XSD has built-in documentation tools that allow you to create self-contained documents that do not require additional description.
Types in XSD
A simple type is a type definition for a value that can be used as the content of an element or attribute. This data type cannot contain elements or have attributes.
<xsd:element name='price' type='xsd:decimal'/>
...
<price>45.50</price>
A complex type is a type definition for elements that can contain attributes and other elements.
<xsd: element name = 'price'>
<xsd: complexType base = 'xsd: decimal'>
<xsd: attribute name = 'currency' type = 'xsd: string' />
</xsd: complexType>
</xsd: element>
...
<price currency = 'US'> 45.50 </price>
Read also:
- Execution of queries with JDBC
- XML, well-formed XML and valid XML
- Basic steps for working with a database using JDBC
Comments
Post a Comment