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

XPath Expression - find the first preceding-sibling th

Subject: XPath Expression - find the first preceding-sibling that is a processing-instruction
From: "Craig Whisenhunt" <craig@xxxxxxxxxxxx>
Date: Wed, 1 Mar 2006 17:21:44 -0600
xslt first preceding sibling
Altova XSLT 2.0 Engine (XMLSpy2006)

I want to look at preceding-siblings until I find a processing-instruction
and assign the value of that processing-instruction to a variable with
'select' so I can compare it to another variable later.

Sample XML:

<Body>
<Caption>
<Para><?Pub line="2" page="1" position="820"?>the cat in the hat.</Para>
</Caption>
<Clause>
<Para FirstLineIndent="7"><?Pub line="3" page="1" position="913"?>hello
world</Para>
</Clause>
<Para FirstLineIndent="7"><?Pub line="4" page="1" position="1010"?> SECTION
<HardSp/> <AutoNum/> Hi <HardSp/> <HardSp/> running around in circles <?Pub
line="5" page="1" position="1101"?> hard to follow.</Para>
</Body>

Stylesheet Excerpt:

<xsl:template match="text()|HardSp|AddedText|processing-instruction('Pub')"
mode="skillets">
<xsl:param name="currentPI"/>
  <xsl:if test="preceding-sibling::*[processing-instruction('Pub')]">
    <xsl:variable name="testPIvalue"
select="preceding-sibling::*[processing-instruction('Pub')]"/>
    <xsl:text>skillets!!!!</xsl:text>
  </xsl:if>
</xsl:template>

XPath expression in question:
preceding-sibling::*[processing-instruction('Pub')]

Not sure if my expression is correct for what I want to do, but it doesn't
'find' the preceding processing-instructions.

For example, when the context node is the text 'the cat in the hat', that
XPath expression does not find the processing-instruction just before it.
Similarly in the rest of the sample there, the expression does not find any
of the processing-instructions no matter what the context node.

Thanks,
-Craig

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.