xsl-list
[Top] [All Lists]

[xsl] Suppressing multiple outcome

2006-11-23 07:17:36
Hello,

I am facing the following problem


I have an invoice:

<?xml version="1.0"?>
<INVOICE>
<ORDERHEADER>
</ORDERHEADER>
<ORDERPOSITIONS>
<ITEM>
        <MATNR>123</MATNR>
        <DETAIL>
                <PARVW>WE</PARVW> 
                <STREET>oxford street</STREET> 
        </DETAIL>
        <DETAIL>
                <PARVW>Z5</PARVW> 
                <STREET>another street</STREET> 
        </DETAIL>
</ITEM>
<ITEM>
        <MATNR>456</MATNR>
        <DETAIL>
                <PARVW>WE</PARVW> 
                <STREET>oxford street</STREET> 
        </DETAIL>
        <DETAIL>
                <PARVW>Z5</PARVW> 
                <STREET>another street</STREET> 
        </DETAIL>
</ITEM>
</ORDERPOSITIONS>
</INVOICE>


-> The invoice has 2 positions <ITEM>. Each position has a <DETAIL>-Tag, which 
has the same contents FOR ALL items.
What i would like to do is to get the content of Tag <STREET>, if the 
<PARVW>-Tag contains "WE" -> in this case this ist the value "oxford street".

in the destinaion xml, "oxford street" sould be in the header segment.
The destination XML should look like:

<?xml version="1.0"?>
<INVOICE>
<ORDERHEADER>
<STREET>oxford street</STREET>
</ORDERHEADER>
<ORDERPOSITIONS>
<ITEM>
        <MATNR>123</MATNR>
</ITEM>
<ITEM>
        <MATNR>456</MATNR>
</ITEM>
</ORDERPOSITIONS>
</INVOICE>


I habe generated the following code with Altova MapForce:

<ORDERHEADER>
<xsl:for-each select="ITEM/DETAIL">
                <xsl:variable name="myVar" select="."/>
                <xsl:for-each select="$myVar/PARVW">
                        <xsl:variable name="myVar3" select="$myVar/PARVW = 
'WE'"/>
                        <xsl:if test="string($myVar3)='true'">
                                <STREET>
                                        <xsl:value-of select="$myVar/STREET"/>
                                </STREET>
                        </xsl:if>                               
                </xsl:for-each>
</xsl:for-each>         
</ORDERHEADER>

Unfortunately the outcome is the following (I get the Tag <STREET> twice, 
whereas I would like to get it only ONCE):
<ORDERHEADER>
        <STREET>oxford street</STREET>
        <STREET>oxford street</STREET>
</ORDERHEADER>

Does anybody know, what I can do so that the destination.xml contains ONLY ONE 
<STREET>-tag?
I hope I did make my problem clear.

Thanks in advance,
Andreas

-- 
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>