xsl-list
[Top] [All Lists]

Re: [xsl] Matching only text nodes with certain (complicated) properties

2009-01-09 12:54:25

Only now that I'm reading your replies am I understanding what "preceding::" actually matches. Thanks!

Good clue with the "normalize-space()", Wendell, but still, somehow whitespace seems to be a problem:

An original XML document (TEI):

...
<item n="c">The <mentioned>i</mentioned> of the nom. before a vowel in the RV.

<pb n="26"/>

<list>
  <item n="a">The <mentioned>i</mentioned> of the ...
...

after applying the following XSL 2.0 Transformation template (among others; the "body//" part of the match ensures that only text nodes from the <body> of the document are considered):

<xsl:template match="body//text()[preceding::text()[normalize-space()][1] &lt;&lt; preceding::pb[1]]"> <span class="pagenumber">page <xsl:value-of select="preceding::pb[1]/@n"/></span>
    <xsl:apply-templates/>
</xsl:template>

becomes:

...
<li>The <span class="ved">i</span> of the nom. before a vowel in the RV.

<span class="pagenumber">page 26</span>
  <ol style="list-style-type:lower-greek">
    <span class="pagenumber">page 26</span>
    <li>
      <span class="pagenumber">page 26</span>
      <span class="ved">i</span> of the ...
...

You see, a lot of <span>s are added not just to the very first text node. These seem to be added just around those places where I have a <pb/> in the original, so I suppose it's got to do with whitespace (there's always one empty line before and after <pb/> in the source XML).

I'm using Saxon B 9.1.0.3 for my XSL 2.0 transformation (in Oxygen).

I'm looking into the thing some more today but thank you for your replies so far.

David Bürgin

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--