XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
David CorleySubject: replacing
Author: David Corley
Date: 18 Jan 2007 09:29 AM
Originally Posted: 18 Jan 2007 09:27 AM
I have a java stack-trace string that I'd like to format for html display.
I need to replace every " at" sub-string of the stack-trace with "
at".
I initially used the xpath 2.0 replace() function, but as Michael Kay's book pointed out, the replace function doesn't support output escaping. So what happens is my html CODE is beautifully formatted, but is not rendered the way I want it.

I need the the &#10 to actually be visible in the code, as opposed to being processed as a new line by the xslt processor, which is what currently happens.

Can anyone help me?
This is really bothering me.

Postnext
Tony LavinioSubject: replacing
Author: Tony Lavinio
Date: 18 Jan 2007 11:10 AM
Why don't you post what you have for input XML, and also the XSLT
you've tried? Otherwise, we're just guessing, and may waste time
suggesting things you've already tried.

Also, without a test case showing input, it's hard to know what's
actually being transformed.

Postnext
David CorleySubject: replacing
Author: David Corley
Date: 19 Jan 2007 03:40 AM
First of all apologies for the multiple threads. I've been posting this problem on a few regex/xslt forums, and genuinely forgot I had already posted.
The input I have is the following:
<testsuite>
<testcase classname="test.net.sourceforge.pmd.jsp.rules.DontNestJsfInJstlIterationTest" name="testViolation" time="0.0">
<error message="Couldn&apos;t find xml/DontNestJsfInJstlIteration.xml" type="java.lang.RuntimeException">java.lang.RuntimeException: Couldn&apos;t find xml/DontNestJsfInJstlIteration.xml
at test.net.sourceforge.pmd.testframework.RuleTst.extractTestsFromXml(RuleTst.java:149)
at test.net.sourceforge.pmd.testframework.RuleTst.extractTestsFromXml(RuleTst.java:137)
at test.net.sourceforge.pmd.testframework.SimpleAggregatorTst.runTests(SimpleAggregatorTst.java:18)
at test.net.sourceforge.pmd.jsp.rules.DontNestJsfInJstlIterationTest.testViolation(DontNestJsfInJstlIterationTest.java:20)
</error>
</testcase>
</testsuite>

My xslt needs to take the text between the <error> tags and output it to html with &#10; inserting before every instance of the word "at".

I've tried the following:
<td class="stacktrace"><xsl:value-of select="replace(.,'at','&#10;at')"></xsl:value-of></td>

Unfortunately the xslt processer interprets the &#10 as a processing instruction, rather than text for output, and the html code get formatted using the instruction. I've tried turning the "disable-output-escaping" attribute on in the <xsl:value-of> element, but it has no effect.

Any suggestions?

Postnext
Tony LavinioSubject: replacing
Author: Tony Lavinio
Date: 19 Jan 2007 09:02 AM
You need to escape the '&' in &#10; like this:
<xsl:value-of select="replace(., ' at ', '&amp;#10;at ')"/>

Postnext
David CorleySubject: replacing
Author: David Corley
Date: 19 Jan 2007 09:38 AM
Hey Tony,
I'm afraid that doesn't work either. It still formats the html code instead of outputting the &#10 as text.

Any other suggestions?

Postnext
Tony LavinioSubject: replacing
Author: Tony Lavinio
Date: 19 Jan 2007 11:20 AM
<td><pre> .... </pre></td>

Posttop
David CorleySubject: replacing
Author: David Corley
Date: 20 Jan 2007 05:16 AM
That works, although the fixed width font is nasty looking.
Thanks for all the help!

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.