cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@dti.net>
Subject Re: including xml dynamically from a string
Date Tue, 27 Nov 2001 16:35:51 GMT
Someone else had this same problem recently.

Use <util:include-expr>.  It will parse the text that you pass in to it, and generate
SAX calls from it (as opposed to writing the text straight to the output - after escaping
all the control chars - like it's doing now).

1) Include the namespace xmlns:util="http://apache.org/xsp/util/2.0" in your XSP or the <util:include-expr>
won't get called properly.

2) the call you need to make this work:
<util:include-expr><util:expr><xsp:expr>xml</xsp:expr></util:expr></util:include-expr>

<xsp:expr>xml</xsp:expr> takes the value of String  xml, which is then passed
in to <util:include-expr>.


DR


At 09:47 AM 11/27/01 +0530, you wrote:
>Hi,
>         Can any one help me in doing this. I get a piece of XML data as a request attribute
forwarded from a servlet. In my xsp page i have to attach that. here is the code snippet
><page>
>   <body>
>    <heading>dynamic</heading>
>       <xsp:logic>  
>        String xml = (String)request.getAttribute("xml"); ( This will return a XML format
string  like " <folders> <folder>Inbox</folder> <folder>Bulk Mail</folder>
</folders>" )
>         // what should i do here ??
>        </xsp:logic>
>    </body>
></page>
>  
>so that the xml which goes to the xslt processes from xsp processor should look like this.
>page>
>   <body>
>    <center>
>    <heading>dynamic</heading>
>         <folders>
>             <folder>Inbox</folder>
>             <folder>Bulk Mail</folder>
>         </folders>
>     </body>
></page>
>  
>It happens some time that the string i get from request attribute can even have a different
structure also . I need a generic sort of implementation to do this. I tried the code below
which will add some tree to the xml but i need to populate that reading from the string.
>  
>  
><?xml version="1.0"?>
><?cocoon-process type="xsp"?>
><?cocoon-process type="xslt"?>
><?xml-stylesheet href="xsl/dynamic-to-html.xsl" type="text/xsl" ?>
>  <xsp:page
>   language="java"
>   xmlns:xsp="<http://www.apache.org/1999/XSP/Core>http://www.apache.org/1999/XSP/Core"
>   xmlns:request="<http://www.apache.org/1999/XSP/Request>http://www.apache.org/1999/XSP/Request"
>   xmlns:util="<http://www.apache.org/1999/XSP/Util>http://www.apache.org/1999/XSP/Util"
>   create-session="true"
>  > 
><page>
>   <body>
>    <center>
>    <heading>dynamic</heading>
>       <xsp:logic>  
>        String xml = (String)request.getAttribute("xml"); ( This willreturn a XML format
string  like " <folders> <folder>Inbox</folder> <folder>Bulk Mail</folder>
</folders>" )
>          xspParentNode = xspCurrentNode;
>          xspNodeStack.push(xspParentNode);
>           xspCurrentNode =document.createElement("folders");
>           xspParentNode.appendChild(xspCurrentNode);
>     
>        xspParentNode = xspCurrentNode;
>        xspNodeStack.push(xspParentNode);
>    
>    xspCurrentNode =  document.createElement("folder");
>    xspParentNode.appendChild(xspCurrentNode);
>    xspCurrentNode.appendChild(document.createTextNode("Inbox"));
>  
>    xspCurrentNode =  document.createElement("folder");
>    xspParentNode.appendChild(xspCurrentNode);
>    xspCurrentNode.appendChild(document.createTextNode("Outbox"));
>  
>    </xsp:logic>
>    
>    </center>
>  </body> 
>  
>  </page>
></xsp:page>
>  
>can any one please help me 
>Thanks in advance
>  
>regards,
>Arun.N
>  


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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


Mime
View raw message