June 2008
Intermediate to advanced
986 pages
27h 8m
English
Our next step is to create an attribute for our empty element. To do that, we declare what XML Schema refers to as a complex type:
<?xml version="1.0" encoding="UTF-8"?> <!-- empty2.xsd --> <xs:schema xmlns="http://www.oreilly.com/xslt" targetNamespace="http://www.oreilly.com/xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="empty2"> <xs:complexType> <xs:attribute name="color"/> </xs:complexType> </xs:element> </xs:schema>
The XML document is slightly more interesting now:
<?xml version="1.0" encoding="utf-8"?> <!-- empty2.xml --> <empty2 xmlns="http://www.oreilly.com/xslt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oreilly.com/xslt empty2.xsd" color="blue"/>
We simply declared an attribute with a name here. We could have declared a datatype for the attribute; we’ll do that soon.
Read now
Unlock full access