[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: Peter Lavender <plaven@xxxxxxxxxxxxxx>
Date: Wed, 25 Sep 2002 00:25:13 +1000
capture title text
Hi Jeni,

> > 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>

Acutally, I should have added a bit more:

<?xml version="1.0" ?>
<book isbn="1234567890">

Its title (<title>The Lord of the Rings</title>)

is often misquoted!

<author>J R R Tolkien</author>

...

</book>


> You could use:
> 
>   <xsl:apply-templates select="title/following-sibling::text()" />
 

I'm sure I actually tried this.

What I'm trying to do is actually capture the text using variables and
substring-before and substring after, to get rid of the chars ().

I haven't succeeded so I was tring to just capture the text().

<snip>

Thanks..

But applying the template doesn't allow me to only grab the bits of
the text that I want, namely all the text() with out the chars ().

<xsl:template match="book">
  <xsl:variable name="txtFirst" select='substring-before( ./text(), "(" )' />
  <xsl:variable name="title" select="title"/>
  <xsl:variable name=txtAfter
select='substring-after("title/text()",")" )' />
  <xsl:value-of select="$txtFirst" />
  <xsl:value-of select="title" />
  <xsl:value-of select="$txtAfter" />
</template>


Hope that make more sence..

I tried a zillion combinations of sibling-after, child::preceding etc.

I just can't figure out how to grab that last bit of text: ")

is often misquoted!" with out the ")"

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


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.