RE: [OT] How to do Xalan parsing of XML file retrieved with HTTP?

2004-07-01 Thread Kris Schneider
For JSTL 1.0 & JSP 1.2, the general idea would be:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml"; %>





Check out the JSTL spec for more details. You can also find some info here:

http://www-106.ibm.com/developerworks/java/library/j-jstl0520/
http://www.informit.com/articles/article.asp?p=30933
http://java.sun.com/developer/technicalArticles/javaserverpages/faster/

Apache provides JSTL 1.0 and JSTL 1.1 (for JSP 2.0) implementations under the
Jakarta Taglibs project. The Standard 1.0 taglib implements JSTL 1.0 while the
Standard 1.1 taglib implements JSTL 1.1. Feel free to post questions related to
JSTL and Standard to the taglibs-user list.

Quoting Robert Taylor <[EMAIL PROTECTED]>:

> Have you looked into using the JSTL XML core and transform tag libraries?
> I haven't used them yet, but they have tags which allow you 
> to parse and transform.
> 
> robert
> 
> > -Original Message-
> > From: Kransen, J. [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, July 01, 2004 4:47 AM
> > To: 'Struts Users Mailing List'
> > Subject: [OT] How to do Xalan parsing of XML file retrieved with HTTP?
> > 
> > 
> > Hello,
> > 
> > I have a .jsp that outputs a XML file. I have another .jsp in which I want
> > to parse the XML file using an XSL file. So in the latter .jsp I want to
> do
> > something like this:
> > 
> > <%
> > 
> > String xslFile = getServletContext().getRealPath("/xml/risc2cvs.xsl");
> > 
> > TransformerFactory tFactory = TransformerFactory.newInstance();
> > Transformer transformer = tFactory.newTransformer(new
> > StreamSource(xslFile));
> > 
> > // write the content of the parsed XML file
> > transformer.transform(new
> > StreamSource("http://localhost/risc/readonly.jsp";), new
> StreamResult(out));
> > 
> > %>
> > 
> > However, when I do this, I get the following error message:
> > 
> > The element type "base" must be terminated by the matching end-tag "".
> > 
> > With this stack trace:
> > javax.xml.transform.TransformerException: The element type "base" must be
> > terminated by the matching end-tag "".
> > at
> >
> org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java
> > :744)
> > at
> >
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
> > 720)
> > at
> >
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
> > 1192)
> > at
> >
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
> > 1170)
> > at
> >
> org.apache.jsp.cvs_005fuittreksel_jsp._jspService(cvs_005fuittreksel_jsp.jav
> > a:109)
> > ...
> > 
> > 
> > When instead I try to parse a local XML file, there are no problems:
> > String xmlFile = getServletContext().getRealPath("/xml/temp.xml");
> > transformer.transform(new StreamSource(xmlFile), new StreamResult(out));
> > 
> > But then, when I try to parse the very same file as accessed through HTTP,
> I
> > get the very same error:
> > transformer.transform(new
> > StreamSource("http://localhost/risc/xml/temp.xml";), new
> StreamResult(out));
> > 
> > I was thinking that maybe the HTTP headers aren't stripped before the
> > parsing. Does anybody know what to do here?
> > 
> > Thanks in advance!
> > 
> > Jeroen

-- 
Kris Schneider 
D.O.Tech   

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] How to do Xalan parsing of XML file retrieved with HTTP?

2004-07-01 Thread Robert Taylor
Have you looked into using the JSTL XML core and transform tag libraries?
I haven't used them yet, but they have tags which allow you 
to parse and transform.

robert

> -Original Message-
> From: Kransen, J. [mailto:[EMAIL PROTECTED]
> Sent: Thursday, July 01, 2004 4:47 AM
> To: 'Struts Users Mailing List'
> Subject: [OT] How to do Xalan parsing of XML file retrieved with HTTP?
> 
> 
> Hello,
> 
> I have a .jsp that outputs a XML file. I have another .jsp in which I want
> to parse the XML file using an XSL file. So in the latter .jsp I want to do
> something like this:
> 
> <%
> 
> String xslFile = getServletContext().getRealPath("/xml/risc2cvs.xsl");
> 
> TransformerFactory tFactory = TransformerFactory.newInstance();
> Transformer transformer = tFactory.newTransformer(new
> StreamSource(xslFile));
> 
> // write the content of the parsed XML file
> transformer.transform(new
> StreamSource("http://localhost/risc/readonly.jsp";), new StreamResult(out));
> 
> %>
> 
> However, when I do this, I get the following error message:
> 
> The element type "base" must be terminated by the matching end-tag "".
> 
> With this stack trace:
> javax.xml.transform.TransformerException: The element type "base" must be
> terminated by the matching end-tag "".
>   at
> org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java
> :744)
>   at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
> 720)
>   at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
> 1192)
>   at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
> 1170)
>   at
> org.apache.jsp.cvs_005fuittreksel_jsp._jspService(cvs_005fuittreksel_jsp.jav
> a:109)
> ...
> 
> 
> When instead I try to parse a local XML file, there are no problems:
> String xmlFile = getServletContext().getRealPath("/xml/temp.xml");
> transformer.transform(new StreamSource(xmlFile), new StreamResult(out));
> 
> But then, when I try to parse the very same file as accessed through HTTP, I
> get the very same error:
> transformer.transform(new
> StreamSource("http://localhost/risc/xml/temp.xml";), new StreamResult(out));
> 
> I was thinking that maybe the HTTP headers aren't stripped before the
> parsing. Does anybody know what to do here?
> 
> Thanks in advance!
> 
> Jeroen
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]