This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes XML and Related Technologies and the fly likes xslt String replace with node Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply 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: 16479
    
    2

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: xslt String replace with node
 
Similar Threads
[XSL-FO][docbook]Problem print line in table of contents
An XSLT that's just a little more Specific
xsl template question
XSLT parsing XML
How to Add a Line Counter for Each XML Element in XSL?