How do i select the preceding nodes of a text node starting from a specific node and not the root no
Posted
by Rachel
on Stack Overflow
See other posts from Stack Overflow
or by Rachel
Published on 2010-05-06T18:21:53Z
Indexed on
2010/05/06
18:28 UTC
Read the original article
Hit count: 304
How do i select the preceding nodes of a text node starting from a specific node whose id i know instead of getting the text nodes from the root node?
When i invoke the below piece from a template match of text node, I get all the preceding text nodes from the root. I want to modify the above piece of code to select only the text nodes that appear after the node having a specific id say 123. i.e something like //*[@id='123']
<xsl:template match="text()[. is $text-to-split]">
<xsl:variable name="split-index" as="xsd:integer"
select="$index - sum(preceding::text()/string-length(.))"/>
<xsl:value-of select="substring(., 1, $split-index - 1)"/>
<xsl:copy-of select="$new"/>
<xsl:value-of select="substring(., $split-index)"/>
</xsl:template>
<xsl:variable name="text-to-split" as="text()?"
select="descendant::text()[sum((preceding::text(), .)/string-length(.)) ge $index][1]"/>
How do i include the condition in places where i use preceding::text inorder to select preceding text nodes relative to the specific node's id which i know?
© Stack Overflow or respective owner