|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Mapping node : Fill output tag with parent occurence |
« View previous topic :: View next topic » |
Author |
Message
|
mk140589 |
Posted: Thu Jan 23, 2014 3:55 am Post subject: Mapping node : Fill output tag with parent occurence |
|
|
Novice
Joined: 17 Jun 2013 Posts: 20
|
Hi guys,
We have made a mapping from a DFDL format to an XML format.
The input-group, which is referenced in the complete schema, is described as :
Code: |
<xsd:group name="REC08">
<xsd:sequence>
<xsd:element default=" " dfdl:length="4" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="aaa" name="H0410" type="stringfield_V_0_9"/>
<xsd:element default=" " dfdl:length="1" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="aaa" name="H0420" type="stringfield_V_0_9"/>
<xsd:element default=" " dfdl:length="12" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="aaa" name="H0430" type="stringfield_V_0_9"/>
<xsd:element default=" " dfdl:length="44" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="aaa" name="H0440" type="stringfield_V_0_9"/>
<xsd:element default=" " dfdl:length="1" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="aaa" name="H0450" type="stringfield_V_0_9"/>
</xsd:sequence> |
This group can be repeated multiple times (unbounded).
The output part is :
Code: |
<xs:element name="Routing" minOccurs="0">
<xs:annotation>
<xs:documentation>Has to be present for transports using CIM. For national (transports without border crossing) this element can be omitted.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="RouteSection" maxOccurs="30">
<xs:complexType>
<xs:sequence>
<xs:element name="RouteCode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5">
</xs:length>
<xs:pattern value="\d*[1-9]\d*0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="RouteText" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="80"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="SequenceID" use="required">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="30"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
|
Based on a certain condition of the input-element, I need to create an output element.
This means that if I have f.e. 5 input-REC08's, that I will only have 2 output-RouteSections.
Everything is filled correctly, except the SequenceID-attribute.
This should start at 1 and be raised for every occurence of RouteSection that is created.
Is there any out-of-the box solution to do this?
If not, can we include this in an ESQL-function that we call from the mapping? If yes, how?
At the moment, we've put a small Compute Node after the mapping to achieve this, but we would like to get it in the mapping.
If anything is unclear, please ask me.
Thanks in advance,
Best regards,
Maarten |
|
Back to top |
|
 |
martinb |
Posted: Thu Jan 23, 2014 8:16 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
There are a couple of things here that you might be able to make use of.
- ForEach "index" variable. The ForEach Transform provides a variable that is named "<primaryinput>-index", this is available for use in the Filter condition, or in any expression in the nested mappings.
So within the nested ForEach you could use a transform that takes the value from "<primaryinput>-index" and places it in "SequenceID", eg a "Custom-Xpath" with only a output wire.
Note that this index applies to the full set of inputs, so if you are using a Filter condition on a ForEach it could have values 1, 3, 4 if the filter excluded the second occurrence in the input
(Note in older v8 releases content assist for this ForEach index variable is only offered within the ForEach filter properties)
- The Append transform allows for adding occurrences to an output repeatable element in a defined order. Assuming you only have a small number of inputs to move to the output you can connect that number of input wires from the repeatable input to a transform targeting the output, then change Transform type from "Join" to "Append". You can now create a nested local transform using a LocalMap to build each instance, and given the Append transform defines the order, you can Assign the relevant value to "SequenceID" in each nested LocalMap
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|