Re: including xml dynamically from a string

2001-11-27 Thread David Rosenstrauch

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-exprutil:exprxsp:exprxml/xsp:expr/util:expr/util:include-expr

xsp:exprxml/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
headingdynamic/heading
   xsp:logic  
String xml = (String)request.getAttribute(xml); ( This will return a XML 
format string  like  folders folderInbox/folder folderBulk 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
headingdynamic/heading
 folders
 folderInbox/folder
 folderBulk 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/Corehttp://www.apache.org/1999/XSP/Core;
   
xmlns:request=http://www.apache.org/1999/XSP/Requesthttp://www.apache.org/1999/XSP/Request;
   
xmlns:util=http://www.apache.org/1999/XSP/Utilhttp://www.apache.org/1999/XSP/Util;
   create-session=true
   
page
   body
center
headingdynamic/heading
   xsp:logic  
String xml = (String)request.getAttribute(xml); ( This willreturn a XML 
format string  like  folders folderInbox/folder folderBulk 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




including xml dynamically from a string

2001-11-26 Thread Arun.N



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
pagebodyheadingdynamic/headingxsp:logicString 
xml = (String)request.getAttribute("xml"); ( This will return a XML 
format string like " folders folderInbox/folder 
folderBulk 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.
pagebodycenterheadingdynamic/heading
  
folders
  
 folderInbox/folder
  
 folderBulk 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 
topopulate 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" 
pagebodycenterheadingdynamic/headingxsp:logicString 
xml = (String)request.getAttribute("xml"); ( This willreturn a XML 
format string like " folders folderInbox/folder 
folderBulk 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