You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter Kröpfl <pe...@groebi.com> on 2005/04/02 14:52:51 UTC

< > become < and > in jx file

Hi!

Data is passed from the flowscript to jx file.

unfortunately all the "<" and ">" characters in #{text} or #{header} are
displayed as &lt; and &gt; .
To be able to process them further I need them to be "<" and ">".


print in flow shows everything allright: 
commentlist.text: Testdata blabla <a href="testlink.html">TESTLINK</a>

However the xml produced by in the jx file looks like this:
<commenttext>
  Testdata blabla &lt;a href="testlink.html"&gt;TESTLINK&lt;/a&gt;
</commenttext>

Is there a way to prevent this behaviour in the jx transformation?


Thanks,
Peter


------------------ CODE ---------------------

--- flow snip ---
var commentlist = java.util.ArrayList();
commentlist = commentDAO.find("entry = " + entry.getId());

if (commentlist.size() > 0) {
 print("commentlist.text: " + commentlist.get(0).getText());
}
	
cocoon.sendPageAndWait("internal/generate-view/comments", {entry_id : eid,
commentlist : commentlist, entry : entry}

//everything seems allright allright


--- snip of the jx file ---

<comments>
    <c:forEach select="#{commentlist}">
                <comment>
                    <commentheader>	#{header}</commentheader>
                    <commenttext>	#{text}	</commenttext>                   
                    <commentdate>	#{date}	</commentdate>
                </comment>
    </c:forEach>
</comments>



--- sitemap snip ---

<map:match pattern="internal/generate-view/*">
  <map:generate src="views/{1}View.xml" type="file"/>
  <map:transform type="jx" label="jxDebug"/>
  <map:call resource="html"/>
</map:match>

<map:resources>
        <map:resource name="html">
            <map:transform src="xsl/standardformat.xsl">
            	<map:parameter name="base-url" value="/cocoon/homepage" />
            </map:transform>
            <map:serialize type="html"/>
        </map:resource>
    </map:resources>


------------- END CODE ----------------


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


Re: < > become & lt and & gt in jx file

Posted by Peter Kröpfl <pe...@groebi.com>.
Hi,

many, many thanks for your help.
It is working now.

For everyone who might be interested. 

--- Code that caused the error ---
<xmlize value="${text}" ignoreRoot="true"/>

--- Correct Code ---
<xmlize value="#{text}" ignoreRoot="true"/>



Thanks, Leszek


Peter




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


Re: < > become < and > in jx file

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Peter Kröpfl wrote:
>>>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.
seems that your string is not valid xml.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

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


Re: < > become < and > in jx file

Posted by Peter Kröpfl <pe...@groebi.com>.
>> 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


Re: < > become < and > in jx file

Posted by Leszek Gawron <lg...@apache.org>.
Peter Kröpfl wrote:
> Hi!
> 
> Data is passed from the flowscript to jx file.
> 
> unfortunately all the "<" and ">" characters in #{text} or #{header} are
> displayed as &lt; and &gt; .
> To be able to process them further I need them to be "<" and ">".
> 
> 
> print in flow shows everything allright: 
> commentlist.text: Testdata blabla <a href="testlink.html">TESTLINK</a>
> 
> However the xml produced by in the jx file looks like this:
> <commenttext>
>   Testdata blabla &lt;a href="testlink.html"&gt;TESTLINK&lt;/a&gt;
> </commenttext>
> 
> Is there a way to prevent this behaviour in the jx transformation?
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108680748429717&w=2
please wikify it if the solutions works fine for you.

> 
> 
> Thanks,
> Peter
> 
> 
> ------------------ CODE ---------------------
> 
> --- flow snip ---
> var commentlist = java.util.ArrayList();
> commentlist = commentDAO.find("entry = " + entry.getId());
> 
> if (commentlist.size() > 0) {
>  print("commentlist.text: " + commentlist.get(0).getText());
> }
> 	
> cocoon.sendPageAndWait("internal/generate-view/comments", {entry_id : eid,
> commentlist : commentlist, entry : entry}
> 
> //everything seems allright allright
> 
> 
> --- snip of the jx file ---
> 
> <comments>
>     <c:forEach select="#{commentlist}">
>                 <comment>
>                     <commentheader>	#{header}</commentheader>
>                     <commenttext>	#{text}	</commenttext>                   
>                     <commentdate>	#{date}	</commentdate>
>                 </comment>
>     </c:forEach>
> </comments>
> 
> 
> 
> --- sitemap snip ---
> 
> <map:match pattern="internal/generate-view/*">
>   <map:generate src="views/{1}View.xml" type="file"/>
>   <map:transform type="jx" label="jxDebug"/>
>   <map:call resource="html"/>
> </map:match>
> 
> <map:resources>
>         <map:resource name="html">
>             <map:transform src="xsl/standardformat.xsl">
>             	<map:parameter name="base-url" value="/cocoon/homepage" />
>             </map:transform>
>             <map:serialize type="html"/>
>         </map:resource>
>     </map:resources>
> 
> 
> ------------- END CODE ----------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

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