[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?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|