The xsd.policy option specifies a modeling policy to generate an XML Schema schema.
The xsd.policy option takes one of the following values as a parameter:
The default configuration is auto
.
The xsd.policy option is reflected to the contents of the XML Schema schema.
List 29.3.3.1[xsdRngPolicy.rng] is an XML Schema schema.
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <start> <ref name="account"/> </start> <define name="account"> <element name="account"> <attribute name="accountNo"> <data type="token"/> </attribute> <element name="balance"> <data type="int"/> </element> <element name="owner"> <data type="token"/> </element> <optional> <ref name="address"/> </optional> <zeroOrMore> <ref name="phone"/> </zeroOrMore> </element> </define> <define name="address"> <element name="address"> <attribute name="zip"> <data type="token"/> </attribute> <text/> </element> </define> <define name="phone"> <element name="phone"> <attribute name="area"> <data type="token"/> </attribute> <data type="token"/> </element> </define> </grammar>
Execution of Relaxer using the xsd.policy option with a parameter 'auto' is as follows:
$ relaxer -xsd -xsd.policy:auto xsdPolicy.rng
As a result of this command, Relaxer generates one file:
The artifact of the XSD generator is shown in List 29.3.3.1.1[xsdRngPolicy.xsd].
<?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="account" type="account"/> <xsd:complexType name="account"> <xsd:sequence> <xsd:element name="balance" type="xsd:int"/> <xsd:element name="owner" type="xsd:token"/> <xsd:element maxOccurs="1" minOccurs="0" name="address" type="address"/> <xsd:element maxOccurs="unbounded" minOccurs="0" name="phone" \ type="phone"/> </xsd:sequence> <xsd:attribute name="accountNo" type="xsd:token"/> </xsd:complexType> <xsd:complexType name="address"> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="zip" type="xsd:token"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <xsd:complexType name="phone"> <xsd:simpleContent> <xsd:extension base="xsd:token"> <xsd:attribute name="area" type="xsd:token"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:schema>
Execution of Relaxer using the xsd.policy option with a parameter 'element' is as follows:
$ relaxer -xsd -xsd.policy:element xsdPolicy.rng
As a result of this command, Relaxer generates one file:
The artifact of the XSD generator is shown in List 29.3.3.2.1[xsdRngPolicy.xsd].
<?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="account"> <xsd:complexType> <xsd:sequence> <xsd:element name="balance" type="xsd:int"/> <xsd:element name="owner" type="xsd:token"/> <xsd:element maxOccurs="1" minOccurs="0" ref="address"/> <xsd:element maxOccurs="unbounded" minOccurs="0" ref="phone"/> </xsd:sequence> <xsd:attribute name="accountNo" type="xsd:token"/> </xsd:complexType> </xsd:element> <xsd:element name="address"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="zip" type="xsd:token"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:element> <xsd:element name="phone"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:token"> <xsd:attribute name="area" type="xsd:token"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:element> </xsd:schema>
Execution of Relaxer using the xsd.policy option with a parameter 'type' is as follows:
$ relaxer -xsd -xsd.policy:type xsdPolicy.rng
As a result of this command, Relaxer generates one file:
The artifact of the XSD generator is shown in List 29.3.3.3.1[xsdRngPolicy.xsd].
<?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="account" type="account"/> <xsd:complexType name="account"> <xsd:sequence> <xsd:element name="balance" type="xsd:int"/> <xsd:element name="owner" type="xsd:token"/> <xsd:element maxOccurs="1" minOccurs="0" name="address" type="address"/> <xsd:element maxOccurs="unbounded" minOccurs="0" name="phone" \ type="phone"/> </xsd:sequence> <xsd:attribute name="accountNo" type="xsd:token"/> </xsd:complexType> <xsd:complexType name="address"> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="zip" type="xsd:token"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <xsd:complexType name="phone"> <xsd:simpleContent> <xsd:extension base="xsd:token"> <xsd:attribute name="area" type="xsd:token"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:schema>