on 03-31-2007 5:07 PM
Hi,
I have an xml structure that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SectorsSETAs>
<SectorSETA>
<Sector_MDMId>1</Sector_MDMId>
<SETA_MDMId>1</SETA_MDMId>
</SectorSETA>
<SectorSETA>
<Sector_MDMId>5</Sector_MDMId>
<SETA_MDMId>2</SETA_MDMId>
</SectorSETA>
<SectorSETA>
<Sector_MDMId>6, 12, 15</Sector_MDMId>
<SETA_MDMId>23</SETA_MDMId>
</SectorSETA>
</SectorsSETAs>
The sending structure/message above is exactly the same as the receiving structure/message.
How do I map the Sending field 'Sector_MDMId' to its Receiving field with the same name, so that if there is more than one value listed (e.g. 6, 12, 15 as above), it retains the first 9 value (e.g. 6) as well as its corresponding SETA_MDMId field value (e.g. 23), and then inserts the next value (e.g. 12) - again along with the same corresponding SETA_MDMId field value 23 into the next node?
Essentially, there will be 2 columns - Sector_MDMId & SETA_MDMId - by the time I've converted this xml file into a flat file. And I need to list the SETA_MDMId with its corresponding Sector_MDMId, this is the reason I need to 'split' the values in the Sector_MDMId field, so that they all appear in the Sector_MDMId column against the right SETA_MDMId value.
Many thanks in advance!
Kind regards,
Reuben.
Hi Henrique,
Very very many thanks for your response and tips. I've just encountered the following error message whilst testing UDF 1 & 2 with my mappings:
Source code has syntax error: /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:91: illegal start of expression String output[] = a<i>.split(", "); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:103: illegal start of expression String output[] = a<i>.split(", "); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:105: illegal start of expression result.addValue(b<i>); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:105: ')' expected result.addValue(b<i>); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:110: illegal start of expression public static void main(String[] args) throws Exception{/!_$ClNRep_/_MM_SETA_Attributes_Asyn_ st = new /!_$ClNRep_/_MM_SETA_Attributes_Asyn_(); st.testExecute(); } ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:111: ';' expected } ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:112: '}' expected ^ 7 errors Source code has syntax error: /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:91: illegal start of expression String output[] = a<i>.split(", "); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:103: illegal start of expression String output[] = a<i>.split(", "); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:105: illegal start of expression result.addValue(b<i>); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:105: ')' expected result.addValue(b<i>); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:110: illegal start of expression public static void main(String[] args) throws Exception{/!_$ClNRep_/_MM_SETA_Attributes_Asyn_ st = new /!_$ClNRep_/_MM_SETA_Attributes_Asyn_(); st.testExecute(); } ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:111: ';' expected } ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map77868d00e02511dbb01e00e000a6f270/source/com/sap/xi/tf/_MM_SETA_Attributes_Asyn_.java:112: '}' expected ^ 7 errors
08:49:10 End of test
Any ideas what the problem is?
Kind regards,
Reuben.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try something like this:
Sector_MDMId - removeContext - UDF1 - Sector_MDMId
Sector_MDMId - removeContext - UDF2 - SETA_MDMId
SETA_MDMId - removeContext /
UDF1:
[code]...
for (int i=0; i < a.length; i++) {
String output[] = a<i>.split(", ");
for (int j = 0; j < output.length; j++) {
result.addValue(output[j]);
}
}
...[/code]
UDF2:
[code]...
for (int i=0; i < a.length; i++) {
String output[] = a<i>.split(", ");
for (int j = 0; j < output.length; j++) {
result.addValue(b<i>);
}
}
...[/code]
Though since you use a similar logic for both fields, making it as UDF is not the smartest (because you'll execute the same logic at least twice). You could also try out a XSLT with something like:
[code]...
<xsl:template match="/SectorsSETAs">
<SectorsSETAs>
<xsl:for-each select="SectorSETA">
<xsl:variable name="sectors" select="fn:tokenize(string(Sector_MDMId), ',\s+')"/>
<xsl:variable name="seta" select="SETA_MDMId"/>
<xsl:for-each select="$sectors">
<SectorSETA>
<Sector_MDMId>
<xsl:value-of select="."/>
</Sector_MDMId>
<SETA_MDMId>
<xsl:value-of select="$seta"/>
</SETA_MDMId>
</SectorSETA>
</xsl:for-each>
</xsl:for-each>
</SectorsSETAs>
</xsl:template>
...[/code]
Regards,
Henrique.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.