Subject: Re: [xsl] XPath Expression - find the first preceding-sibling that is a processing-instruction From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Thu, 2 Mar 2006 10:30:36 +1100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XPath Expression - find the f, Craig Whisenhunt | Thread | [xsl] Expression in XPath, Dariusz Borowski |
[xsl] XPath Expression - find the f, Craig Whisenhunt | Date | [xsl] Expression in XPath, Dariusz Borowski |
Month |