> Having obtained the node <instrText> whose text contains value 6
> I want to count all previous instrText nodes whose text starts with
> "HYPERLINK"
> and are buried at any level within the same record/Kommentar/body/section
> tree as the node with value 6
First letbs do XSLT 2.0. Your requirement translates directly into syntax:
count(
preceding::instrText
[starts-with(., bHYPERLINKb)]
[ancestor::sect is current()/ancestor::sect]
)
The only problem is the bisb operator which requires 2.0. In XSLT 1.0 you
can substitute generate-id():
count(
preceding::instrText
[starts-with(., bHYPERLINKb)]
[generate-id(ancestor::sect) = generate-id(current()/ancestor::sect)]
)
>
>
> So in my example the count result should be b4"
I donbt see how you get 4. Which 4? From your description, I would expect to
select those labelled 3, 4, and 5.
Michael Kay
Saxonica
> I stumble when I try to count nodes which are previous to a given node but
> have to meet the above xpath condition
> Thanks in advance for any advice.
> Regards Markus
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <file>
> <record>
> <Kommentar>
> <body>
> <sect>
> <p>
> <r>
> <instrText>HYPERLINK \l "anchor" \t "1"</instrText>
> </r>
> </p>
> <p>
> <r>
> <instrText>HYPERLINK \l "anchor" \t "2"</instrText>
> </r>
> </p>
> </sect>
> </body>
> </Kommentar>
> </record>
>
>
> <record>
> <Kommentar>
> <body>
> <sect>
> <p>
> <r>
> <instrText>HYPERLINK \l "anchor" \t "3"</instrText>
> <instrText>HYPERLINK \l "anchor" \t "4</instrText>
> </r>
> </p>
> <p>
> <r>
> <rPr>
> <rFonts ascii="BLG New Garamond" h-ansi="BLG
> New Garamond"/>
> <sz val="32"/>
> </rPr>
> <instrText>HYPERLINK \l "anchor" \t "5"</instrText>
> </r>
> </p>
> <p>
> <r>
> <instrText>HYPERLINK \l "anchor" \t "6"</instrText>
> </r>
> </p>
> </sect>
> </body>
> </Kommentar>
> </record>
> </file>
|