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"
  xmlns:request="
http://www.apache.org/1999/XSP/Request"
  xmlns: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
 

Reply via email to