Re: [xsl] Picking up the 2nd part text after child element

Subject: Re: [xsl] Picking up the 2nd part text after child element
From: Bryan Schnabel <bryan.schnabel@xxxxxxxxxxxxx>
Date: Wed, 26 Mar 2003 15:18:03 -0800 (PST)
Spenser,

I think I understand what you want.  This will pick up
the second part:

<xsl:if test="text()[2]">
p2: <xsl:value-of select="text()[2]"/>
</xsl:if>


--- Spenser Kao <SpenserKao@xxxxxxxxxxxxxxxx> wrote:
> Hi,
> 
> If I have an element having text split into two
> parts with a child
> element in between, how do I pick up the second part
> text after the
> child element?
>  
> Please see attached files for xml instance,
> stylesheet and test output. 
> 
> I expected to pick up the multiple parts of text and
> the child element's
> text in the order they appear, but lost the second
> part text after the
> child element. Any suggestion will be appreciated.
> 
> Regards,
> 
> Spenser
> 
> 1)  The xml instance file --
> 
> <?xml version="1.0" encoding="ISO-8859-1"
> standalone="no"?>
> <paras>
> <p>First paragraph starts, <i>Italic text here</i>,
> first paragraph
> ends.</p> 
> <p>Second paragraph starts, <i>Italic text here</i>,
> second paragraph
> ends.</p> 
> </paras>
> 
> 2) The stylesheet file -
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="text"/>
> 
> <xsl:template match="/paras">
> <xsl:apply-templates select="p"/>
> </xsl:template>
> 
> <xsl:template match="p">
> 
> One para --
> <xsl:if test="text()">
> p: <xsl:value-of select="text()"/>
> </xsl:if>
> <xsl:if test="node()">
> 	<xsl:apply-templates select="i"/>
> </xsl:if>
> </xsl:template>
> 
> <xsl:template match="i">
> i: <xsl:value-of select="text()"/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> 3) The test output.
> One para --
> 
> p: First paragraph starts,
> i: Italic text here
> 
> One para --
> 
> p: Second paragraph starts,
> i: Italic text here 
> 
> 
> 
> 
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread