Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] XPath Expression - find the first preceding-sibling that is a processing-instruction

From: "Dimitre Novatchev" <dnovatchev@--------->
To:
Date: 3/1/2006 11:31:00 PM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent