Subject: Re: [xsl] Problem with grouping sibling tags From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 23 Dec 2008 08:25:33 -0500 |
The second link post seems more in the direction of what i'm looking for, but unfortunately i'm not completely grasping the process. Will study it harder, but this is 'higher' xslt writing for me. ... Op 23 dec 2008, om 11:45 heeft Michael Kay het volgende geschreven:And in particular Ken Holman's post at http://markmail.org/message/teo6uftbxjvsa56c (dated 22 Oct 1999) which must be the earliest exposition of the technique often called "sibling recursion".
T:\ftemp>type casper.xml <?xml version="1.0" encoding="UTF-8"?> <ArticleContent> <Frame Label="BroodTekst"> <Paragraph Pstyle="Tussenkop"> <Text Cstyle="[No character style]">textcontent</Text> <Text Cstyle="[No character style]"/> </Paragraph> <Paragraph Pstyle="PlattetekstInitiaal"> <Text Cstyle="[No character style]">textcontent</Text> </Paragraph> <Paragraph Pstyle="PlattetekstBullet"> <Text Cstyle="[No character style]">bullet1</Text> </Paragraph> <Paragraph Pstyle="PlattetekstBullet"> <Text Cstyle="[No character style]">bullet2</Text> </Paragraph> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">textcontent</Text> </Paragraph> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">textcontent</Text> </Paragraph> <Paragraph Pstyle="PlattetekstBullet"> <Text Cstyle="[No character style]">bullet3</Text> </Paragraph> </Frame> </ArticleContent>
T:\ftemp>type casper.out <?xml version="1.0" encoding="utf-8"?>
<section role="BroodTekst"> <title role="tussenkop">textcontent</title> <para role="plattetekstInitiaal"> textcontent </para> <itemizedlist> <listitem> <para role="plattetekstBullet"> bullet1 </para> </listitem> <listitem> <para role="plattetekstBullet"> bullet2 </para> </listitem> </itemizedlist> <para role="plattetekst"> textcontent </para> <para role="plattetekst"> textcontent </para> <itemizedlist> <listitem> <para role="plattetekstBullet"> bullet3 </para> </listitem> </itemizedlist> </section>
T:\ftemp>type casper.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="Frame"> <section role="{@Label}"><xsl:apply-templates select="*"/></section> </xsl:template>
<xsl:template match="Paragraph[@Pstyle='Tussenkop']"> <title role="tussenkop"><xsl:apply-templates select="Text"/></title> </xsl:template>
<xsl:template match="Paragraph[@Pstyle='PlattetekstInitiaal']"> <para role="plattetekstInitiaal"><xsl:apply-templates/></para> </xsl:template>
<xsl:template match="Paragraph[@Pstyle='Plattetekst']"> <para role="plattetekst"><xsl:apply-templates/></para> </xsl:template>
<xsl:template match="Paragraph[@Pstyle='PlattetekstBullet']"> <!--only do something if this is the first of consecutive siblings--> <xsl:if test="not(preceding-sibling::*[1][self::Paragraph] [@Pstyle='PlattetekstBullet'])"> <itemizedlist> <xsl:apply-templates mode="next-list-item" select="."/> </itemizedlist> </xsl:if> </xsl:template>
<xsl:template mode="next-list-item" match="Paragraph[@Pstyle='PlattetekstBullet']"> <listitem> <para role="plattetekstBullet"><xsl:apply-templates/></para> </listitem> <!--keep building the list as long as there are consecutive siblings--> <xsl:apply-templates mode="next-list-item" select="following-sibling::*[1][self::Paragraph] [@Pstyle='PlattetekstBullet']"/> </xsl:template>
-- Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes: : Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Unable to replace "/", Florent Georges | Thread | Re: [xsl] Problem with grouping sib, Casper Voortman |
Re: [xsl] Unannounced Departure of , Vasu Chakkera | Date | RE: [xsl] numbering question, Trevor Nicholls |
Month |