Altova Mailing List Archives

[xsl] Converting milestone tags

From: Josef Schneeberger <josef@---------------.-->
To: xsl-list@-----.------------.---
Date: 10/14/2010 7:06:00 AM
Hi everybody,

I am new to this list and apologize, if my question is an FAQ. I scanned
the archives, but did not find a solution. The question arises in a TEI
project where we have to switch from a chapter hierarchy to a page
oriented form. The XSLT is done in multiple steps (a cocoon pipeline)
and I use Saxon9.

Here is a simplified example of an infile:

 <p>text <span order="start"/>text<span order="end"/> text</p>
 <p>text <span order="start"/>text<span order="end"/> text
    text <span order="start"/>text<span order="end"/> text</p>
 <p>text text text <span order="start"/>text<span order="end"/></p>
 <p><span order="start"/>text<span order="end"/> text text text</p>

which should result in the following output:

 <p>text <span>text</span> text</p>
 <p>text <span>text</span> text
    text <span>text</span> text</p>
 <p>text text text <span>text</span></p>
 <p><span>text</span> text text text</p>

There my be an arbitrary number of <span order="begin"/> (and
corresponding end milestone tags) in a p element. Furthermore, any
"text" node may again contain markup which should be preserved in the
output. I tried various approaches but I failed. Here is one of my
attempts using sibling recursion ...

<xsl:stylesheet version="2.0"
 <xsl:template match="/">
 <xsl:template match="root">
 <xsl:template match="p">
   <xsl:apply-templates select="child::node()" mode="procp"/>
 <xsl:template match="span[@order='start']" mode="procp">
  <xsl:apply-templates select="following-sibling::node()[1]"/>
 <xsl:template match="node()" mode="procp">
  <xsl:copy-of select="."/>

Any help would be greatly appreciated. Josef

Josef Schneeberger
Nuernberg, Germany

XSL-List info and archive:
To unsubscribe, go to:
or e-mail: <mailto:xsl-list-unsubscribe@l...>


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 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.