[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl != not working?

Subject: Re: xsl != not working?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 22 Jun 2005 06:33:16 +1000
link to top xsl
> //h2[1]/text() != text()

I think this is a FAQ about the "//" abbreviation.

What you probably need is:

(//h2)[1]/text() != text()

But checking for node identity using the content of the node may
generally be unreliable.

I'd recommend:

     generate-id() != generate-id((//h2)[1])

Even this may cause HUGE inefficiency, therefore it is better to
evaluate (//h2)[1] once and define an xsl:variable having this value:

     <xsl:variable name="h2ID" select="generate-id((//h2)[1] )"/>


then at the place, where the test is necessary, have:

     generate-id() != $h2ID


Cheers,
Dimitre Novatchev





On 6/22/05, Joe Stump <joe@xxxxxxxxxxxx> wrote:
> I've got a bunch of h2's in a document that I want to group at the
> top with jumps to the actual h2's in the body, which I have working
> without incident. The problem I have is with links back to the top.
> Basically, if it's NOT the first h2, it should show a "Back to Top"
> link above the h2. I have a test that appears to be exactly what I
> need, but it's not working. The basic test is:
>
> //h2[1]/text() != text()
>
> Below is the full XSLT (it's in a template matching h2's).
>
>     <xsl:if test="//h2[1]/text() != text()">
>           <xsl:text>"</xsl:text>
>           <xsl:value-of select="//h2[1]/text()"/>
>           <xsl:text>"</xsl:text>
>           <xsl:text> != </xsl:text>
>           <xsl:text>"</xsl:text>
>           <xsl:value-of select="text()"/>
>           <xsl:text>"</xsl:text>
>
>       <xsl:element name="div">
>           <xsl:attribute name="class">article-top</xsl:attribute>
>           <xsl:element name="a">
>             <xsl:attribute name="class">article-top</xsl:attribute>
>             <xsl:attribute name="href">#top</xsl:attribute>
>             <xsl:text>Back to Top</xsl:text>
>           </xsl:element>
>       </xsl:element>
>     </xsl:if>
>
> Here's my output for my first h2 (which should NOT have a link to top
> above it):
>
> "Definition" != "Definition"
> Back to Top
>
> Quite annoying ... any ideas? How can 'Definition' not equal
> 'Definition'?
>
> --Joe

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.