This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
selecting nodes - syntax?
- To: "Xsl-List" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] selecting nodes - syntax?
- From: "Denis Kranjcec" <denis dot kranjcec at fer dot hr>
- Date: Mon, 15 Oct 2001 10:55:51 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hello everyone.
I have problem with syntax when I want to select nodes.
Here is example XML:
<main>
<list>
<a code="1" priority="10" .../>
<a code="2" priority="7" .../>
<a code="3" priority="8" .../>
<a code="4" priority="3" .../>
<a code="5" priority="5" .../>
</list>
<elem>
<b>
...
<a code="1"/>
<a code="3"/>
...
</b>
<b>
...
<a code="4"/>
<a code="5"/>
<a code="3"/>
...
<!-- hundreds of elements <b> -->
</b>
...
</elem>
</main>
Every element <a> have lots of attributes (XSL-FO properties). There is cca.
20 different elements <a>.
Element <b> could have several elements <a>. Because of hundreds of elements
<b> I don't want that there is copy of <a> in every <b>. I would like to
have only attribute @code in element <a> that is same as @code in <a> with
all properties.
I want to select, for every <b> element, element <a> with lowest priority.
I tried with something like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="main/elem/b"/>
</xsl:template>
<xsl:template match="b">
<xsl:variable name="selected">
<xsl:for-each select="/main/a[@code = ./a/@code]"> <!-- I guess that
problem is that node . isn't <b> -->
<xsl:sort data-type="number" select="@priority" order="ascending"/>
<!-- debug --> debug[<xsl:value-of select="."></xsl:value-of>]
<xsl:if test="position()=1">
<xsl:value-of select="./@code"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
selected[<xsl:value-of select="$selected"/>]
</xsl:template>
</xsl:stylesheet>
I don't know syntax to select element <a> with all properties.
What is correct syntax?
Any help is appreciated.
Thanks in advance,
Denis
P.S.
Sorry for my lousy english :-)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list