[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XPath Expression - find the first preceding-siblin
Use: preceding-sibling::processing-instruction('Pub')[1] -- Cheers, Dimitre Novatchev --------------------------------------- The significant problems we have cannot be solved at the same level of thinking with which we created them. On 3/2/06, Craig Whisenhunt <craig@xxxxxxxxxxxx> wrote: > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|