cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Kröpfl <pe...@groebi.com>
Subject Re: < > become &lt and &gt in jx file
Date Sat, 02 Apr 2005 23:12:46 GMT
>> Is there a way to prevent this behaviour in the jx transformation?
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108680748429717&w=2

I copied the code and made a little change (original code commented out):
However it is still not working. 

Errormessage:
at stringToSAX (file:/usr/java/tomcat/webapps/cocoon/homepage/flow/main.js, Line
11): org.xml.sax.SAXParseException: Premature end of file.


Thanks for your help.
Peter


---- CODE ----
function stringToSAX( str, consumer, ignoreRootElement ) {
 	var is = new Packages.org.xml.sax.InputSource( new java.io.StringReader( str ) );
 	var ignore = ( ignoreRootElement == "true" );
 	var parser = null;
 	var includeConsumer = new org.apache.cocoon.xml.IncludeXMLConsumer( consumer,
consumer );
 	includeConsumer.setIgnoreRootElement( true );
 	try {	
 		parser = cocoon.getComponent(
Packages.org.apache.excalibur.xml.sax.SAXParser.ROLE );
 		parser.parse( is, includeConsumer );	
 	} finally {
 		if ( parser != null ) cocoon.releaseComponent( parser );
 	}
 }

// put it into session by
cocoon.session.setAttribute( "saxer", stringToSAX  );

implement a jx:macro:
 	<jx:macro name="xmlize">
 		<jx:parameter name="value"/>
 		<jx:parameter name="ignoreRoot" default="false"/>
                <!-- Original Code -->
 		<!--jx:set var="ignored" value="${cocoon.session.stringToSAX( value,
cocoon.consumer, ignoreRoot )}"/ -->
                <!-- My Change -->
 		<jx:set var="ignored" value="${cocoon.session.saxer( value, cocoon.consumer,
ignoreRoot )}"/>
 	</jx:macro>


// use it like this:

<xmlize value="${xmlVal}" ignoreRoot="true"/>

// I use it like this:
 <jx:forEach select="#{commentlist}">
                <comment>
                    <commentheader>	#{header}</commentheader>
                    <commenttext><xmlize value="${text}"
ignoreRoot="true"/></commenttext>                   
                    <commentdate>	#{date}	</commentdate>
                </comment>
    </jx:forEach>

----END CODE----




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


Mime
View raw message