Description
In order for GenRocket to import, parse an XSD and convert its information into GenRocket Domains and establish Domain Parent/Child/Sibling relationships, a consistent XSD format must be adhered to. The XSD format defined below not only helps GenRocket easily and quickly parse an XSD document, its format design pattern also makes it easy for anyone to define a heavily nested XSD.
Design Pattern
The diagram below show the basic design pattern XSD documents need to follow to be compatible for importing into the GenRocket platform.
Schema Definition
The XSD defined below, is that starting template to use to describe GenRocket compatible XSD documents.
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" version="1.0"> <xs:element name="root" type="root"/> <xs:complexType name="root"> <xs:sequence> <xs:element name="" type=""/> <xs:element name="" type=""/> <xs:element name="child" type="child"/> </xs:sequence> <xs:attribute name="" type=""/> <xs:attribute name="" type=""/> <xs:attribute name="" type=""/> </xs:complexType> <xs:complexType name="child"> <xs:sequence/> <xs:attribute/> </xs:complexType> </xs:schema>
Schema Definition Header
The <schema> element is the root element of every XML Schema. The <schema> element may contain some attributes, but only the first attribute is mandatory.
- The fragment, xmlns:xs=" http://www.w3.org/2001/XMLSchema" indicates that the elements and data types used in the schema come from the "http://www.w3.org/2001/XMLSchema" namespace. It also specifies that the elements and data types that come from the "http://www.w3.org/2001/XMLSchema" namespace should be prefixed with xs:
- The fragment, elementFormDefault="unqualified", indicates that any elements used by the XML instance document which were declared in this schema do not have to be namespace qualified.
- The fragment, version="1.0", indicates the version number and is normally always 1.0.
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" version="1.0"> ... </xs:schema>
Root Element
The root element defines the first element of the XML document and defines a reference to the root complexType. The root complexType is the complexType from which all other complexTypes are related to in their ancestry, whether the root is the parent, grand parent, great grand parent, etc.
<xs:element name="root" type="root"/>
Since the root complexType may only exist once within an XML document, the root Domain's loopCount determines how many XML documents will be generated; thus, changing the loopCount to any positive number will determine the number of XML documents that will be generated. For example:
- If the Domain's loopCount = 1, then one XML document will be generated.
- If the Domain's loopCount = 100, then one hundred XML documents will be generated.
- If the Domain's loopCount = 10,000, then ten thousand XML documents will be generated.
All other child Domains will generate their appropriate amount of data, based on their own loopCounts and also based on the number of times they are iterated over by their parent Domain.
One to Many ComplexTypes
All complexTypes may contain the following structure.
- must contain a <xs:sequence> element, <xs:elements> are required
- may contain one or more <xs:elements> within the <xs:sequence> element
- may contain one or more <xs:attribute> elements
- the <xs:attribute> element must be placed below the </xs:sequence> element if the <xs:sequence></xs:sequence> elements exist.
<xs:complexType name="root"> <xs:sequence> <xs:element name="" type=""/> <xs:element name="" type=""/> <xs:element name="child" type="child"/> </xs:sequence> <xs:attribute name="" type=""/> <xs:attribute name="" type=""/> <xs:attribute name="" type=""/> </xs:complexType>
Nesting ComplexTypes within ComplexTypes
Elements may reference of the complexTypes from the element.type parameter, where the vale of the type is the name to another complexType.name parameter.
The value of the element.name parameter does not have to match the value of the element.type parameter.
<xs:complexType name="parent"> <xs:sequence> <xs:element name="child" type="child"/> </xs:sequence> </xs:complexType> <xs:complexType name="child"> <xs:sequence> <xs:element name="grandChild1" type="grandChild1"/> <xs:element name="grandChild2" type="grandChild2"/> </xs:sequence> </xs:complexType> <xs:complexType name="grandChild1"> <xs:sequence/> </xs:complexType> <xs:complexType name="grandChild2"> <xs:sequence/> </xs:complexType>