cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Donald Thomason" <>
Subject CForms-approach to outputing XML/HTML in form fields
Date Tue, 05 Dec 2006 17:50:35 GMT
This problem has come up before, but I don't recall seeing
this solution. Thought it might be useful or generate 
other thoughts (plus by depositing it here I will remember
where it is).

I needed to output data from an element containing an 
unescaped html anchor in a form output field (string 
datatype) and have the anchor appear as html. The form 
template is jx generated. I wasnÂ’t able to spend enough 
time with the jx:set/jx:out method proposed a few months

to get it to work. However, I found that the html tag would

show up as desired if I serialized the data at binding.

The javascript flow is the a pipeline-generated DOM for the

data to be bound:
 var pipelineUtil =
 var document = pipelineUtil.processToDOM(documentURI,
 currentForm.load(document);  // simple binding
In the binding file, use javascript to bind the data:
 <fb:javascript id="Description" path="Description">
     // XMLUtils class is imported in the binding.js file
     var props = XMLUtils.createPropertiesForXML(true);
//no xml declaration  
     var formValue =
XMLUtils.serializeNode(jxpathPointer.getNode(), props);

In the form template, use the normal widget for output. 
   <ft:widget id="Description" />
I wrapped the widget in a custom tag to escape the output
a downstream stylesheet so linked text shows up and css can

be applied: 
  <xsl:template match="linkedText">
        <xsl:value-of select="."

This was tested on 2.1.9 and BRANCH_2_1_X with the newjx 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message