ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 4 / 4 << | Prev | Next | |
Please, send all comments, bug-reports, and contributions to Jiri.Jirat@systinet.com. Thank you very much.
XML Schema keys: redefineIn this example, we redefine the type "myString" from an arbitrary string to a string which cannot be more than 5 characters long. We will do this using redefine element.
Valid document <foo:root xsi:schemaLocation="http://foo correct_1.xsd" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bar="http://bar" >abcde</foo:root> Invalid document <foo:root xsi:schemaLocation="http://foo correct_1.xsd" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bar="http://bar" >abcdef</foo:root> |
Correct XML Schema (correct_0.xsd) <xsd:schema targetNamespace="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://foo" > <xsd:element name="root" type="foo:myString"/> <xsd:simpleType name="myString"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:schema> Correct XML Schema (correct_1.xsd) <xsd:schema targetNamespace="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://foo" > <xsd:redefine schemaLocation="correct_0.xsd"> <xsd:simpleType name="myString"> <xsd:restriction base="foo:myString"> <xsd:maxLength value="5"/> </xsd:restriction> </xsd:simpleType> </xsd:redefine> </xsd:schema> |