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

RE: following-sibling problem

Subject: RE: following-sibling problem
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Thu, 7 Jun 2007 12:33:36 +0530
RE:  following-sibling problem
The problem is in 
<xsl:when  test="following-sibling::ReferenceReasonText[1]">
This is equivalent to testing if there is a  ReferenceReasonText after the
current node.
What you need is to test if the next immediate node is a ReferenceReasonText
So you need 
following-sibling::*[1][self::ReferenceReasonText]

-----Original Message-----
From: Andy Carr1 [mailto:CARRA@xxxxxxxxxx] 
Sent: Wednesday, June 06, 2007 5:44 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  following-sibling problem

I have some source xml that looks like this:

<References>
        <Reference>Something</Reference>
        <Reference>Something Else</Reference>
        <ReferenceReasonText>Reason for Something 
Else</ReferenceReasonText>
        <Reference>Another reference</Reference>
<References>

I'm applying a template match on References

<xsl:apply-templates select="References" />

and

<xsl:template match="References/Reference">

        <!-- I've set up a test variable to determine if the 
following-sibling is a <ReferenceReasonText> -->
        <xsl:variable name="test">
                <xsl:choose>
                        <xsl:when 
test="following-sibling::ReferenceReasonText[1]">
                                <xsl:text>True</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                                <xsl:text>False</xsl:text>
                        </xsl:otherwise>
                </xsl:choose>
        </xsl:variable>

</xsl:template>

The value of the test variable returns the following after transformation:

<References>
        <Reference>Something</Reference>        VARIABLE = TRUE
        <Reference>Something Else</Reference> VARIABLE = TRUE
        <ReferenceReasonText>Reason for Something 
Else</ReferenceReasonText>
        <Reference>Another reference</Reference>        VARIABLE = FALSE
<References>

For the first instance of Reference I would expect the variable to be 
False, what am I doing wrong ... anyone?

I've used following-sibling::xxxxx[1] before and got the results I 
expected. The only difference that I can see is that this XSLT (v2.0) is 
wrapped up in some FO using XEP 4.3 to produce PDF.


Regards
Andy

Andy Carr
Senior IT Specialist
Tel: Internal - 298037 External - 01252 558037
Mail Point  M1C IBM Application Services
Meudon House, Meudon Avenue, Farnborough, GU14 7NB
(Notes) Andy Carr1/UK/IBM@IBMGB 
(Internet)CARRA@xxxxxxxxxx






Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

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.