René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Simple and complex types | ||
Simple Type
The schema file:
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="simple-element" /> <xsd:element name="rootelem"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="simple-element" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
The XML file:
<?xml version="1.0" encoding="ISO-8859-1" ?> <rootelem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="si.xsd"> > <simple-element>only text here</simple-element> </rootelem> Complex empty element
The schema file:
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="rootelem"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="complex-empty-element"> <xsd:complexType> <xsd:attribute name="some_attr" type="xsd:integer" /> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
The XML file:
<?xml version="1.0" encoding="ISO-8859-1" ?> <rootelem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ce.xsd"> > <complex-empty-element some_attr="42"></complex-empty-element> </rootelem> Complex mixed content
The schema file:
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="rootelem"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="hello"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="name" type="xsd:string" /> <xsd:element name="date" type="xsd:date" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
The XML file:
<?xml version="1.0" encoding="ISO-8859-1" ?> <rootelem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mc.xsd"> > <hello>I am going to see <name>Mr Morgan</name> on <date>2004-08-28</date>.</hello> </rootelem> Complex Text only
The schema file:
The XML file:
Simple Type
The schema file:
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="rootelem"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="text-only"> <xsd:complexType> <xsd:attribute name="an_attribute" type="xsd:positiveInteger" /> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
The XML file:
<?xml version="1.0" encoding="ISO-8859-1" ?> <rootelem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="to.xsd"> > <text-only an_attribute="44"></text-only> </rootelem> |