Hi,
Give us a sample input instance and expected output..We will try..
Hi John-305 ,Its not the same output message. i have provided a sample. the last 3 fields will be constant values that are different for both records.
Hi Ashwin, the following are the sample input and expected output files:
INPUT:
- <RAL_RECORD xmlns="">
<RECORD_TYPE>Part</RECORD_TYPE>
<Filialnum>12345</Filialnum>
<Date>20150225</Date>
<Code>P</Code>
<uniqID>110</uniqID>
<NetValue>455.56</NetValue>
<Volume>1</Volume>
</RAL_RECORD>
OUTPUT:
<Sample> ---- recrd 1
<A>Part</A>
<B>12345</B>
<C>20150225</C>
<D>Unique ID from DB</D>
<E>Constant value "xyz"</E>
<F>Constant value "abc"</F>
</Sample>
<Sample> ---- record 2
<A>Part</A>
<B>12345</B>
<C>20150225</C>
<D>Unique ID from DB</D>
<E>Constant value "asd"</E>
<F>Constant value "qwe"</F>
</Sample>
Input and out ar both repeating records.
Fields <A><B><C> are direct mapping.
The field <D>, that is the unique id generated from DB is to be same in the 2nd occurance of the record.
For the following input XML:
<Root xmlns="soucenamespace"> <RAL_RECORD xmlns=""> <RECORD_TYPE>Part</RECORD_TYPE> <Filialnum>12345</Filialnum> <Date>20150225</Date> <Code>P</Code> <uniqID>110</uniqID> <NetValue>455.56</NetValue> <Volume>1</Volume> </RAL_RECORD> <RAL_RECORD xmlns=""> <RECORD_TYPE>OtherPart</RECORD_TYPE> <Filialnum>12346</Filialnum> <Date>20150226</Date> <Code>P</Code> <uniqID>110</uniqID> <NetValue>455.56</NetValue> <Volume>1</Volume> </RAL_RECORD> </Root>
You can use the following custom XSLT (you will have to do the "Unique ID from DB" logic yourself, since I have no way of knowing how this is done today)
<?xml version="1.0" encoding="utf-16"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:source="soucenamespace" exclude-result-prefixes="source"> <xsl:template match="source:Root"> <Output> <xsl:for-each select="RAL_RECORD"> <xsl:variable name="UniqueID" select="'hardcoded'" /> <!--Change to "fetch from DB logic" --> <Sample> <A> <xsl:value-of select="RECORD_TYPE" /> </A> <B> <xsl:value-of select="Filialnum" /> </B> <C> <xsl:value-of select="Date" /> </C> <D> <xsl:value-of select="$UniqueID" /> </D> <E> <xsl:text>xyz</xsl:text> </E> <F> <xsl:text>abc</xsl:text> </F> </Sample> <Sample> <A> <xsl:value-of select="RECORD_TYPE" /> </A> <B> <xsl:value-of select="Filialnum" /> </B> <C> <xsl:value-of select="Date" /> </C> <D> <xsl:value-of select="$UniqueID" /> </D> <E> <xsl:text>asd</xsl:text> </E> <F> <xsl:text>qwe</xsl:text> </F> </Sample> </xsl:for-each> </Output> </xsl:template> </xsl:stylesheet>
Morten la Cour
This is where Table-Extractor and Table-Looping Functiod comes into play.
Do the following:
- Drag a Table-Looping Functiod
- In Table-Looping Functiod, specify 2 a constant (which defines the scope for you number of repeating records you want).
- In Table-Looping Functiod, specifiy 6 a constant (which defines the number of output fields, in your case you have six fields)
- Link RECORD_TYPE from source schema to Table-Looping Functiod as 3<sup>rd</sup> parameter.
- Link Filialnum from source schema to Table-Looping Functiod as 4<sup>rd</sup> parameter.
- Link Date from source schema to Table-Looping Functiod as 5<sup>rd</sup> parameter.
- Now link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayOne. This will be the 6<sup>th</sup> parameter for Table-Looping Functiod.
- Again link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayTwo. This will be the 7<sup>th</sup> parameter for Table-Looping Functiod.
- Hard code xyz as 8th parameter
- Hard code abc as 9th parameter
- Hard code asd as 10th parameter
- Hard code qwe as 11th parameter
- Now right-click the Table-Looping Functiod and select Configure Table Looping Grid and configure the grid as show above.
- Drag a Table Extractor fuctiod for each output. And link Table-Looping Functiod as its first parameter and specify the column names which you want to output..like 1 or 2 or 3 or 4 or 5 or 6
So for the given input:
<RAL_RECORD xmlns=""> <RECORD_TYPE>Part</RECORD_TYPE> <Filialnum>12345</Filialnum> <Date>20150225</Date> <Code>P</Code> <uniqID>110</uniqID> <NetValue>455.56</NetValue> <Volume>1</Volume> </RAL_RECORD>
<OutputInstance> <Sample> <A>Part</A> <B>12345</B> <C>20150225</C> <D>Unique ID from DB-LetsSayOne</D> <E>xyz</E> <F>abc</F> </Sample> <Sample> <A>Part</A> <B>12345</B> <C>20150225</C> <D>Unique ID from DB-LetsSayTwo</D> <E>asd</E> <F>qwe</F> </Sample> </OutputInstance>
Regards,
M.R.ashwin Prabhu
This is where Table-Extractor and Table-Looping Functiod comes into play.
Do the following:
- Drag a Table-Looping Functiod
- In Table-Looping Functiod, specify 2 a constant (which defines the scope for you number of repeating records you want).
- In Table-Looping Functiod, specifiy 6 a constant (which defines the number of output fields, in your case you have six fields)
- Link RECORD_TYPE from source schema to Table-Looping Functiod as 3<sup>rd</sup> parameter.
- Link Filialnum from source schema to Table-Looping Functiod as 4<sup>rd</sup> parameter.
- Link Date from source schema to Table-Looping Functiod as 5<sup>rd</sup> parameter.
- Now link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayOne. This will be the 6<sup>th</sup> parameter for Table-Looping Functiod.
- Again link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayTwo. This will be the 7<sup>th</sup> parameter for Table-Looping Functiod.
- Hard code xyz as 8th parameter
- Hard code abc as 9th parameter
- Hard code asd as 10th parameter
- Hard code qwe as 11th parameter
- Now right-click the Table-Looping Functiod and select Configure Table Looping Grid and configure the grid as show above.
- Drag a Table Extractor fuctiod for each output. And link Table-Looping Functiod as its first parameter and specify the column names which you want to output..like 1 or 2 or 3 or 4 or 5 or 6
So for the given input:
<RAL_RECORD xmlns=""> <RECORD_TYPE>Part</RECORD_TYPE> <Filialnum>12345</Filialnum> <Date>20150225</Date> <Code>P</Code> <uniqID>110</uniqID> <NetValue>455.56</NetValue> <Volume>1</Volume> </RAL_RECORD>
Output as follows:
<OutputInstance> <Sample> <A>Part</A> <B>12345</B> <C>20150225</C> <D>Unique ID from DB-LetsSayOne</D> <E>xyz</E> <F>abc</F> </Sample> <Sample> <A>Part</A> <B>12345</B> <C>20150225</C> <D>Unique ID from DB-LetsSayTwo</D> <E>asd</E> <F>qwe</F> </Sample> </OutputInstance>
Regards,
M.R.ashwin Prabhu