100 likes | 178 Views
Organization. No tutorial next week Next sheet hand in on the 05.06.07 Tuesday. <?xml version="1.0"?> <movies xmlns:xmllib="http://www.xmlmovielibrary.com"> <xmllib:title>Star Wars:Episode I-The Phantom Menace</xmllib:title> <xmllib:year>1999</xmllib:year>
E N D
Organization • No tutorial next week • Next sheet hand in on the 05.06.07 Tuesday
<?xml version="1.0"?> <movies xmlns:xmllib="http://www.xmlmovielibrary.com"> <xmllib:title>Star Wars:Episode I-The Phantom Menace</xmllib:title> <xmllib:year>1999</xmllib:year> <purchase xmlns:xmllib="http://www.othermovielibrary.com"> <xmllib:title>Star Wars:Episode II-Attack of the Clones </xmllib:title> <xmllib:year>2002</xmllib:year> </purchase> <xmllib:title>Star Wars:Episode III-Revenge of the Sith</xmllib:title> <xmllib:year>2005</xmllib:year> </movies> • The W3C Namespaces in XML Recommendation enforces some namespace constraints: • Prefixes beginning with the three-letter sequence x, m, and l, in any case combination, are reserved for use by XML and XML-related specifications. Although not a fatal error, it is inadvisable to bind such prefixes. The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. • A prefix cannot be used unless it is declared and bound to a namespace. (Using variable in Java without declaring it)
<?xml version="1.0"?> <bk:book xmlns:bk="tar"> <bk:title/> </bk:book> <?xml version="1.0"?> <bk:book xmlns:bk="tar"> <title/> </bk:book> <?xml version="1.0"?> <book xmlns="tar"> <title xmlns=“”/> </book>
<?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:abc="http://abc.com/" targetNamespace="http://abc.com/" elementFormDefault="unqualified" attributeFormDefault="unqualified"> <element name="books" type="abc:t1"/> <element name="comments" type="string"/> <complexType name="t1"> <sequence> <element name="book" type="abc:t2"/> <element ref="abc:comments" minOccurs="0"/> </sequence> </complexType> <complexType name="t2"> <sequence> <element name="title" type="string"/> </sequence> </complexType> </schema>
<?xml version="1.0" encoding="UTF-8"?> <bk:books xmlns:bk="http://www.abc.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <book> <title>XML for dummies</title> </book> <bk:comments>Books one the topc XML</bk:comments> </bk:books> Qualified:definine elements and attributes in the target namespace Unqualified: elements and attributes in any namespace <?xml version="1.0" encoding="UTF-8"?> <bk:books xmlns:bk="http://www.abc.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <bk:book> <bk:title>XML for dummies</bk:title> </bk:book> <bk:comments>Books one the topc XML</bk:comments> </bk:books>
… <xsd:key name="itemNumKey"> <xsd:selector xpath=".//item"/> <xsd:field xpath="number"/> </xsd:key> <xsd:keyref name="itemNumKeyRef" refer="itemNumKey"> <xsd:selector xpath="products/*"/> <xsd:field xpath="@number"/> </xsd:keyref> </xsd:element> …..
Unique vs. Key • Unique = guarantees uniqueness, nullable • Key = guarantees uniqueness and existence • always be present (minOccurs must be greater than zero) • be non-nullable (i.e., nullable="false") • be unique • Key implies unique, but unique does not imply key