You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Ray Allis <ra...@boeing.com> on 2001/06/19 23:38:50 UTC

xtags taglib - templates and copyOf

I am building a NewsML database application using JSP and XYZFind.
I'm stuck at handling the HTML (NITF) embedded in
/NewsML/NewsItem/NewsComponent/ContentItem/DataContent/body/body.content/

valueOf gives the text without the <p>, <b> etc. markup.  (Of course) 
Supposedly copyOf will copy elements and contents, but I can't get
beyond errors like "Not allowed to flush in custom tags" or similar.
template should do copyOf?  Nothing appears in the output.

I have read http://www.dpawson.co.uk/xsl/sect2/N4554.html, and I thought
I understood it.  The best I can do is select .../body.content/p and get
the (text of) the first paragraph.

Will someone please help me understand how this works?

------ newsitem.jsp ------

<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" 
prefix="xtags" %>
<html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; 
charset=ISO-8859-1">
     <title>RSS Styling Demo</title>
     <link rel="stylesheet" href="examples.css" type="text/css">
   </head>
   <body>

     <h2>Documents</h2>

     <xtags:parse>
       <io:http url="http://analogy.sea.boeing.com:1234" action="POST">
       <io:header name="Content-Type" value="text/xml"/>
       <io:pipe>
         <xyz:input xmlns:xyz="http://xyzfind.com/schemas/xyzql/1.0">
           <xyz:query>
             <xyz:document name="IndonesiaSummit.xml"/>
           </xyz:query>
         </xyz:input>
       </io:pipe>
       </io:http>
     </xtags:parse>

     <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
       <tr bgcolor="#dddddd">
         <th>Headline</th>
         <th>Dateline</th>
         <th>Body</th>
       </tr>

       <xtags:forEach select="//results/document/NewsItem/NewsComponent">
         <tr bgcolor="#eeeeee">
           <td>
           <xtags:valueOf select="NewsLines/HeadLine"/>
           </td>
           <td>
           <xtags:valueOf select="NewsLines/DateLine"/>
           </td>
           <td>
           <xtags:valueOf 
select="ContentItem/DataContent/body/body.content/p" />
           </td>
         </tr>
       </xtags:forEach>
     </table>
   </body>
</html>

Ray Allis - ray.allis@boeing.com


Re: xtags taglib - templates and copyOf

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi Ray

I'm glad its working :-)

From: "Ray Allis" <ra...@boeing.com>
> James Strachan wrote:
>
> > Hi Ray
> >
> > <xtags:copyOf> is the tag you want, this essentially outputs the XML of
the
> > nodes you select via XPath, with all markup intact.
> >
> > I've hit the problem of <xtags:copyOf> and "Not allowed to flush in
custom
> > tags" before. There was some code calling flush() in the XTags code (and
> > sometimes in the dom4j code) which I've patched recently. So maybe if
you
> > use the latest CVS image of the XTags library this problem might go
away?
>
> Thank you!  I was using xtags-20010511.tar.gz because that was the
> latest I could find on jakarta.apache.org last week.
>
> So, I downloaded xtags-20010620.tar.gz from jakarta.apache.org, put
> xtags-examples.war in jakarta-tomcat-4.0-b5/webapps/ and started tomcat.

Cool. I should really do a formal release soon.

> http://analogy.sea.boeing.com:8080/xtags-examples/index.jsp works,
> except the style demos...
>
> ClassNotFoundException: org.apache.xalan.processor.TransformerFactoryImpl

This sounds like a Xalan version issue. You could try a later version of
Xalan. (Have you any old ones tucked away in the dreaded jre/lib/ext?
You also need a 1.1 version of jaxp.jar but I'm assuming you have that in
your CLASSPATH to be able to find the Xalan processor.


> I have had these things all over the place.  Last successful setup had
> dom4j and log4j in /usr/java/jre/lib/ext (so I don't have to have them
> in -every- application.)  This messed me up this time because those
> were picked up rather than the newer ones in xtags-examples.

Agreed. I tend to avoid using jre/lib/ext as its easy to forget whats in
there (and how old the version is) and can be quite confusing when things
don't work.

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: xtags taglib - templates and copyOf

Posted by Ray Allis <ra...@boeing.com>.
James Strachan wrote:

> Hi Ray
> 
> <xtags:copyOf> is the tag you want, this essentially outputs the XML of the
> nodes you select via XPath, with all markup intact.
> 
> I've hit the problem of <xtags:copyOf> and "Not allowed to flush in custom
> tags" before. There was some code calling flush() in the XTags code (and
> sometimes in the dom4j code) which I've patched recently. So maybe if you
> use the latest CVS image of the XTags library this problem might go away?

Thank you!  I was using xtags-20010511.tar.gz because that was the 
latest I could find on jakarta.apache.org last week.

So, I downloaded xtags-20010620.tar.gz from jakarta.apache.org, put
xtags-examples.war in jakarta-tomcat-4.0-b5/webapps/ and started tomcat.

http://analogy.sea.boeing.com:8080/xtags-examples/index.jsp works, 
except the style demos...

ClassNotFoundException: org.apache.xalan.processor.TransformerFactoryImpl

So, now -my- application has:

jakarta-tomcat-4.0-b5/webapps/xmlnews/WEB-INF/lib
-rw-r--r--   1 ray      staff     187162 Jun 20 15:36 crimson.jar
-rw-r--r--   1 ray      staff     409380 Jun 20 14:53 dom4j.jar
-rw-r--r--   1 ray      staff      10998 Jun 19 20:21 input.jar
-rw-r--r--   1 ray      staff      20643 Jun 15 10:02 io.jar
-rw-r--r--   1 ray      staff      92132 Jun 20 14:53 log4j-core.jar
-rw-r--r--   1 ray      staff     436249 Jun 20 14:54 xalan.jar
-rw-r--r--   1 ray      staff      76332 Jun 20 14:54 xtags.jar

and my application seems to work!


<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" 
prefix="xtags" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/input-0.90" 
prefix="input" %>
<html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; 
charset=ISO-8859-1">
     <title>Eventually, display news item</title>
     <link rel="stylesheet" href="examples.css" type="text/css">
   </head>
   <body>

     <h2>Documents</h2>

   <xtags:parse>
     <io:http url="http://analogy.sea.boeing.com:1234" action="POST">
     <io:header name="Content-Type" value="text/xml"/>
     <io:pipe>
       <xyz:input xmlns:xyz="http://xyzfind.com/schemas/xyzql/1.0">
         <xyz:query>
           <xyz:document name="IndonesiaSummit.xml"/>
         </xyz:query>
       </xyz:input>
     </io:pipe>
     </io:http>
   </xtags:parse>

     <form method="post" >
       <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
         <tr bgcolor="#dddddd">
           <th>Headline</th>
           <th>Dateline</th>
           <th>Body</th>
         </tr>

       <xtags:forEach select="//results/document/NewsItem/NewsComponent">
         <tr bgcolor="#eeeeee">
           <td>
             <xtags:valueOf select="NewsLines/HeadLine"/>
           </td>
           <td>
             <xtags:valueOf select="NewsLines/DateLine"/>
           </td>
           <td>
             <xtags:copyOf 
select="ContentItem/DataContent/body/body.content" />
           </td>
         </tr>
         <tr>
           <td colspan="3">
             <input:textarea name="words" default="DEFAULT" />
           </td>
         </tr>
       </xtags:forEach>
       </table>
     </form>
   </body>
</html>

I have had these things all over the place.  Last successful setup had
dom4j and log4j in /usr/java/jre/lib/ext (so I don't have to have them
in -every- application.)  This messed me up this time because those
were picked up rather than the newer ones in xtags-examples.

Thank you again.

Ray Allis


unsubscribe me: weiguo@orbitalsw.com

Posted by Chris Twardowski <ch...@orbitalsw.com>.
unsubscribe me: weiguo@orbitalsw.com

-----Original Message-----
From: James Strachan [mailto:james_strachan@yahoo.co.uk]
Sent: Wednesday, June 20, 2001 8:01 AM
To: taglibs-user@jakarta.apache.org
Subject: Re: xtags taglib - templates and copyOf


Hi Ray

From: "Ray Allis" <ra...@boeing.com>
> I am building a NewsML database application using JSP and XYZFind.
> I'm stuck at handling the HTML (NITF) embedded in
> /NewsML/NewsItem/NewsComponent/ContentItem/DataContent/body/body.content/
>
> valueOf gives the text without the <p>, <b> etc. markup.  (Of course)
> Supposedly copyOf will copy elements and contents, but I can't get
> beyond errors like "Not allowed to flush in custom tags" or similar.
> template should do copyOf?  Nothing appears in the output.

You're right. <xtags:valueOf> returns the string-value of an XPath
expression (defined in the XPath spec) so it will strip all markup and just
return text.

<xtags:copyOf> is the tag you want, this essentially outputs the XML of the
nodes you select via XPath, with all markup intact.

I've hit the problem of <xtags:copyOf> and "Not allowed to flush in custom
tags" before. There was some code calling flush() in the XTags code (and
sometimes in the dom4j code) which I've patched recently. So maybe if you
use the latest CVS image of the XTags library this problem might go away?

If this doesn't fix your problem it might be something to do with your
Servlet container. Which Servlet container are you using? It might be that
you are hitting a JSP 1.1 issue. Its quite hard to build really useful JSP
custom tags on JSP 1.1 due to the body tag issue - the only way to do loops
in JSP 1.1 is to use body tags and inside body tags in JSP 1.1 you can't
properly do <jsp:include> calls or flush the output. e.g. <xtags:forEach>
has to be a body tag in JSP 1.1 so anything inside your loop is in a body
tag which may cause problems with tags like <xtags:copyOf>).

It might be worth trying out your web app on Tomcat 4.0 which has full
support for JSP 1.2 or WebLogic 6.1 (which I think has JSP 1.2 support also)

James

>
> I have read http://www.dpawson.co.uk/xsl/sect2/N4554.html, and I thought
> I understood it.  The best I can do is select .../body.content/p and get
> the (text of) the first paragraph.
>
> Will someone please help me understand how this works?
>
> ------ newsitem.jsp ------
>
> <%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
> <%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0"
> prefix="xtags" %>
> <html>
>    <head>
>      <meta http-equiv="Content-Type" content="text/html;
> charset=ISO-8859-1">
>      <title>RSS Styling Demo</title>
>      <link rel="stylesheet" href="examples.css" type="text/css">
>    </head>
>    <body>
>
>      <h2>Documents</h2>
>
>      <xtags:parse>
>        <io:http url="http://analogy.sea.boeing.com:1234" action="POST">
>        <io:header name="Content-Type" value="text/xml"/>
>        <io:pipe>
>          <xyz:input xmlns:xyz="http://xyzfind.com/schemas/xyzql/1.0">
>            <xyz:query>
>              <xyz:document name="IndonesiaSummit.xml"/>
>            </xyz:query>
>          </xyz:input>
>        </io:pipe>
>        </io:http>
>      </xtags:parse>
>
>      <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
>        <tr bgcolor="#dddddd">
>          <th>Headline</th>
>          <th>Dateline</th>
>          <th>Body</th>
>        </tr>
>
>        <xtags:forEach select="//results/document/NewsItem/NewsComponent">
>          <tr bgcolor="#eeeeee">
>            <td>
>            <xtags:valueOf select="NewsLines/HeadLine"/>
>            </td>
>            <td>
>            <xtags:valueOf select="NewsLines/DateLine"/>
>            </td>
>            <td>
>            <xtags:valueOf
> select="ContentItem/DataContent/body/body.content/p" />
>            </td>
>          </tr>
>        </xtags:forEach>
>      </table>
>    </body>
> </html>
>
> Ray Allis - ray.allis@boeing.com
>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




xsl taglib

Posted by Tung Tran <tu...@yahoo.com>.
this is the error when i tried to run Apply.jsp from
the example.  please help.


Error: 500
Location: /xsl-examples/jsp/Apply.jsp
Internal Servlet Error:

javax.servlet.ServletException:
org.xml.sax.SAXException: SAX Exception
	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
	at
jsp._0002fjsp_0002fApply_0002ejspApply_jsp_1._jspService(_0002fjsp_0002fApply_0002ejspApply_jsp_1.java:265)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
	at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
	at
org.apache.tomcat.core.Handler.service(Handler.java:287)
	at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
	at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
	at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
	at java.lang.Thread.run(Thread.java:484)

Root cause: 
javax.servlet.jsp.JspException:
org.xml.sax.SAXException: SAX Exception
	at
org.apache.taglibs.xsl.ApplyTag.doEndTag(ApplyTag.java:274)
	at
jsp._0002fjsp_0002fApply_0002ejspApply_jsp_1._jspService(_0002fjsp_0002fApply_0002ejspApply_jsp_1.java:87)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
	at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
	at
org.apache.tomcat.core.Handler.service(Handler.java:287)
	at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
	at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
	at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
	at java.lang.Thread.run(Thread.java:484)



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: xtags taglib - templates and copyOf

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi Ray

From: "Ray Allis" <ra...@boeing.com>
> I am building a NewsML database application using JSP and XYZFind.
> I'm stuck at handling the HTML (NITF) embedded in
> /NewsML/NewsItem/NewsComponent/ContentItem/DataContent/body/body.content/
>
> valueOf gives the text without the <p>, <b> etc. markup.  (Of course)
> Supposedly copyOf will copy elements and contents, but I can't get
> beyond errors like "Not allowed to flush in custom tags" or similar.
> template should do copyOf?  Nothing appears in the output.

You're right. <xtags:valueOf> returns the string-value of an XPath
expression (defined in the XPath spec) so it will strip all markup and just
return text.

<xtags:copyOf> is the tag you want, this essentially outputs the XML of the
nodes you select via XPath, with all markup intact.

I've hit the problem of <xtags:copyOf> and "Not allowed to flush in custom
tags" before. There was some code calling flush() in the XTags code (and
sometimes in the dom4j code) which I've patched recently. So maybe if you
use the latest CVS image of the XTags library this problem might go away?

If this doesn't fix your problem it might be something to do with your
Servlet container. Which Servlet container are you using? It might be that
you are hitting a JSP 1.1 issue. Its quite hard to build really useful JSP
custom tags on JSP 1.1 due to the body tag issue - the only way to do loops
in JSP 1.1 is to use body tags and inside body tags in JSP 1.1 you can't
properly do <jsp:include> calls or flush the output. e.g. <xtags:forEach>
has to be a body tag in JSP 1.1 so anything inside your loop is in a body
tag which may cause problems with tags like <xtags:copyOf>).

It might be worth trying out your web app on Tomcat 4.0 which has full
support for JSP 1.2 or WebLogic 6.1 (which I think has JSP 1.2 support also)

James

>
> I have read http://www.dpawson.co.uk/xsl/sect2/N4554.html, and I thought
> I understood it.  The best I can do is select .../body.content/p and get
> the (text of) the first paragraph.
>
> Will someone please help me understand how this works?
>
> ------ newsitem.jsp ------
>
> <%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
> <%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0"
> prefix="xtags" %>
> <html>
>    <head>
>      <meta http-equiv="Content-Type" content="text/html;
> charset=ISO-8859-1">
>      <title>RSS Styling Demo</title>
>      <link rel="stylesheet" href="examples.css" type="text/css">
>    </head>
>    <body>
>
>      <h2>Documents</h2>
>
>      <xtags:parse>
>        <io:http url="http://analogy.sea.boeing.com:1234" action="POST">
>        <io:header name="Content-Type" value="text/xml"/>
>        <io:pipe>
>          <xyz:input xmlns:xyz="http://xyzfind.com/schemas/xyzql/1.0">
>            <xyz:query>
>              <xyz:document name="IndonesiaSummit.xml"/>
>            </xyz:query>
>          </xyz:input>
>        </io:pipe>
>        </io:http>
>      </xtags:parse>
>
>      <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
>        <tr bgcolor="#dddddd">
>          <th>Headline</th>
>          <th>Dateline</th>
>          <th>Body</th>
>        </tr>
>
>        <xtags:forEach select="//results/document/NewsItem/NewsComponent">
>          <tr bgcolor="#eeeeee">
>            <td>
>            <xtags:valueOf select="NewsLines/HeadLine"/>
>            </td>
>            <td>
>            <xtags:valueOf select="NewsLines/DateLine"/>
>            </td>
>            <td>
>            <xtags:valueOf
> select="ContentItem/DataContent/body/body.content/p" />
>            </td>
>          </tr>
>        </xtags:forEach>
>      </table>
>    </body>
> </html>
>
> Ray Allis - ray.allis@boeing.com
>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com