Altova Mailing List Archives


Re: [xsl] segmenting a paragraph

From: "Christian Wittern" <cwittern@--------->
To:
Date: 10/3/2007 8:29:00 AM
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

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.