cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevecam <stephen.came...@geometryit.com>
Subject Re: JX templating & XML
Date Mon, 14 Jan 2008 04:13:08 GMT

My version of this solution is as follows:

I need to replace CRLF in data from a RDBMS with <br/> tags, these are being
sanitized by JXTemplate.

In my flowscript I have the following code.

importClass(Packages.org.w3c.dom.Document);
importClass(Packages.javax.xml.parsers.DocumentBuilderFactory);
importClass(Packages.org.xml.sax.InputSource);

.
.
.

function ConvertToXML(str){
	var doc = null;  
	if(str instanceof String){
	   str = "<xhtml:span>" + str.replaceAll("(\r\n|\r|\n|\n\r)",
"<xhtml:br/>") + "</xhtml:span>";
	   doc = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
InputSource(new java.io.StringReader(str)));
	}
	return doc;
}




anil wrote:
> 
> 
> Hi everyone -
> 
> I managed to find a solution to this which was (rather annoyingly) pretty
> simple!
> 
> In the end instead of using an XML string and trying to get that to
> display, I returned a w3c.DOM.document object to the jx template itself &
> this handled outputing the xml for me.
> 
> Anyway, I just thought I would complete the post as a reference for any
> other newbies out there.
> 
> Many thanks,
> Anil.
> 
> 

-- 
View this message in context: http://www.nabble.com/JX-templating---XML-tp14701516p14795132.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message