Table of Contents

Search

  1. Preface
  2. XML Concepts
  3. Using XML with PowerCenter
  4. Working with XML Sources
  5. Using the XML Editor
  6. Working with XML Targets
  7. XML Source Qualifier Transformation
  8. Midstream XML Transformations
  9. Appendix A: XML Datatype Reference
  10. Appendix B: XPath Query Functions Reference

XML Guide

XML Guide

Element and Attribute Groups

Element and Attribute Groups

You can put elements and attributes in groups that you can reference in a schema. You must declare the group of elements or attributes before you reference the group.
The following example shows the schema syntax for an element group:
<xs:group name="Songs">       <xs:element name="songTitle" type="xs:string" />       <xs:element name="artist" type="xs:string" />       <xs:element name="publisher" type="xs:string" />   </xs:group>
The following example shows the schema syntax for an attribute group:
<xs:attributeGroup name="Songs">    <xs:attribute name="songTitle" type="xs:string" />    <xs:attribute name="artist" type="xs:string" />    <xs:attribute name="publisher" type="xs:string" /> </xs:attributeGroup>
The following element groups provide constraints on XML data:
  • Sequence group.
    All elements in an XML file must occur in the order that the schema lists them. For example, OrderHeader requires the customerName first, then orderNumber, and then orderDate:
    <xs:group name="OrderHeader">    <xs:sequence>       <xs:element name="customerName" type="xs:string" />       <xs:element name="orderNumber" type="xs:number" />       <xs:element name="orderDate" type="xs:date" />    </xs:sequence> </xs:group>
  • Choice group
    . One element in the group can occur in an XML file. For example, the CustomerInfo group lists a choice of elements for the XML file:
    <xs:group name="CustomerInfo">    <xs:choice>       <xs:element name="customerName" type="xs:string" />       <xs:element name="customerID" type="xs:number" />       <xs:element name="customerNumber" type="xs:integer" />    </xs:choice> </xs:group>
  • All group.
    All elements must occur in the XML file or none at all. The elements can occur in any order. For example, CustomerInfo requires all or none of the three elements:
    <xs:group name="CustomerInfo">    <xs:all>       <xs:element name="customerName" type="xs:string" />       <xs:element name="customerAddress" type="xs:string" />       <xs:element name="customerPhone" type="xs:string" />    </xs:all> </xs:group>

0 COMMENTS

We’d like to hear from you!