Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
9.6. XML Schema Document (XSD) File Sequencer
The XML Schema Document (XSD) File Sequencer can parse XML Schema Documents that adhere to the W3C's XML Schema Part 1 and Part 2 specifications, and output a representation of the XSD's attribute declarations, element declarations, simple type definitions, complex type definitions, import statements, include statements, attribute group declarations, annotations, other components, and even attributes with a non-schema namespace. This derived information is intended to accurately reflect the structure and semantics of the XSD files while also making it possible for users to easily navigate, query and search over this derived information. This sequencer captures the namespace and names of all referenced components, and will resolve references to components appearing within the same files.
The design of this sequencer and its output structure have been influenced by the SOA Repository Artifact Model and Protocol (S-RAMP) draft specification, which is currently under development as an OASIS Technology Committee. S-RAMP defines a model for a variety of file types, including WSDL and XSD. This sequencer's output was designed to mirror that model, and thus some of the properties and node types used are defined within the "sramp" namespace.
The XML Schema specification is powerful, flexible, rich, and complicated. This means that many XML Schema Documents themselves are complicated. But it also means that there is a lot of variation in XSDs, and consequently there is a lot of variation in the output structure that this sequencer derives from XSD files.
9.6.1. XSD File Sequencer Example Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Consider an example XML Schema Document taken from the XML Schema Primer :
<?xml version="1.0" encoding="ISO-8859-1" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation xml:lang="en"> Purchase order schema for Example.com. Copyright 2000 Example.com. All rights reserved. </xsd:documentation> </xsd:annotation> <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> <xsd:element name="comment" type="xsd:string"/> <xsd:complexType name="PurchaseOrderType"> <xsd:sequence> <xsd:element name="shipTo" type="USAddress"/> <xsd:element name="billTo" type="USAddress"/> <xsd:element ref="comment" minOccurs="0"/> <xsd:element name="items" type="Items"/> </xsd:sequence> <xsd:attribute name="orderDate" type="xsd:date"/> </xsd:complexType> <xsd:complexType name="USAddress"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="street" type="xsd:string"/> <xsd:element name="city" type="xsd:string"/> <xsd:element name="state" type="xsd:string"/> <xsd:element name="zip" type="xsd:decimal"/> </xsd:sequence> <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/> </xsd:complexType> <xsd:complexType name="Items"> <xsd:sequence> <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="productName" type="xsd:string"/> <xsd:element name="quantity"> <xsd:simpleType> <xsd:restriction base="xsd:positiveInteger"> <xsd:maxExclusive value="100"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="USPrice" type="xsd:decimal"/> <xsd:element ref="comment" minOccurs="0"/> <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> </xsd:sequence> <xsd:attribute name="partNum" type="SKU" use="required"/> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <!-- Stock Keeping Unit, a code for identifying products --> <xsd:simpleType name="SKU"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d{3}-[A-Z]{2}"/> </xsd:restriction> </xsd:simpleType> </xsd:schema>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation xml:lang="en">
Purchase order schema for Example.com.
Copyright 2000 Example.com. All rights reserved.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="shipTo" type="USAddress"/>
<xsd:element name="billTo" type="USAddress"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="items" type="Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:decimal"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN"
fixed="US"/>
</xsd:complexType>
<xsd:complexType name="Items">
<xsd:sequence>
<xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="quantity">
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="USPrice" type="xsd:decimal"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="partNum" type="SKU" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- Stock Keeping Unit, a code for identifying products -->
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
This schema defines the structure of several XML elements used to represent purchase orders, and describes an XML document such as the following:
<?xml version="1.0"?> <purchaseOrder orderDate="1999-10-20"> <shipTo country="US"> <name>Alice Smith</name> <street>123 Maple Street</street> <city>Mill Valley</city> <state>CA</state> <zip>90952</zip> </shipTo> <billTo country="US"> <name>Robert Smith</name> <street>8 Oak Avenue</street> <city>Old Town</city> <state>PA</state> <zip>95819</zip> </billTo> <comment>Hurry, my lawn is going wild<!/comment> <items> <item partNum="872-AA"> <productName>Lawnmower</productName> <quantity>1</quantity> <USPrice>148.95</USPrice> <comment>Confirm this is electric</comment> </item> <item partNum="926-AA"> <productName>Baby Monitor</productName> <quantity>1</quantity> <USPrice>39.98</USPrice> <shipDate>1999-05-21</shipDate> </item> </items> </purchaseOrder>
<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Mill Valley</city>
<state>CA</state>
<zip>90952</zip>
</shipTo>
<billTo country="US">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Old Town</city>
<state>PA</state>
<zip>95819</zip>
</billTo>
<comment>Hurry, my lawn is going wild<!/comment>
<items>
<item partNum="872-AA">
<productName>Lawnmower</productName>
<quantity>1</quantity>
<USPrice>148.95</USPrice>
<comment>Confirm this is electric</comment>
</item>
<item partNum="926-AA">
<productName>Baby Monitor</productName>
<quantity>1</quantity>
<USPrice>39.98</USPrice>
<shipDate>1999-05-21</shipDate>
</item>
</items>
</purchaseOrder>
The XSD sequencer will derive the following content from the above XSD:
<po.xsd jcr:primaryType=xs:schemaDocument jcr:mixinTypes=[mode:derived] - jcr:uuid=ca46f972-6875-481d-b9e1-cfb64ae76f74 - sramp:contentEncoding="UTF-8" - sramp:contentSize=2353 - sramp:contentType="application/xsd" - sramp:description="Purchase order schema for Example.com.> Copyright 2000 Example.com. All rights reserved." <purchaseOrder jcr:primaryType=xs:elementDeclaration - jcr:uuid=eff3bcfb-42d1-4d55-805b-5133279e15eb - xs:abstract=false - xs:form="qualified" - xs:ncName="purchaseOrder" - xs:nillable=false - xs:type=5088dc05-ad30-4d7d-8d24-3edc548a777f - xs:typeName="PurchaseOrderType"/> <comment jcr:primaryType=xs:elementDeclaration - jcr:uuid=2daaa747-01f1-41f3-b5c2-ec218d8a7290 - xs:abstract=false - xs:form="qualified" - xs:ncName="comment" - xs:nillable=false - xs:typeName="string" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema/> <PurchaseOrderType jcr:primaryType=xs:complexTypeDefinition - jcr:uuid=5088dc05-ad30-4d7d-8d24-3edc548a777f - xs:abstract=false - xs:baseTypeName="anyType" - xs:baseTypeNamespace="http://www.w3.org/2001/XMLSchema" - xs:method="restriction" - xs:mixed=false - xs:ncName="PurchaseOrderType"/> <xs:sequence jcr:primaryType=xs:sequence - jcr:uuid=1b87d92d-4d59-44ac-859f-2a51c3a48eb2 - xs:maxOccurs=1 - xs:minOccurs=1> <shipTo jcr:primaryType=xs:elementDeclaration - jcr:uuid=994ba18b-c389-4635-8ce3-27d3a81cf97d - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="shipTo" - xs:nillable=false - xs:type=dd683707-83bb-4893-aa6e-f3ce81237e76 - xs:typeName="USAddress"/> <billTo jcr:primaryType=xs:elementDeclaration - jcr:uuid=e260c1aa-5a5a-4db5-a962-b02576359ee7 - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="billTo" - xs:nillable=false - xs:type=dd683707-83bb-4893-aa6e-f3ce81237e76 - xs:typeName="USAddress"/> <comment jcr:primaryType=xs:elementDeclaration - jcr:uuid=a7796d20-0e7b-4833-96b6-16e0ac6676ca - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=0 - xs:nillable=false - xs:ref=2daaa747-01f1-41f3-b5c2-ec218d8a7290 - xs:refName="comment"/> <items jcr:primaryType=xs:elementDeclaration - jcr:uuid=02ab83d1-ea1a-4a7b-b66d-a1974f13ca63 - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="items" - xs:nillable=false - xs:type=7543bf0f-1753-4813-9a31-f2bbed34fd11 - xs:typeName="Items"/> <orderDate jcr:primaryType=xs:attributeDeclaration - jcr:uuid=8b23e048-c683-4d6d-8835-faf81df6912d - xs:ncName="orderDate" - xs:typeName="date" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema - xs:use="optional"/> <USAddress jcr:primaryType=xs:complexTypeDefinition - jcr:uuid=dd683707-83bb-4893-aa6e-f3ce81237e76 - xs:abstract=false - xs:baseTypeName="anyType" - xs:baseTypeNamespace="http://www.w3.org/2001/XMLSchema" - xs:method="restriction" - xs:mixed=false - xs:ncName="USAddress"/> <xs:sequence jcr:primaryType=xs:sequence - jcr:uuid=82411c47-7f1a-4b11-9778-acc310c9e51c - xs:maxOccurs=1 - xs:minOccurs=1> <name jcr:primaryType=xs:elementDeclaration - jcr:uuid=40dcb6fc-386c-4d3a-841b-dab478348d74 - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="name" - xs:nillable=false - xs:typeName="string" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema/> <street jcr:primaryType=xs:elementDeclaration - jcr:uuid=a3ff1a2d-38e7-442a-a46b-141fa1ac4442 - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="street" - xs:nillable=false - xs:typeName="string" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema /> <city jcr:primaryType=xs:elementDeclaration - jcr:uuid=30d4215f-cd44-4857-9589-3df127e42cf3 - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="city" - xs:nillable=false - xs:typeName="string" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema/> <state jcr:primaryType=xs:elementDeclaration - jcr:uuid=061a58d9-94fd-4dca-84e2-6ced7fe523fe - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="state" - xs:nillable=false - xs:typeName="string" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema/> <zip jcr:primaryType=xs:elementDeclaration - jcr:uuid=100dc3cc-b59f-4835-b14e-243b9e7a2ecf - xs:abstract=false - xs:form="qualified" - xs:maxOccurs=1 - xs:minOccurs=1 - xs:ncName="zip" - xs:nillable=false - xs:typeName="decimal" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema/> <country jcr:primaryType=xs:attributeDeclaration - jcr:uuid=f323219f-bea0-4d6f-9ad5-f51cf8409f13 - xs:ncName="country" - xs:typeName="NMTOKEN" - xs:typeNamespace=http://www.w3.org/2001/XMLSchema - xs:use="optional"/> <Items jcr:primaryType=xs:complexTypeDefinition - jcr:uuid=7543bf0f-1753-4813-9a31-f2bbed34fd11 - xs:abstract=false - xs:baseTypeName="anyType" - xs:baseTypeNamespace="http://www.w3.org/2001/XMLSchema" - xs:method="restriction" - xs:mixed=false - xs:ncName="Items"/> <xs:sequence jcr:primaryType=xs:sequence - jcr:uuid=d907da56-f370-40e3-b06e-e3a5ae957f4d - xs:maxOccurs=1 - xs:minOccurs=1/> <item jcr:primaryType=xs:elementDeclaration - jcr:uuid=87cc1352-2f90-49f4-9f36-3db7b9ffcf26 - xs:abstract=false - xs:form="qualified" - xs:minOccurs=0 - xs:ncName="item" - xs:nillable=false/> <SKU jcr:primaryType=xs:simpleTypeDefinition - jcr:uuid=4127108d-a699-461e-8210-3bb40c923318 - xs:baseTypeName="string" - xs:baseTypeNamespace=http://www.w3.org/2001/XMLSchema - xs:ncName="SKU" - xs:pattern="\d{3}-[A-Z]{2}"/>
<po.xsd jcr:primaryType=xs:schemaDocument jcr:mixinTypes=[mode:derived]
- jcr:uuid=ca46f972-6875-481d-b9e1-cfb64ae76f74
- sramp:contentEncoding="UTF-8"
- sramp:contentSize=2353
- sramp:contentType="application/xsd"
- sramp:description="Purchase order schema for Example.com.>
Copyright 2000 Example.com. All rights reserved."
<purchaseOrder jcr:primaryType=xs:elementDeclaration
- jcr:uuid=eff3bcfb-42d1-4d55-805b-5133279e15eb
- xs:abstract=false
- xs:form="qualified"
- xs:ncName="purchaseOrder"
- xs:nillable=false
- xs:type=5088dc05-ad30-4d7d-8d24-3edc548a777f
- xs:typeName="PurchaseOrderType"/>
<comment jcr:primaryType=xs:elementDeclaration
- jcr:uuid=2daaa747-01f1-41f3-b5c2-ec218d8a7290
- xs:abstract=false
- xs:form="qualified"
- xs:ncName="comment"
- xs:nillable=false
- xs:typeName="string"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema/>
<PurchaseOrderType jcr:primaryType=xs:complexTypeDefinition
- jcr:uuid=5088dc05-ad30-4d7d-8d24-3edc548a777f
- xs:abstract=false
- xs:baseTypeName="anyType"
- xs:baseTypeNamespace="http://www.w3.org/2001/XMLSchema"
- xs:method="restriction"
- xs:mixed=false
- xs:ncName="PurchaseOrderType"/>
<xs:sequence jcr:primaryType=xs:sequence
- jcr:uuid=1b87d92d-4d59-44ac-859f-2a51c3a48eb2
- xs:maxOccurs=1
- xs:minOccurs=1>
<shipTo jcr:primaryType=xs:elementDeclaration
- jcr:uuid=994ba18b-c389-4635-8ce3-27d3a81cf97d
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="shipTo"
- xs:nillable=false
- xs:type=dd683707-83bb-4893-aa6e-f3ce81237e76
- xs:typeName="USAddress"/>
<billTo jcr:primaryType=xs:elementDeclaration
- jcr:uuid=e260c1aa-5a5a-4db5-a962-b02576359ee7
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="billTo"
- xs:nillable=false
- xs:type=dd683707-83bb-4893-aa6e-f3ce81237e76
- xs:typeName="USAddress"/>
<comment jcr:primaryType=xs:elementDeclaration
- jcr:uuid=a7796d20-0e7b-4833-96b6-16e0ac6676ca
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=0
- xs:nillable=false
- xs:ref=2daaa747-01f1-41f3-b5c2-ec218d8a7290
- xs:refName="comment"/>
<items jcr:primaryType=xs:elementDeclaration
- jcr:uuid=02ab83d1-ea1a-4a7b-b66d-a1974f13ca63
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="items"
- xs:nillable=false
- xs:type=7543bf0f-1753-4813-9a31-f2bbed34fd11
- xs:typeName="Items"/>
<orderDate jcr:primaryType=xs:attributeDeclaration
- jcr:uuid=8b23e048-c683-4d6d-8835-faf81df6912d
- xs:ncName="orderDate"
- xs:typeName="date"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema
- xs:use="optional"/>
<USAddress jcr:primaryType=xs:complexTypeDefinition
- jcr:uuid=dd683707-83bb-4893-aa6e-f3ce81237e76
- xs:abstract=false
- xs:baseTypeName="anyType"
- xs:baseTypeNamespace="http://www.w3.org/2001/XMLSchema"
- xs:method="restriction"
- xs:mixed=false
- xs:ncName="USAddress"/>
<xs:sequence jcr:primaryType=xs:sequence
- jcr:uuid=82411c47-7f1a-4b11-9778-acc310c9e51c
- xs:maxOccurs=1
- xs:minOccurs=1>
<name jcr:primaryType=xs:elementDeclaration
- jcr:uuid=40dcb6fc-386c-4d3a-841b-dab478348d74
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="name"
- xs:nillable=false
- xs:typeName="string"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema/>
<street jcr:primaryType=xs:elementDeclaration
- jcr:uuid=a3ff1a2d-38e7-442a-a46b-141fa1ac4442
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="street"
- xs:nillable=false
- xs:typeName="string"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema />
<city jcr:primaryType=xs:elementDeclaration
- jcr:uuid=30d4215f-cd44-4857-9589-3df127e42cf3
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="city"
- xs:nillable=false
- xs:typeName="string"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema/>
<state jcr:primaryType=xs:elementDeclaration
- jcr:uuid=061a58d9-94fd-4dca-84e2-6ced7fe523fe
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="state"
- xs:nillable=false
- xs:typeName="string"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema/>
<zip jcr:primaryType=xs:elementDeclaration
- jcr:uuid=100dc3cc-b59f-4835-b14e-243b9e7a2ecf
- xs:abstract=false
- xs:form="qualified"
- xs:maxOccurs=1
- xs:minOccurs=1
- xs:ncName="zip"
- xs:nillable=false
- xs:typeName="decimal"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema/>
<country jcr:primaryType=xs:attributeDeclaration
- jcr:uuid=f323219f-bea0-4d6f-9ad5-f51cf8409f13
- xs:ncName="country"
- xs:typeName="NMTOKEN"
- xs:typeNamespace=http://www.w3.org/2001/XMLSchema
- xs:use="optional"/>
<Items jcr:primaryType=xs:complexTypeDefinition
- jcr:uuid=7543bf0f-1753-4813-9a31-f2bbed34fd11
- xs:abstract=false
- xs:baseTypeName="anyType"
- xs:baseTypeNamespace="http://www.w3.org/2001/XMLSchema"
- xs:method="restriction"
- xs:mixed=false
- xs:ncName="Items"/>
<xs:sequence jcr:primaryType=xs:sequence
- jcr:uuid=d907da56-f370-40e3-b06e-e3a5ae957f4d
- xs:maxOccurs=1
- xs:minOccurs=1/>
<item jcr:primaryType=xs:elementDeclaration
- jcr:uuid=87cc1352-2f90-49f4-9f36-3db7b9ffcf26
- xs:abstract=false
- xs:form="qualified"
- xs:minOccurs=0
- xs:ncName="item"
- xs:nillable=false/>
<SKU jcr:primaryType=xs:simpleTypeDefinition
- jcr:uuid=4127108d-a699-461e-8210-3bb40c923318
- xs:baseTypeName="string"
- xs:baseTypeNamespace=http://www.w3.org/2001/XMLSchema
- xs:ncName="SKU"
- xs:pattern="\d{3}-[A-Z]{2}"/>
The first thing to note is that the sequencer produces a node of type
xs:schemaDocument
that includes the mode:derived
information, information about the XSD itself, plus an sramp:description
property containing the documentation content from any annotations directly under the schema
element in the XSD.
Secondly, there is a node for each top-level element declaration, namely
purchaseOrder
and comment
, with properties capturing the element's name, namespace (not shown since there is no target namespace for the schema), and XSD type name, namespace and reference. The comment
element declaration has a base type of xs:string
, whereas the purchaseOrder
element declaration has a type of PurchaseOrderType
(defined later in the XSD and in the derived content). Each node is mix:referenceable
and has a jcr:uuid
property, allowing the purchaseOrder
element declaration to have a xs:type
REFERENCE property pointing to the PurchaseOrderType
complex type definition node.
There are also nodes representing each of the global complex type definitions, including
PurchaseOrderType
, USAddress
, Items
, and SKU
. Each of these nodes has properties representing the complex type's features (such as abstract
, mixed
, name
, etc.), as well as child nodes that represent the definition of the complex type's content (e.g., sequence, choice, all, simple content, complex content, etc.).
This example shows some of the structure that this sequencer derives from the XML Schema Documents. Our goal for this sequencer was to output content that reflected as accurately as possible the structure of the XML Schema Documents while also making the content easy to navigate, search and query.
9.6.2. XSD File Sequencer Node Types Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The XSD sequencer follows JCR best-practices by defining all nodes to have a primary type that allows any single or multi-valued property, meaning it is possible and valid for any node to have any property (with single or multiple values). In fact, this feature is used when XSD files contain attributes with non-schema namespaces, which are then mapped onto properties with the attributes name and possibly-empty namespace. However, it is still useful to capture the metadata about what that node represents, and so the sequencer use explicit node type definitions and mixins for this.
9.6.3. XSD File Sequencer CND Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The compact node definitions for the "xs" namespace are as follows:
//------------------------------------------------------------------------------ // N A M E S P A C E S //------------------------------------------------------------------------------ <jcr='http://www.jcp.org/jcr/1.0'> <nt='http://www.jcp.org/jcr/nt/1.0'> <mix='http://www.jcp.org/jcr/mix/1.0'> <sramp = "http://s-ramp.org/xmlns/2010/s-ramp"> <xs = "http://www.w3.org/2001/XMLSchema"> //------------------------------------------------------------------------------ // N O D E T Y P E S //------------------------------------------------------------------------------ [xs:component] > sramp:derivedArtifactType abstract - xs:id (string) - * (undefined) multiple - * (undefined) [xs:namespaced] mixin - xs:namespace (uri) [xs:located] mixin - xs:schemaLocation (string) [xs:import] > xs:component, xs:located, xs:namespaced [xs:include] > xs:component, xs:located [xs:redefine] > xs:component, xs:located [xs:named] > xs:namespaced mixin - xs:ncName (string) [xs:typeDefinition] > xs:component // A mixin representing a reference to an 'xs:typeDefinition' [xs:typed] mixin - xs:typeName (string) - xs:typeNamespace (uri) - xs:type (weakreference) < 'xs:typeDefinition' // Attribute wildcard [xs:anyAttribute] > xs:component - xs:minOccurs (long) < '[0,)' - xs:maxOccurs (long) < '[0,)' - xs:namespace (uri) multiple - xs:processContents (string) = 'strict' < 'lax', 'strict', 'skip' // // The 'group', 'all', 'sequence' and 'choice' components // [xs:modelGroup] > xs:component abstract - xs:minOccurs (long) < '[0,)' - xs:maxOccurs (long) < '[0,)' - xs:refName (string) - xs:refNamespace (uri) - xs:ref (weakReference) < 'xs:modelGroup' + * (xs:elementDeclaration) [xs:group] > xs:modelGroup + 'xs:anyAttribute' (xs:anyAttribute) [xs:all] > xs:modelGroup [xs:sequence] > xs:modelGroup + 'xs:sequence' (xs:sequence) + 'xs:choice' (xs:choice) + 'xs:all' (xs:all) + 'xs:anyAttribute' (xs:anyAttribute) [xs:choice] > xs:modelGroup + 'xs:sequence' (xs:sequence) + 'xs:choice' (xs:choice) + 'xs:all' (xs:all) + 'xs:anyAttribute' (xs:anyAttribute) // // The 'simpleContent' and 'complexContent' components // [xs:complexContent] > xs:component - xs:method (string) < 'restriction', 'extension' + * (xs:attributeDeclaration) + * (xs:attributeGroup) + * (xs:group) + 'xs:anyAttribute' (xs:anyAttribute) + 'xs:sequence' (xs:sequence) + 'xs:choice' (xs:choice) + 'xs:all' (xs:all) [xs:simpleContent] > xs:component - xs:method (string) < 'restriction', 'extension' - xs:minValueExclusive (*) - xs:minValueInclusive (*) - xs:maxValueExclusive (*) - xs:maxValueInclusive (*) - xs:totalDigits (long) < '[0,]' - xs:fractionDigits (long) < '[0,]' - xs:length (long) - xs:maxLength (long) < '[0,]' - xs:minLength (long) < '[0,]' - xs:enumeratedValues (string) multiple - xs:whitespace (string) < 'preserve','collapse','replace' - xs:pattern (string) + * (xs:attributeDeclaration) sns + * (xs:attributeGroup) sns + * (xs:simpleTypeDefinition) sns + 'xs:anyAttribute' (xs:anyAttribute) // // Attribute Groups // [xs:attributeGroup] > xs:component - xs:ncName (string) - xs:namespace (uri) - xs:refName (string) - xs:refNamespace (uri) - xs:ref (weakReference) < 'xs:attributeGroup' + * (xs:attributeDeclaration) sns + * (xs:attributeGroup) sns + 'xs:anyAttribute' (xs:anyAttribute) // // Complex and simple type definitions // [xs:complexTypeDefinition] > xs:typeDefinition, xs:named - xs:abstract (boolean) = 'false' - xs:mixed (boolean) = 'false' - xs:block (string) multiple < 'restriction', 'extension', 'all' - xs:final (string) multiple < 'restriction', 'extension', 'all' + * (xs:attributeDeclaration) sns + * (xs:attributeGroup) sns + * (xs:complexContent) sns + * (xs:simpleContent) sns + * (xs:group) sns + 'xs:anyAttribute' (xs:anyAttribute) + 'xs:sequence' (xs:sequence) + 'xs:choice' (xs:choice) + 'xs:all' (xs:all) [xs:simpleTypeDefinition] > xs:typeDefinition, xs:named - xs:baseTypeName (string) - xs:baseTypeNamespace (uri) - xs:baseType (weakreference) < 'xs:typeDefinition' - xs:final (string) multiple < 'restriction', 'list', 'union', 'all' // // Attribute declaration // [xs:attributeDeclaration] > xs:component, xs:named, xs:typed - xs:length (long) - xs:maxLength (long) - xs:minLength (long) - xs:enumeratedValues (string) multiple - xs:whitespace (string) < 'preserve','collapse','replace' - xs:maxValueExclusive (*) - xs:minValueExclusive (*) - xs:maxValueInclusive (*) - xs:minValueInclusive (*) - xs:totalDigits (long) - xs:fractionDigits (long) - xs:pattern (string) - xs:use (string) // // Identity constraint definition // [xs:selector] > xs:component - xs:xpath (string) mandatory [xs:field] > xs:component - xs:xpath (string) mandatory [xs:identityConstraintDefinition] > xs:component abstract - xs:ncName (string) mandatory + 'selector' (xs:selector) + 'field' (xs:field) sns [xs:unique] > xs:identityConstraintDefinition [xs:key] > xs:identityConstraintDefinition [xs:keyref] > xs:identityConstraintDefinition - xs:refer (string) mandatory // // Element declaration // [xs:elementDeclaration] > xs:component, xs:named, xs:typed - xs:abstract (boolean) = 'false' - xs:nillable (boolean) = 'false' - xs:final (string) multiple < 'all', 'extension', 'restriction' - xs:block (string) multiple < 'all', 'extension', 'restriction', 'substitution' - xs:default (string) - xs:fixed (string) - xs:form (string) < 'qualified', 'unqualified' - xs:minOccurs (long) < '[0,)' - xs:maxOccurs (long) < '[0,)' - xs:refName (string) - xs:refNamespace (uri) - xs:ref (weakReference) < 'xs:elementDeclaration' - xs:substitutionGroupName (string) - xs:substitutionGroup (weakReference) < 'xs:elementDeclaration' + * (xs:typeDefinition) + * (xs:identityConstraintDefinition) // // XML Schema Document // [xs:schemaDocument] > sramp:xmlDocument - xs:id (string) - xs:targetNamespace (uri) - xs:version (string) - xs:attributeFormDefault (string) = 'unqualified' < 'qualified', 'unqualified' - xs:elementFormDefault (string) = 'unqualified' < 'qualified', 'unqualified' - xs:finalDefault (string) multiple < 'all', 'extension', 'restriction', 'list', 'union' - xs:blockDefault (string) multiple < 'all', 'extension', 'restriction', 'substitution' - xs:importedXsds (weakreference) multiple < 'xs:xsdDocument' - xs:includedXsds (weakreference) multiple < 'xs:xsdDocument' - xs:redefinedXsds (weakreference) multiple < 'xs:xsdDocument' - * (undefined) multiple - * (undefined) + * (xs:import) sns + * (xs:include) sns + * (xs:redefine) sns // Technically need 'sns' because the attributes, elements, simple types, complex types, attribute groups, // and groups don't share same name scopes + * (xs:attributeDeclaration) sns + * (xs:elementDeclaration) sns + * (xs:attributeGroup) sns + * (xs:group) sns + * (xs:simpleTypeDefinition) sns + * (xs:complexTypeDefinition) sns
//------------------------------------------------------------------------------
// N A M E S P A C E S
//------------------------------------------------------------------------------
<jcr='http://www.jcp.org/jcr/1.0'>
<nt='http://www.jcp.org/jcr/nt/1.0'>
<mix='http://www.jcp.org/jcr/mix/1.0'>
<sramp = "http://s-ramp.org/xmlns/2010/s-ramp">
<xs = "http://www.w3.org/2001/XMLSchema">
//------------------------------------------------------------------------------
// N O D E T Y P E S
//------------------------------------------------------------------------------
[xs:component] > sramp:derivedArtifactType abstract
- xs:id (string)
- * (undefined) multiple
- * (undefined)
[xs:namespaced] mixin
- xs:namespace (uri)
[xs:located] mixin
- xs:schemaLocation (string)
[xs:import] > xs:component, xs:located, xs:namespaced
[xs:include] > xs:component, xs:located
[xs:redefine] > xs:component, xs:located
[xs:named] > xs:namespaced mixin
- xs:ncName (string)
[xs:typeDefinition] > xs:component
// A mixin representing a reference to an 'xs:typeDefinition'
[xs:typed] mixin
- xs:typeName (string)
- xs:typeNamespace (uri)
- xs:type (weakreference) < 'xs:typeDefinition'
// Attribute wildcard
[xs:anyAttribute] > xs:component
- xs:minOccurs (long) < '[0,)'
- xs:maxOccurs (long) < '[0,)'
- xs:namespace (uri) multiple
- xs:processContents (string) = 'strict' < 'lax', 'strict', 'skip'
//
// The 'group', 'all', 'sequence' and 'choice' components
//
[xs:modelGroup] > xs:component abstract
- xs:minOccurs (long) < '[0,)'
- xs:maxOccurs (long) < '[0,)'
- xs:refName (string)
- xs:refNamespace (uri)
- xs:ref (weakReference) < 'xs:modelGroup'
+ * (xs:elementDeclaration)
[xs:group] > xs:modelGroup
+ 'xs:anyAttribute' (xs:anyAttribute)
[xs:all] > xs:modelGroup
[xs:sequence] > xs:modelGroup
+ 'xs:sequence' (xs:sequence)
+ 'xs:choice' (xs:choice)
+ 'xs:all' (xs:all)
+ 'xs:anyAttribute' (xs:anyAttribute)
[xs:choice] > xs:modelGroup
+ 'xs:sequence' (xs:sequence)
+ 'xs:choice' (xs:choice)
+ 'xs:all' (xs:all)
+ 'xs:anyAttribute' (xs:anyAttribute)
//
// The 'simpleContent' and 'complexContent' components
//
[xs:complexContent] > xs:component
- xs:method (string) < 'restriction', 'extension'
+ * (xs:attributeDeclaration)
+ * (xs:attributeGroup)
+ * (xs:group)
+ 'xs:anyAttribute' (xs:anyAttribute)
+ 'xs:sequence' (xs:sequence)
+ 'xs:choice' (xs:choice)
+ 'xs:all' (xs:all)
[xs:simpleContent] > xs:component
- xs:method (string) < 'restriction', 'extension'
- xs:minValueExclusive (*)
- xs:minValueInclusive (*)
- xs:maxValueExclusive (*)
- xs:maxValueInclusive (*)
- xs:totalDigits (long) < '[0,]'
- xs:fractionDigits (long) < '[0,]'
- xs:length (long)
- xs:maxLength (long) < '[0,]'
- xs:minLength (long) < '[0,]'
- xs:enumeratedValues (string) multiple
- xs:whitespace (string) < 'preserve','collapse','replace'
- xs:pattern (string)
+ * (xs:attributeDeclaration) sns
+ * (xs:attributeGroup) sns
+ * (xs:simpleTypeDefinition) sns
+ 'xs:anyAttribute' (xs:anyAttribute)
//
// Attribute Groups
//
[xs:attributeGroup] > xs:component
- xs:ncName (string)
- xs:namespace (uri)
- xs:refName (string)
- xs:refNamespace (uri)
- xs:ref (weakReference) < 'xs:attributeGroup'
+ * (xs:attributeDeclaration) sns
+ * (xs:attributeGroup) sns
+ 'xs:anyAttribute' (xs:anyAttribute)
//
// Complex and simple type definitions
//
[xs:complexTypeDefinition] > xs:typeDefinition, xs:named
- xs:abstract (boolean) = 'false'
- xs:mixed (boolean) = 'false'
- xs:block (string) multiple < 'restriction', 'extension', 'all'
- xs:final (string) multiple < 'restriction', 'extension', 'all'
+ * (xs:attributeDeclaration) sns
+ * (xs:attributeGroup) sns
+ * (xs:complexContent) sns
+ * (xs:simpleContent) sns
+ * (xs:group) sns
+ 'xs:anyAttribute' (xs:anyAttribute)
+ 'xs:sequence' (xs:sequence)
+ 'xs:choice' (xs:choice)
+ 'xs:all' (xs:all)
[xs:simpleTypeDefinition] > xs:typeDefinition, xs:named
- xs:baseTypeName (string)
- xs:baseTypeNamespace (uri)
- xs:baseType (weakreference) < 'xs:typeDefinition'
- xs:final (string) multiple < 'restriction', 'list', 'union', 'all'
//
// Attribute declaration
//
[xs:attributeDeclaration] > xs:component, xs:named, xs:typed
- xs:length (long)
- xs:maxLength (long)
- xs:minLength (long)
- xs:enumeratedValues (string) multiple
- xs:whitespace (string) < 'preserve','collapse','replace'
- xs:maxValueExclusive (*)
- xs:minValueExclusive (*)
- xs:maxValueInclusive (*)
- xs:minValueInclusive (*)
- xs:totalDigits (long)
- xs:fractionDigits (long)
- xs:pattern (string)
- xs:use (string)
//
// Identity constraint definition
//
[xs:selector] > xs:component
- xs:xpath (string) mandatory
[xs:field] > xs:component
- xs:xpath (string) mandatory
[xs:identityConstraintDefinition] > xs:component abstract
- xs:ncName (string) mandatory
+ 'selector' (xs:selector)
+ 'field' (xs:field) sns
[xs:unique] > xs:identityConstraintDefinition
[xs:key] > xs:identityConstraintDefinition
[xs:keyref] > xs:identityConstraintDefinition
- xs:refer (string) mandatory
//
// Element declaration
//
[xs:elementDeclaration] > xs:component, xs:named, xs:typed
- xs:abstract (boolean) = 'false'
- xs:nillable (boolean) = 'false'
- xs:final (string) multiple < 'all', 'extension', 'restriction'
- xs:block (string) multiple < 'all', 'extension', 'restriction', 'substitution'
- xs:default (string)
- xs:fixed (string)
- xs:form (string) < 'qualified', 'unqualified'
- xs:minOccurs (long) < '[0,)'
- xs:maxOccurs (long) < '[0,)'
- xs:refName (string)
- xs:refNamespace (uri)
- xs:ref (weakReference) < 'xs:elementDeclaration'
- xs:substitutionGroupName (string)
- xs:substitutionGroup (weakReference) < 'xs:elementDeclaration'
+ * (xs:typeDefinition)
+ * (xs:identityConstraintDefinition)
//
// XML Schema Document
//
[xs:schemaDocument] > sramp:xmlDocument
- xs:id (string)
- xs:targetNamespace (uri)
- xs:version (string)
- xs:attributeFormDefault (string) = 'unqualified' < 'qualified', 'unqualified'
- xs:elementFormDefault (string) = 'unqualified' < 'qualified', 'unqualified'
- xs:finalDefault (string) multiple < 'all', 'extension', 'restriction', 'list', 'union'
- xs:blockDefault (string) multiple < 'all', 'extension', 'restriction', 'substitution'
- xs:importedXsds (weakreference) multiple < 'xs:xsdDocument'
- xs:includedXsds (weakreference) multiple < 'xs:xsdDocument'
- xs:redefinedXsds (weakreference) multiple < 'xs:xsdDocument'
- * (undefined) multiple
- * (undefined)
+ * (xs:import) sns
+ * (xs:include) sns
+ * (xs:redefine) sns
// Technically need 'sns' because the attributes, elements, simple types, complex types, attribute groups,
// and groups don't share same name scopes
+ * (xs:attributeDeclaration) sns
+ * (xs:elementDeclaration) sns
+ * (xs:attributeGroup) sns
+ * (xs:group) sns
+ * (xs:simpleTypeDefinition) sns
+ * (xs:complexTypeDefinition) sns
These types use some of the node types and mixins defined in the
sramp
namespace:
9.6.4. Using the XSD File Sequencer Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To use the XSD File Sequencer, include the appropriate version of the Maven artifact with a
org.modeshape
group ID and modeshape-sequencer-xsd
and modeshape-sequencer-sramp
artifacts ID. Or, if you're using JAR files and manually setting up the classpath for your application, use the modeshape-sequencer-xsd-2.7.0.Final-jar-with-dependencies.jar
file. Then, define a sequencing configuration, using something similar to:
{ "name" : "XSD Sequencer Test Repository", "sequencing" : { "removeDerivedContentWithOriginal" : true, "sequencers" : { "XSD Sequencer" : { "classname" : "xsdsequencer", "pathExpressions" : [ "default:/(*.xsd)/jcr:content[@jcr:data]" ] } } } }
{
"name" : "XSD Sequencer Test Repository",
"sequencing" : {
"removeDerivedContentWithOriginal" : true,
"sequencers" : {
"XSD Sequencer" : {
"classname" : "xsdsequencer",
"pathExpressions" : [ "default:/(*.xsd)/jcr:content[@jcr:data]" ]
}
}
}
}