Re: [xsl] segmenting a paragraph

Subject: Re: [xsl] segmenting a paragraph
From: "Christian Wittern" <cwittern@xxxxxxxxx>
Date: Wed, 3 Oct 2007 17:28:54 +0900
First of all, thanks David, this was in fact what I was looking for
(and now realized that I went down a similar path some time ago..).

On 02/10/2007, David Carlisle <davidc@xxxxxxxxx> wrote:
>
> > This is essentially a variant of the approach using saxon:serialize(), which
> > inserts the strings <note> and </note> instead of @@@@@ and !!!!!.
>
> yes but it's for the simpler case (that I think we are in) that you can
> remove the entire note element (and put it back later) saxon serialise
> would not only put <note> there it would flatten out all its contents as
> well, (which is why you'd needs saxon:parse to reconstruct it)

Indeed, I found out that the method of taking out the note as a whole
and put it back later is the solution I need, since otherwise the
regex processing potentially messes up the content of the notes and
produces a string that can't be parsed back into XML.

However, I came across a little problem in the code:


<xsl:template match="note" mode="zap-node">
 <xsl:text>@@@@@</xsl:text>
 <xsl:value-of select="count(preceding-sibling::note)+1"/>
 <xsl:text>!!!!!</xsl:text>
</xsl:template>

Here we count the preceding note elements.

<xsl:matching-substring>
<xsl:copy-of select="$p/note[position()=regex-group(1)]"/>
</xsl:matching-substring>

However, here we count all preceding nodes, no?  So in some cases I
get the wrong note inserted.  Is there a way to limit the value
returned by position in the XPath expression in the same way to return
only preceding siblings element nodes with the name note?

best,

Christian

-- 
Christian Wittern, Kyoto

Current Thread