Hi, all. Tahnk you to those who reply to my question that was:
I want to process a list of nodes that can appear at several different
points of the structure, and I ant to process them in a particular order.
This is easy to specify:
for-each select="//node-name"
sort select="criteria"
The problem is that I want to supress the node's processing if it is equal
to the one that precedes it in that order. How can I have access to the
last
processed node while processing the current one?
TIA
jcr
I just found a nice solution in Bob DuCharme's column at O'Reilly:
you just need to put the following test:
<xsl:if test="not(.=preceding::node-name)"> ...
This way you can guarantee that if you have already processed a node with
the same content of current one you skip this one.
This helped me to solve an interesting problem: I had a Bibliography XML
file regarding to a DocBook application. Each BIBLIOENTRY has a list of
authors and I wanted to transform that structure into another that for each
AUTHOR lists his entries. This is a structure inversion problem is not
trivial in a normal programming language. Spite all the tags the XSL
solution is quite nice:
<xsl:template match="/">
<UL>
<xsl:for-each select="//AUTHOR">
<xsl:sort select="SURNAME" order="ascending"/>
<xsl:if test="not(./SURNAME=preceding::SURNAME)">
<xsl:call-template name="getEntries">
<xsl:with-param name="snome" select="SURNAME"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</UL>
</xsl:template>
Let´s come up with some new tags...
jcr
----------------------------------------------------------------------------
---
José Carlos Ramalho orienteer
Dep. Informática - U.Minho windsurfer
http://www.di.uminho.pt/~jcr engineer
+351 253 604479
----------------------------------------------------------------------------
-----
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list