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

Can I grab text between two characters using XSL?

Subject: Can I grab text between two characters using XSL?
From: "Bryan M" <vanillaxtrakt@xxxxxxxxx>
Date: Thu, 13 Sep 2007 17:10:41 -0400
 Can I grab text between two characters using XSL?
i have some xml that's being created from multiple html pages by my
CMS.  for example:

    RICHMOND, VA &#8212;July 16, 2007 &#8212;
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent
mauris lectus, interdum nec, consectetuer in, viverra id, enim.
Vestibulum facilisis felis sed magna.

I'm using XSL to format the page, and I want to pull the date from the
page.  Is there a way to just pull the text in between the &#8212;

the xml contains a lot of pages similar but not exact to the one
above.  i tried something like:

<xsl:for-each select="system-page">
                <!--Show the date-->
select="page-xhtml//strong[contains(.,'Richmond') or
                    <br/><xsl:value-of select="substring(.,16)"/>

but this only works for maybe half of the pages, because it seems all
of the pages are formatted differently.  the spacing seems to be
different where it says "RICHMOND, VA" and so the date shows up like
"uly 13, 2007" for some of the pages.  In addition, even when this
does work, it still returns the final &#8212; character, which I don't
want.  Some of the pages have another city listed altogether.

It seems to me the easiest way would be to just pull the text between
the &#8212; characters, but I honestly have no idea how to do this
using XSLT 1.0 (the CMS uses Xalan).

The last resort is to go change all of the HTML of the original pages,
but this would not only consume a lot of time but it will not help me
in the future when a new page is created with different spacing or
some other problem.  Any other ideas are more than welcome.  Thanks.

Current Thread


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.
First Name
Last Name
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.