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

RE: How do I capture the text "around" a node?

Subject: RE: How do I capture the text "around" a node?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 24 Sep 2002 17:01:25 +0100
RE:  How do I capture the text "around" a node?
I'm not sure what result you want.

If you want:
"This book Lord of the rings is often misquoted."

then you can just get it as the string-value of the <book> element.

i.e., with <book> as the context node, it is string(.).

If you want

"This book is often misquoted."

then it's best to use template rules - these are always a good idea when
handling mixed content.

<xsl:variable name="top-level-text">
  <xsl:apply-templates select="text()"/>
</xsl:variable>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Peter Lavender
> Sent: 24 September 2002 14:27
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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
> 


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


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.