tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter.Burg...@tietoenator.com
Subject RE: Very Basic Help
Date Tue, 09 Jul 2002 14:37:51 GMT


-----Original Message-----
From: Ben Ramsey [mailto:ben@eureka-interactive.com]
Sent: 09 July 2002 16:36
To: Tag Libraries Users List
Subject: RE: Very Basic Help


If I were you, I'd look into using XTAGS.  I had numerous problems using the
XSL 1.0 tag library to transform XML with XSL.  Plus, whenever I've looked
for help with the XSL tag library, all sources seem to point to using XTAGS
instead.

I tried:
<xsl:apply xml="file.xml" xsl="file.xsl"/>

But that gave me errors.  Then, I tried:
<xtags:style xml="file.xml" xsl="file.xsl"/>

Still more problems!

Then again, my problems could be caused by my use of Cobalt's packaged JSDK
and Tomcat.  The package uses versions 1.3.1 and 3.2.3, respectively.  Thus,
I'm not even sure my JSP container is at 1.2, which could be what's causing
my problems.

However, when I used XTAGS as my stylesheet instead of a separate XSL file,
all worked well:

<%@ taglib uri="/WEB-INF/tlds/xtags.tld" prefix="xtags" %>

<xtags:parse uri="file.xml"/>
<xtags:stylesheet>
  <xtags:template match="/">
    <p class="byline"><xtags:valueOf select="article/author"/></p>
    <p class="artcopy"><xtags:valueOf select="article/body"/></p>
  </xtags:template>
</xtags:stylesheet>

The cool part about using xtags to transform your XML is that you can
dynamically alter your stylesheet.  For example, say you had 100 or so
ARTICLEs in your XML file.  Each ARTICLE has a unique id.  If you pass the
id number through the querystring, you can build an XPath statement to pull
only one record:

<%
  String matchNode = "/article[@id='" + request.getParameter("id") + "']";
%>
<xtags:template match="<%= matchNode %>">

The problem I found with this, however, is that xtags isn't working in quite
the way that XSL andXPath is supposed to work.  All the other records will
be returned with your data--they just won't be formatted.  So, I've had to
add this code to take care of that problem:

<%
  String removeNodes = "/article[not(@id='" + request.getParameter("id") +
"')]";
%>
<xtags:remove match="<%= removeNodes %>"/>

Place the remove command just below the parse command.

Does anyone else have this same problem?  If not, please tell me what I'm
doing wrong so that I can minimize my code.


Ben Ramsey
Technical Director
EUREKA! Interactive, Inc.
770-642-0390
www.eureka-interactive.com


--
To unsubscribe, e-mail:
<mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:taglibs-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message