Subject: Re: Can I grab text between two characters using XSL?
From: "Alice Wei" <ajwei@xxxxxxxxxxx>
Date: Thu, 13 Sep 2007 17:39:22 -0400
|
Hi, Bryan:
Looks like you are getting the dates in this example? There is something
that you might want to try:
<xsl:value-of select="substring-after(Richmond, VA—July, 16, 2007,
'—')"/>
This can give you the output of July, 16, 2007.
In case you have some text after the date, say 12345, you can use
<xsl:value-of selecct="substring-before(July, 16, 2007—12345,
'—')"/>
to get the same output of July 16, 2007. The string-before or string-after
depends on the position of your dash sign.
One suggestion is that in case you do have a lot of the output with the same
format, set them as some sort of "variable" so you can easily extract them.
I hope this helps.
Good luck.
Alice
On Thu Sep 13 17:10 , "Bryan M" sent:
>i have some xml that's being created from multiple html pages by my
>CMS. for example:
>
>
>
>
>
> RICHMOND, VA bJuly 16, 2007 b
>
> 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 b
>characters?
>
>the xml contains a lot of pages similar but not exact to the one
>above. i tried something like:
>
>
>
> select="page-xhtml//strong[contains(.,'Richmond') or
>contains(.,'RICHMOND')]">
>
>
>
>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 b 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 b 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.
>
>--~------------------------------------------------------------------
>XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-listTo
unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/or e-mail:
xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>--~--
|