1

Below is my source schema

<ns0:xyz xmlns:ns0="http://abc/xyz">
    <main>
        <zzz/></zzz>
        <yyy/></yyy>
    </main>
    <Lines>
        <Line>
            <LineNum></LineNum>
            <Linerate></Linerate>
        </Line>
    </Lines>

and Below is my input file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xyz xmlns="http://abc/xyz">
    <main>
        <zzz>12</zzz>
        <yyy>11</yyy>
    </main>
    <Lines>
        <Line>
            <LineNum>1</LineNum>
            <Linerate>0.5</Linerate>
        </Line>
        <LineNum>3</LineNum>
        <Linerate>0.2</Linerate>
    </Line>
    <Line>
        <LineNum>5</LineNum>
        <Linerate>0.5</Linerate>
    </Line>
</Lines>

I need to compare the line records and check if the Linerate element has similar value , then irrespective of the number of records in the source file , my destination file should have only 1 record with that particular Line rate value.

And for every distinct Linerate value , there should be respective record for it.

The Linerate value should be assigned to percent node in the destination

The Cumulative sum value of the LineNum value should be assigned to Amount in destination(if Linerate value is same across the records in the source)

Linerate * cumulative sum of LineNum should be assinged to AdditionalAmount in destination

Below is the expected output file

<LineSummary> 
    <Percent>0.5</Percent> 
    <Amount>6</Amount> 
    <AdditionalAmount>3</AdditionalAmount> 
</LineSummary>      
<LineSummary> 
    <Percent>0.2</Percent> 
    <Amount>3</Amount> 
    <AdditionalAmount>0.6</AdditionalAmount> 
</LineSummary>

Below is the XSLT code used in my BizTalk Map.

 <xsl:variable name="unique-LineRate" select="//Lines/Line[not(Linerate=preceding-sibling::Line/Linerate)]/Linerate" />
<xsl:for-each select="$unique-LineRate"> 
  <LineSummary> 
     <xsl:variable name="LineSum" select="sum(//Lines/Line[Linerate=current()]/LineNum)" />
    <Percent><xsl:value-of select="current()"/></Percent> 
    <Amount><xsl:value-of select="$LineSum" /></Amount> 
    <AdditionalAmount><xsl:value-of select="current() * $LineSum"/></AdditionalAmount> 
    </LineSummary>      
    </xsl:for-each>

If my source schema "ElementFormDefault" value is kept as unqualified or default, the I get an error as : Input validation error: The element 'xyz' in namespace 'http://abc/xyz' has invalid child element 'main' in namespace 'http://abc/xyz'. List of possible elements expected: 'main'.

If my source schema "ElementFormDefault" is kept as Qualified,then the XSLT doesn't work. I am sure it has to do something with the namespace issue or element tagging But i am not sure exactly where i need to make the change.

Do I need to prefix with the XPath or the namespace to all the elements in the XSLT?

shrys
  • 5,860
  • 2
  • 21
  • 36
  • Before anyone can answer this, you need to ask the trading partner if they have a Schema for this message. This is VERY important. It makes a BIG difference. – Johns-305 Jul 05 '16 at 12:26
  • I finally got the solution for this ....I had the elementformdefault value as qualified ...and validated my map...then I carefully observed the xsl file of it... I could see the nodes were prefixed with S0 ...so I prefixed my nodes with S0 in my XSLT code and it worked :) – user6546702 Jul 05 '16 at 13:23
  • Ok, but you really can't just change that without knowing how the source is interpreting it. As I said at MSDN, unless you get an answer from the source, you're just guessing. – Johns-305 Jul 05 '16 at 13:37

0 Answers0