You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by JAMES VANETTEN <JV...@ALLMERICA.COM> on 2000/09/06 19:00:57 UTC
Viewing XML tags for demo
I am putting together a short XML demo page for my intranet developers. I am using xsp and sql to generate the xml and then applying a stylesheet:
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="sql"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="directory-html.xsl" type="text/xsl"?>
I am using the view-source.xml that came with the cocoon demos to allowing viewing of the source xml and xsl page but I also want to be able to view the resulting xml after the sql query and xsp processing. Is there an easy way to do this or do I have to create a stylesheet that simulates this.
Thanks
Jim
RE: Viewing XML tags for demo
Posted by Per Kreipke <pe...@onclave.com>.
In your example, if you comment out the line below, you should see the
unstyled XML data (e.g. your included file or your sql results):
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="sql"?>
<!-- <?cocoon-process type="xslt"?> Comment this line out to avoid styling
the doc -->
<?xml-stylesheet href="directory-html.xsl" type="text/xsl"?>
Per.
> I am putting together a short XML demo page for my intranet
> developers. I am using xsp and sql to generate the xml and then
> applying a stylesheet:
>
> <?xml version="1.0"?>
>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="sql"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="directory-html.xsl" type="text/xsl"?>
>
> I am using the view-source.xml that came with the cocoon demos to
> allowing viewing of the source xml and xsl page but I also want
> to be able to view the resulting xml after the sql query and xsp
> processing. Is there an easy way to do this or do I have to
> create a stylesheet that simulates this.
>
> Thanks
> Jim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
Re: Viewing XML tags for demo
Posted by Sylvain Wallez <wa...@free.fr>.
Donald Ball a écrit :
>
> On Wed, 6 Sep 2000, JAMES VANETTEN wrote:
>
> > I am putting together a short XML demo page for my intranet developers. I am using xsp and sql to generate the xml and then applying a stylesheet:
> >
> > <?xml version="1.0"?>
> >
> > <?cocoon-process type="xsp"?>
> > <?cocoon-process type="sql"?>
> > <?cocoon-process type="xslt"?>
> > <?xml-stylesheet href="directory-html.xsl" type="text/xsl"?>
> >
> > I am using the view-source.xml that came with the cocoon demos to
> > allowing viewing of the source xml and xsl page but I also want to be
> > able to view the resulting xml after the sql query and xsp processing.
> > Is there an easy way to do this or do I have to create a stylesheet
> > that simulates this.
>
> remove the cocoon-process type="xslt" PI. note if you're using xsp, you're
> strongly encouraged to use the sql logicsheet instead of the sql processor
> (or even better, the new esql logicsheet).
>
> - donald
To achieve the same result without removing <?cocoon-process
type="xslt"?> in all files, I wrote a special debugging XSLT processor
that checks the request for the special "_out" parameter.
Here's the code :
---------------------------------------------------------------------------------
import org.w3c.dom.*;
import org.apache.cocoon.processor.xslt.XSLTProcessor;
import java.util.Dictionary;
import javax.servlet.http.HttpServletRequest;
/**
A debugging replacement for Cocoon's XSLTProcessor in
cocoon.properties that dumps the input document
if the request contains "_out=xml". This allows to know what's
produced by XSP's before XSLT processing.
@author S. Wallez
*/
public class DebugXSLTProcessor extends XSLTProcessor
{
public Document process(Document document, Dictionary parameters)
throws Exception
{
HttpServletRequest request = (HttpServletRequest)
parameters.get("request");
if ("xml".equals(request.getParameter("_out")))
{
// Remove cocoon and stylesheet PI's
NodeList list = document.getChildNodes();
Node node;
// Backward iteration because removeChilds changes positions
in the list
for (int i = list.getLength()-1; i >= 0; i--)
{
node = list.item(i);
if (node.getNodeType() ==
Node.PROCESSING_INSTRUCTION_NODE)
{
document.removeChild(node);
}
}
// Add a new PI to dump in XML format.
document.appendChild(document.createProcessingInstruction("cocoon-format",
"type=\"text/xml\""));
return document;
}
else
{
// Just do the normal XSLT job
return super.process(document, parameters);
}
}
}
---------------------------------------------------------------------------------
Now just make this simple change in "cocoon.properties" :
#processor.type.xslt = org.apache.cocoon.processor.xslt.XSLTProcessor
processor.type.xslt = DebugXSLTProcessor
Now type "http://host/my_page.xml?_out=xml" in your browser et voilà (in
french :) you have your XSP result whithout XSL processing.
Hope this helps.
-Sylvain
Re: Viewing XML tags for demo
Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 6 Sep 2000, JAMES VANETTEN wrote:
> I am putting together a short XML demo page for my intranet developers. I am using xsp and sql to generate the xml and then applying a stylesheet:
>
> <?xml version="1.0"?>
>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="sql"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="directory-html.xsl" type="text/xsl"?>
>
> I am using the view-source.xml that came with the cocoon demos to
> allowing viewing of the source xml and xsl page but I also want to be
> able to view the resulting xml after the sql query and xsp processing.
> Is there an easy way to do this or do I have to create a stylesheet
> that simulates this.
remove the cocoon-process type="xslt" PI. note if you're using xsp, you're
strongly encouraged to use the sql logicsheet instead of the sql processor
(or even better, the new esql logicsheet).
- donald