ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 2 / 3 << | Prev | Next | |
Please, send all comments, bug-reports, and contributions to Jiri.Jirat@systinet.com. Thank you very much.
XML Schema keys: attributeFormDefault, attributeWhen the form is "unqualified" (default behaviour), the attributes must be from the null namespace.
Valid document <f:root xsi:schemaLocation="http://foo correct_0.xsd" xx="1" xmlns:f="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Invalid document <f:root xsi:schemaLocation="http://foo correct_0.xsd" f:xx="1" xmlns:f="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> |
Correct XML Schema (correct_0.xsd) <xsd:schema targetNamespace="http://foo" attributeFormDefault="unqualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://foo" > <xsd:element name="root"> <xsd:complexType> <xsd:attribute name="xx" type="xsd:string" use="required"/> </xsd:complexType> </xsd:element> </xsd:schema> |
We can set the namespace using the "ns" attribute, but if we want the attributes to be from some non-null namespace, we must explicitly put the "ns" attribute either to the "attribute/name" element or to the "attribute[@name]" element.
Valid document <f:root xx="1" xmlns:f="http://foo" /> Invalid document <f:root f:xx="1" xmlns:f="http://foo" /> |
Correct Relax NG schema (correctRelax_0.rng) |