Subject: Re: [xsl] breaking up XML on page break element [RETRY 3] From: "G. Ken Holman g.ken.holman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 5 Jul 2014 16:05:21 -0000 |
At 2014-07-04 14:43 +0000, Geert Bormans geert@xxxxxxxxxxxxxxxxxxx wrote:Now I want to break the document per page, reconstructing the structure
Use "<<" and ">>" to determine those elements that are before, after and in-between page breaks, then recreate the document structure up to those points.
t:\ftemp>type geert.xml <?xml version="1.0" encoding="UTF-8"?> <book> <title>...</title> <section no="1"> <para>aaa<pb/>bbb</para> </section> <section no="2"> <para>2-1</para> <para>ccc<pb/>ddd<pb/>eee</para> <para>2-3</para> <subsection> <para>fff<pb/>ggg<span>hhh<pb/>jjj</span>kkk<pb/>mmm</para> </subsection> <pb/> <para>2-5</para> </section> <section> <para>No breaks</para> </section> </book>
<xsl:template match="@*|node()" mode="#default section"> <xsl:param tunnel="yes" name="after"/> <xsl:param tunnel="yes" name="before"/> <xsl:param tunnel="yes" name="ancestors" as="element()*"/> <xsl:choose> <xsl:when test="( . intersect $ancestors ) or ( not($after) and not($before) ) or ( not($after) and . << $before ) or ( . >> $after and not($before) ) or ( . >> $after and . << $before )"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template>
</xsl:stylesheet> t:\ftemp>rem Done!
-- Contact us for world-wide XML consulting and instructor-led training | Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm | Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ | G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx | Google+ profile: http://plus.google.com/+GKenHolman-Crane/about | Legal business disclaimers: http://www.CraneSoftwrights.com/legal |
--- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] breaking up XML on page b, G. Ken Holman g.ken. | Thread | Re: [xsl] breaking up XML on page b, Geert Bormans geert@ |
Re: [xsl] breaking up XML on page b, G. Ken Holman g.ken. | Date | Fwd: Re: [xsl] breaking up XML on p, G. Ken Holman gkholm |
Month |