Subject: RE: [xsl] How do I capture the text "around" a node? From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx> Date: Tue, 24 Sep 2002 14:45:51 +0100 |
Hi, Text handling like this is always (imho) a little confusing. The simple answer is to use xsl:apply-templates as this will hit all the child text() nodes, not just the first(ala value-of). As a good-practice rule, you should always use apply-templates over value-of (where possible) for a number of reasons, with the biggest probably being that template match=text() gets called. cheers andrew > -----Original Message----- > From: Peter Lavender [mailto:plaven@xxxxxxxxxxxxxx] > Sent: 24 September 2002 14:27 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] How do I capture the text "around" a node? > > > Hi Everyone, > > I'm beating my head against a wall here, and haven't been able to work > out how to capture the text around a node. > > Here is the snippet of xml: > > <book isbn="88888"> > This book <title>Lord of the rings</title> is often misquoted. > > ... > > </book> > > Now I have tried to work out how, but failed miserably and would > appreciate some help, or even better an explaination as to why/how to > do this. > > Here is my attempt to do it: > > <xsl:template match="book"> > > <fo:block font-size="12pt" font-family="serif" > line-height="16pt"> > > <xsl:variable name="txtFirst" select='substring-before( > /book/text(), "(" )' /> > <xsl:value-of select="$txtFirst" /> > <xsl:value-of select="title" /> > <xsl:text>After this is something:</xsl:text> > <xsl:value-of select="/child::title/child::text()" /> > > </fo:block> > > </xsl:template> > > When I do just variable name="txt" select="text()" i only get all text > up to the title tag. How can I get the text after the title node? > > > > Regards, > > Pete. > > -- > Due to a lack of imagination, > this signature will remain > under construction indefinitely. > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.391 / Virus Database: 222 - Release Date: 19/09/2002 > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 19/09/2002 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How do I capture the text, Michael Kay | Thread | Re: [xsl] How do I capture the text, Peter Lavender |
[xsl] Variable question: capture an, Mike Ferrando | Date | Re: [xsl] How do I capture the text, Jeni Tennison |
Month |