Tutorial Addendum On XML Technologies - XSD Syntax
| |
Empty XML Elements
Empty XML Element: A appropriate circuitous XML aspect that has
one aspect or added and no adolescent argument nodes. Abandoned XML elements must
be authentic with circuitous data types in the afterward format:
<xsd:complexType name="my_data_type">
<xsd:attribute name="attribute_a" type="data_type_a"/>
<xsd:attribute name="attribute_b" type="data_type_b"/>
...
</xsd:complexType>
Anomymous Data Types
If data blazon is specific to a adolescent aspect in a ancestor data type, and there is not
need to allotment it with data types alfresco the ancestor data type, you can ascertain it
as bearding data blazon - a non-named data blazon authentic inline. For example, the
following code:
<xsd:complexType name="my_data_type">
<xsd:sequence>
<xsd:element name="setting">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="property" type="xsd:string"/>
<xsd:element name="value" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
defines "my_data_type" which has a "setting" element, which has an bearding data type
defined inline.
Sample XSD book - dictionary.xsd
Let s alter my concordance XML book with XSD link, dictionary_xsd.xml:
<?xml version="1.0"?>
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="dictionary.xsd">
<!-- dictionary_xsd.xml
Absorb (c) 2002 by Dr. Yang
-->
<word acronym="true">
<name>XML</name>
<definition reference="'s Notes">eXtensible Markup
Language.</definition>
<update date="2002-12-23"/>
</word>
<word symbol="true">
<name><</name>
<definition>Mathematical attribute apery the "less than" analytic
operation, like: 1<2.</definition>
<definition>Reserved attribute in XML apery the alpha of
tags, like: <![CDATA[<p>Hello world!</p>]]>
</definition>
</word>
<word symbol="false" acronym="false">
<name>extensible</name>
<definition>Capable of getting extended.</definition>
</word>
</dictionary>
And address an XSD validation file, dictionary.xsd:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="dictionary" type="dictionaryType"/>
<xsd:complexType name="dictionaryType">
<xsd:sequence>
<xsd:element name="word" type="wordType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="wordType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="definition" type="definitionType"
maxOccurs="unbounded"/>
<xsd:element name="update" type="updateType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="acronym" type="xsd:boolean" use="optional"/>
<xsd:attribute name="symbol" type="xsd:boolean" use="optional"/>
</xsd:complexType>
<xsd:complexType name="definitionType" mixed="true">
<xsd:attribute name="reference" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="updateType">
<xsd:attribute name="date">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="p{Nd}{4}-p{Nd}{2}-p{Nd}{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:schema>
Note that:
- Anonymous data blazon is acclimated to ascertain my "date" attribute.
- A "pattern" angle is acclimated to bind a cord blazon with a approved expression.
- "dicstionary_xsd.xml" anesthetized XML Spy 5.3 XSchema validation.
|
complextype, element, attribute, definition, dictionary, sequence, string, symbol, anonymous, acronym, notes, , < xsd, xsd complextype, data type, xsd element, xsd sequence, < definition, element name, sequence <, xsd attribute, < word, complextype <, type xsd, complextype name, attribute name, string <, < name, xsd string, definition <, name <, dictionary xsd, word <, true <, xsd xml, < dictionary, anonymous data, xsd element name, xsd attribute name, xsd complextype name, < word symbol, org 2001 xmlschema, parent data type, attribute name attribute, type data type, anonymous data type, |
Also see ...
Validation with XMLReaderUnfortunately, I couldn t acquisition any XML parsers provided in J2SDK 1.4.1_02 that can validate XML anatomy adjoin XSD rules. So I downloaded one of the alotof
Using SAXParserFactory to Amount ParsersXerces J amalgamation can aswell be loaded by the SAXParserFactory.newInstance()method. Actuality is my SAXValidator.java: p
The achievement Elementoutput: An XSL element, confined as a arrangement statement. It sets arrangement agreement values to the XSL processor to ascendancy the achievement f
2. Using "element" and "attribute" statements: element: An XSL element, confined as an achievement statement. It inserts an XML elementwith the defined name into the output.br
Since XSL is a accent based on XML, so all XSL statements are accounting as XML elements. In this note, we will apprentice and play with three basal XSL elements:"stylesheet": Desclaring an XSL appe
The apply templates Elementapply templates: An XSL aspect confined as an activity statement. It requests the XSL processor to administer transformation templates to assertive eleme
Transformation ChainsWhen the XSL processor is transforming an aspect with a template, if the arrangement containsan "apply templates" statement, the XSL processor will authority the transf
Notice that the achievement architecture is abundant bigger now. Why? I accept amid a brace of HTML tags,<pre and </pre at the alpha and the end of the backup agreeable for the root aspect "p". It tells IE to present ag
After abstruse how and if to transform an aspect and its adolescent elements in the XML sourcefile, now we are traveling to attending at how to retrieve ethics out of the altered locations of thesource element.br
Openning dictionary_xsl.xml with Internet Explorer, I got: dictionary word acronym=true symbol= name XML definition adaptable Mar