aspose file tools*
The moose likes XML and Related Technologies and the fly likes xslt String replace with node Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xslt String replace with node" Watch "xslt String replace with node" New topic
Author

xslt String replace with node

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi
I am trying to format Strings (like Java formatter) using xslt
so the outoput will be replaced with the matching {X} in the string of the data section
for example xml :



the desired output will be:

No param
Hallo world Steve and Hi roman
Hallo bla bla world roman and Hi vss

I am able to replace just normal strings with a tamplate, but i am unable to replace regular expressions

sample xsl:



Is it possible to contain function to get regex?
Thank you
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

So what happens instead? You get those nodes, unchanged, in your output?

Are you using a transformer which can handle XSLT 2.0?
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Originally posted by Paul Clapham:
So what happens instead? You get those nodes, unchanged, in your output?

I am able to replace Strings and i get the correct output for string replacemant, but i cannot find "{[0-9]}" as regex.
for example, in the attached xsl if you replace the line:
<xsl:variable name="regExp" select="'{[1-9]}'"/>
with :
<xsl:variable name="regExp" select="'ReplaceMe'"/>

all "ReplaceMe" word in the input will be replaced.

Are you using a transformer which can handle XSLT 2.0?
Yes.

[ November 23, 2008: Message edited by: Sharon whipple ]
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

Hi Sharon. The contains and substring- functions don't use regular expressions. You'll need to use the matches and replace functions, or xsl:analyze-string and its related instructions.
 
 
subject: xslt String replace with node
 
Similar Threads
How to Add a Line Counter for Each XML Element in XSL?
An XSLT that's just a little more Specific
xsl template question
[XSL-FO][docbook]Problem print line in table of contents
XSLT parsing XML