Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The XML Feature contains operators that allow the processing of XML documents.

Table of Contents

Operators

ToXML

This operator allows the transformation from a Tuple object into a XML document. The transformation requieres a XML schema definition (XSD) which describes the structure of the XML document and the mapping between that document and the Tuple object. However, there are different approaches to provide that schema information to the operator:


  • rootElement
  • rootAttribute
  • xsdFile
  • xsdString
  • xsdAttribute 
  • xPathAttributes

Firstly, the schema can be provided via file access (whereas the file can be located either locally or on a webserver).

Code Block
transform = TOXML({
                rootelement = 'user',
                xsdfile = '../schema.xsd'              
              },
              input
            )

Secondly, the schema information can be passed via string.

Code Block
transform = TOXML({
                rootelement = 'user',
                xsdstring = '<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
							  <xs:element name="user">
							    <xs:complexType>
							      <xs:sequence>
							        <xs:element type="xs:string" name="nickname"/>
							        <xs:element type="xs:string" name="fname"/>
							        <xs:element type="xs:string" name="lname"/>
							        <xs:element type="xs:string" name="email"/>
							        <xs:element type="xs:byte" name="age"/>
							        <xs:element name="roles">
							          <xs:complexType>
							            <xs:sequence>
							              <xs:element type="xs:string" name="role"/>
							            </xs:sequence>
							          </xs:complexType>
							        </xs:element>
							      </xs:sequence>
							    </xs:complexType>
							  </xs:element>
							</xs:schema>'             
              },
              input
            )

Thirdly, the schema information can be a payload on the current Tuple object which can be advantageous if the XSD has to change dynamically (xsdattribute = 'xsd'). Thus, it is possible to produces different documents within one data stream. Besides that, the root element of the document might change and therefore it is possible to define an attribute of the Tuple object that carries this information as well (rootattribute = 'root').

Code Block
transform = TOXML({
                rootattribute = 'root',
                xsdattribute = 'xsd'           
              },
              input
            ) 

Furthermore, the operator allows to use XPath expressions for an enriched mapping between attributes of the Tuple object and the XML document. The expressions can be applied as options or again as a payload on the Tuple object (xpathattributes = ['xpaths']). If xpathattributes is used, each defined Tuple attribute can contain several expressions whereas each expression is followed by an attribute name that has to match with an attribute of the Tuple object (e.g. [attributename][delimeter][expression]). These pairs are also separated by a delimiter (default is the , symbol).

Code Block
transform = TOXML({
                rootelement = 'user',
                xsdfile = '../schema.xsd',
                options = [
                  ['user_id', '/user/@id'],
                  ['role_1', '/user/roles/role[1]'],
                  ['role_2', '/user/roles/role[2]'],
                  ['role_3', '/user/roles/role[3]']
                ]                            
              },
              input
            )
Code Block
transform = TOXML({
                rootelement = 'user',
                xpathattributes = ['xpaths'],
                xsdfile = '../schema.xsd',
                options = [['delimeter', ';']]                                 
              },
			  input
            )
  • XMLEnrich

  • XMLMap

  • XMLSplit

  • XMLTransform

  • XMLToTuple