xsl-list
[Top] [All Lists]

Re: [xsl] Can I grab text between two characters using XSL?

2007-09-13 14:39:50
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&#8212;July, 16, 2007, 
'&#8212;')"/>

 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&#8212;12345, 
'&#8212;')"/> 
   
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 —July 16, 2007 —
   
   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 —
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 — 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 — 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(_at_)lists(_dot_)mulberrytech(_dot_)com>--~--






--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>