|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Avoid repitition of XML data at different nodes??
Subject: Re: Avoid repitition of XML data at different nodes??
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Wed, 16 Oct 2002 21:33:38 +0200
|
It's a simple grouping problem:
Muenchian Grouping: http://www.jenitennison.com/xslt/grouping/muenchian.xml
<xsl:key name="params" match="Parameter" use="Name"/>
<xsl:for-each select="Class/Parameter">
<xsl:choose>
<xsl:when test="generate-id() = generate-id(key('params', Name))">
Absent: <xsl:value-of select="Name"/>!
</xsl:when>
<xsl:otherwise>
Present!
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
contains() and concat() are string functions and can't be used to
compare different nodes. Furthermore it looks like you want to reassign
the variable $total. That's not possible in XSLT.
Instead of Muenchian Grouping you can use the preceding axis.
Regards,
Joerg
Raghava Rao wrote:
Hello,
Any help is appreciated...
Please find enclosed the xsl file which looks up the given input XML
file to produce the html output file. I want to know how to avoid
repitition of Parameter P1 in my output html file. I'm not sure how to
use the "concat" and "contains" functions and couldn't find help on the
web regarding the same.. I'm using Saxon6_5_2, if that helps! I would
appreciate if you can throw some light!
Thank you.
Raghava
Input XML file:
--------------------
<Parent>
<Class>
<Parameter Name="P1" Type="str" />
<Parameter Name="P2" Type="int" />
</Class>
<Class>
<Parameter Name="P3" Type="long" />
<Parameter Name="P1" Type="str" />
</Class>
</Parent>
XSL file:
------------
<xsl:variable name="total" > </xsl:variable>
Parameters are: <br/>
<xsl:for-each select="Parent">
<xsl:for-each select="Class/Parameter">
<xsl:variable name="pNam" select="@Name" />
<xsl:choose>
<xsl:when test="contains($total,$pNam)" >
Present!
</xsl:when>
<xsl:otherwise>
Absent:
<xsl:value-of name="$total" select="concat($total, '_', $pNam,
'_')" /> <br/>
<xsl:value-of select="@Name" /> <br/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
Output html file:
-------------------
Parameters are:
Absent: P1
Absent: P2
Absent: P3
Present!
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|