xsl-list
[Top] [All Lists]

Re: Isolate spezial text term with pattern

2005-07-25 17:47:00
Hi Oliver,

But i want only PB123.
With the function substring-after i get "PB123 Rest of the Comment".

Any solution ?

Errr, well, since I have no clue what the "Rest of the comment"
actually contains it's a little hard to guess.

If you're using an XSLT 2.0 processor, you can try a regular
expression.  Not really going to bother trying to figure out how to do
the regular expression in XSLT 2.0 since I haven't done it before.  I
think there's some examples in the spec chapter 15
(http://www.w3.org/TR/xslt20/#regular-expressions).

On the other hand, if your text is regular enough that it is
deliminated by at the end of the sequence (say a space) you could do
some more string chunking.  My example improved a bit (and with
correct quotations this time I think)

 <xsl:template match="comment">
 <td>PB<xsl:value-of
select='substring-before(substring-after(.,"PB")," ")' /></td>
 </xsl:template>

This writes out PB, then gets everything after the PB (string x),
everything before the space in string x (string y), and writes string
y.

If either the above suggests don't work, I think it would be far more
helpful to see a small but complete example of the XML.  Also any
details like restrictions in processor choice, languages, development
environment might help.

Jon Gorman

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