xsl-list
[Top] [All Lists]

Re: following-sibling question

2002-12-04 15:41:00
Hello Mani,

the important elements don't have the same parent element, so you can't use following-sibling axis.

Either you change it to following axis:

<xsl:for-each select="document/filtered-text/important
              [not(.=following::important[1])]">
  <xsl:value-of select="."/>
</xsl:for-each>

or you must walk up the tree a bit:

<xsl:for-each select="document/filtered-text/important
[not(.=../../following-sibling::document/filtered-text/important[1])]">
  <xsl:value-of select="."/>
</xsl:for-each>

or if there is only one important element as descendant of document:

<xsl:for-each select="document[not(filtered-text/important = following-sibling::document[1]/filtered-text/important)]/filtered-text/important">

Regards,

Joerg

Mani Malarvannan wrote:
Hi,
I've following XSL and XML, when I apply the XSL to the XML I'm getting the following output

Test 1Test 1Test 2

but I need the output to be Test 1Test 2

It shoud remove the same values that comes within the <important> tag while printing it.

<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>



<xsl:output
    method="html"
    doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"
    encoding="iso-8859-1"
    indent="no" />


XSL-file
<xsl:template match="document-list" >
<xsl:for-each select="document/filtered-text/important[not(. = following-sibling::important[1])]">

   <xsl:value-of select="."/>
  </xsl:for-each>

</xsl:template>


XML-file
<document-list>
<document>
<filtered-text>
<important>Test 1</important>
</filtered-text>
<word>
<p>
<WORD>word 1</WORD>
</p>
</word>
</document>
<document>
<filtered-text>
<important>Test 1</important>
</filtered-text>
<word>
<p>
<WORD>word 11</WORD>
</p>
</word>
</document>
<document>
<filtered-text>
<important>Test 2</important>
</filtered-text>
<word>
<p>
<WORD>word 11</WORD>
</p>
</word>
</document>
</document-list>
</xsl:stylesheet>

Thanks for the help

-Mani


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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