[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Splitting content from sub-elements

Subject: Re: Splitting content from sub-elements
From: Casper Voortman <casper.voortman@xxxxxxxxxxxx>
Date: Tue, 16 Jun 2009 16:00:23 +0200
Re:  Splitting content from sub-elements
Ken and Emmanuel,

Thanks for the very quick response.

Indeed i started trying it with the push method but i kept losing the content while keeping the sub-elements. After that i started going into way to difficult routes to get my result (even tried going through them 1 by 1 with following:sibling etc.)

But what i totally overlooked was that i should have used the call '<xsl:apply-templates/>' without the 'select' attribute.

Again thanks.

Regards,

Casper Voortman

Op 16 jun 2009, om 15:48 heeft G. Ken Holman het volgende geschreven:

At 2009-06-16 15:30 +0200, Casper Voortman wrote:
I'm having trouble with breaking down a piece of XML into a simpler
structure by using xslt 1.0.

The problem concentrates itself specifically around splitting the
content within a <Text> element from the <FootNote>, which is also
part of the same element <Text >, and still keeping the order within
the <Paragraph> intact.

Sounds to me like you are trying to use pull (xsl:for-each) rather than push (xsl:apply-templates).


Any suggestions would be much appreciated.

I hope the example below helps. Note that your desired output is the same order as the input, so it is a simple matter of substitution.


. . . . . . . . . . . Ken


t:\ftemp>type casper.xml <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">A line of text.</Text> <Text Cstyle="Cursief">Another line of text.</Text> <Text Cstyle="[No character style]">A 3rd line of text<FootNote ID="14"> <Paragraph Pstyle="Voetnoot"> <Text Cstyle="[No character style]">This is the content of the footnote.</Text> </Paragraph> </FootNote>that contains a footnote.</Text> <Text Cstyle="Cursief">A 4th line of text.</Text> <Text Cstyle="[No character style]">A 5th line of text that also<FootNote ID="15"> <Paragraph Pstyle="Voetnoot"> <Text Cstyle="[No character style]">This is the 2nd footnote.</Text> </Paragraph> </FootNote>a footnote.</Text> </Paragraph> t:\ftemp>call xslt casper.xml casper.xsl <?xml version="1.0" encoding="utf-8"?><para> A line of text. <emphasis role="italic">Another line of text.</emphasis> A 3rd line of text<footnote label="14"> <para> This is the content of the footnote. </para> </footnote>that contains a footnote. <emphasis role="italic">A 4th line of text.</emphasis> A 5th line of text that also<footnote label="15"> <para> This is the 2nd footnote. </para> </footnote>a footnote. </para> 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="Paragraph">
 <para><xsl:apply-templates/></para>
</xsl:template>

<xsl:template match="FootNote">
 <footnote label="{@ID}"><xsl:apply-templates/></footnote>
</xsl:template>

<xsl:template match="Text[@Cstyle='Cursief']">
 <emphasis role="italic"><xsl:apply-templates/></emphasis>
</xsl:template>

<xsl:template match="Text">
 <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>rem Done!



--
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.