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

XML Files

XML Files

XML files contain tags that identify data in the XML file, but not the format of the data. The basic component of an XML file is an element. An XML element includes an element start tag, element content, and element end tag. All XML files must have a root element defined by a single tag at the top and bottom of the file. The root element encloses all the other elements in the file.
An XML file models a hierarchical database. The position of an element in an XML hierarchy represents its relationships to other elements. An element can contain child elements, and elements can inherit characteristics from other elements.
For example, the following XML file describes a book:
<book> <title>Fun with XML</title> <chapter> <heading>Understanding XML</heading> <heading>Using XML</heading> </chapter> <chapter>   <heading>Using DTD Files</heading> <heading>Fun with Schemas</heading> </chapter> </book>
Book is the root element and it contains the title and chapter elements. Book is the parent element of title and chapter, and chapter is the parent of heading. Title and chapter are sibling elements because they have the same parent.
An element can have attributes that provide additional information about the element. In the following example, the attribute graphic_type describes the content of picture:
<picture
graphic_type="gif"
>computer.gif</picture>
The following figure shows the structure, elements, and attributes in an XML file:
The XML file includes the root element, element data, enclosure element, element tags, attribute value, and attribute tag.
  1. Root element.
  2. Element data.
  3. Enclosure element.
  4. Element tags.
  5. Element data.
  6. Attribute value.
  7. Attribute tag.
An XML file has a hierarchical structure. An XML hierarchy includes the following elements:
  • Child element.
    An element contained within another element.
  • Enclosure element.
    An element that contains other elements but does not contain data. An enclosure element can include other enclosure elements.
  • Global element.
    An element that is a direct child of the root element. You can reference global elements throughout an XML schema.
  • Leaf element.
    An element that does not contain other elements. A leaf element is the lowest level element in the XML hierarchy.
  • Local element.
    An element that is nested in another element. You can reference local elements only within the context of the parent element.
  • Multiple-occurring element.
    An element that occurs more than once within its parent element. Enclosure elements can be multiple-occurring elements.
  • Parent chain.
    The succession of child-parent elements that traces the path from an element to the root.
  • Parent element.
    An element that contains other elements.
  • Single-occurring element.
    An element that occurs once within its parent.
The following figure shows some elements in an XML hierarchy:
 An XML hierarchy can include the code page, encoding attribute identifer, and the DOCTYPE identifying an associated DTD file. It can also include the enclosure, leaf, multiple-occurring, single-occurring, child, and parent elements.
  1. The encoding attribute identifies the code page.
  2. The DOCTYPE identifies an associated DTD file.
  3. Enclosure Element: Element Address encloses elements StreetAddress, City, State, and Zip. Element Address is also a Parent element.
  4. Leaf Element: Element Zip, along with all its sibling elements, is the lowest level element within element Address.
  5. Multiple-occurring Element: Element Sales Region occurs more than once within element Product.
  6. Single-occurring Element: Element PName occurs once within element Product.
  7. Child Element: Element PName is a child of Product, which is a child of Store.

0 COMMENTS

We’d like to hear from you!