Customer Portal

XMLExtract:Reading elements and attributes with same name

Comments 1

  • Avatar
    twaller
    0
    Comment actions Permalink
    Hello,

    Mapping will look like this:


    <Mappings>
    <Mapping element="oa:ItemID">
    <Mapping element="oa:ID" outPort="0" xmlFields="oa:ID" cloverFields="oaID" sequenceField="count" sequenceID="Sequence0" />
    </Mapping>
    <Mapping element="oa:ManufacturerItemID">
    <Mapping element="oa:ID" outPort="1" xmlFields="oa:ID" cloverFields="oaID" sequenceField="count" sequenceID="Sequence0" />
    </Mapping>
    <Mapping element="us:Codes">
    <Mapping element="oa:Code" outPort="2" sequenceField="count" sequenceID="Sequence0" />
    </Mapping>
    <Mapping element="oa:Property">
    <Mapping element="oa:NameValue" outPort="3" sequenceField="count" sequenceID="Sequence0" />
    </Mapping>
    </Mappings>


    XMLExtract will have four output ports.
    The ports 0 and 1 will have the following metadata:


    <Metadata id="Metadata0" previewAttachmentCharset="ISO-8859-1">
    <Record fieldDelimiter="|" name="recordName1" previewAttachmentCharset="ISO-8859-1" recordDelimiter="\r\n" type="delimited">
    <Field name="count" type="integer"/>
    <Field name="oaID" type="string"/>
    </Record>
    </Metadata>


    The ports 2 and 3 will have them as follows:


    <Metadata id="Metadata2">
    <Record fieldDelimiter="|" name="recordName3" recordDelimiter="\r\n" type="delimited">
    <Field name="count" type="integer"/>
    <Field name="name" type="string"/>
    </Record>
    </Metadata>


    These four edges will be joined using ExtMergeJoin where the "count" fields are used as Join key.

    The transformation will be:


    function transform() {
    $0.field1 := $0.oaID;
    $0.field2 := $1.oaID;
    $0.field3 := $2.name;
    $0.field4 := $3.name;
    }


    The output edge of ExtMergeJoin have the following metadata:


    <Metadata id="Metadata1" previewAttachmentCharset="ISO-8859-1">
    <Record fieldDelimiter="|" name="recordName2" previewAttachmentCharset="ISO-8859-1" recordDelimiter="\r\n" type="delimited">
    <Field name="field1" type="string"/>
    <Field name="field2" type="string"/>
    <Field name="field3" type="string"/>
    <Field name="field4" type="string"/>
    </Record>
    </Metadata>


    The graph contains a sequence which serves to fill the "count" fields. Its ID is "Sequence0".

    Note that mapping elements like this:


    <Mapping element="oa:ItemID">
    ...
    </Mapping>


    serve to specify the parent whose child element is sent out.

    Best regards,

    Tomas Waller

Please sign in to leave a comment.