You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by js...@apache.org on 2001/05/07 13:13:33 UTC
cvs commit: jakarta-taglibs/xtags/xml xtags.xml
jstrachan 01/05/07 04:13:32
Modified: xtags/conf xtags.tld
xtags/doc/web intro.xml xtags.html
xtags/examples/conf web.xml
xtags/examples/web hello_rss.jsp much_ado.jsp
periodic_table.jsp periodic_table2.jsp
simple_rss.jsp stock_quote.jsp test_context.jsp
xpath_wizard.jsp
xtags/examples/web/style styledemo3.jsp
xtags/examples/web/test test_param.jsp
xtags/src/org/apache/taglibs/xtags/tags ParseTag.java
xtags/xml xtags.xml
Removed: xtags/src/org/apache/taglibs/xtags/tags DocumentTag.java
Log:
Merged <xtags:document> and <xtags:parse> into the same tag for simplicity. It now no longer requires nesting of <xtags:forEach> tags within it. Also the <xtags:valueOf> and <xtags:variable> all now take a consistent context variable name
Revision Changes Path
1.2 +11 -16 jakarta-taglibs/xtags/conf/xtags.tld
Index: xtags.tld
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/conf/xtags.tld,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xtags.tld 2001/05/05 18:06:19 1.1
+++ xtags.tld 2001/05/07 11:11:45 1.2
@@ -9,16 +9,17 @@
<shortname>xtags</shortname>
<uri>/WEB-INF/xtags.tld</uri>
<tag>
-<name>document</name>
-<tagclass>org.apache.taglibs.xtags.tags.DocumentTag</tagclass>
+<name>parse</name>
+<tagclass>org.apache.taglibs.xtags.tags.ParseTag</tagclass>
+<teiclass>org.apache.taglibs.xtags.tags.ParseTagExtraInfo</teiclass>
<bodycontent>JSP</bodycontent>
<attribute>
-<name>uri</name>
+<name>name</name>
<required>false</required>
-<rtexprvalue>true</rtexprvalue>
+<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
-<name>name</name>
+<name>uri</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
@@ -29,17 +30,6 @@
</attribute>
</tag>
<tag>
-<name>parse</name>
-<tagclass>org.apache.taglibs.xtags.tags.ParseTag</tagclass>
-<teiclass>org.apache.taglibs.xtags.tags.ParseTagExtraInfo</teiclass>
-<bodycontent>JSP</bodycontent>
-<attribute>
-<name>name</name>
-<required>false</required>
-<rtexprvalue>false</rtexprvalue>
-</attribute>
-</tag>
-<tag>
<name>valueOf</name>
<tagclass>org.apache.taglibs.xtags.tags.ValueOfTag</tagclass>
<bodycontent>empty</bodycontent>
@@ -288,6 +278,11 @@
<attribute>
<name>select</name>
<required>true</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
+<name>context</name>
+<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
1.2 +3 -1 jakarta-taglibs/xtags/doc/web/intro.xml
Index: intro.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/doc/web/intro.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- intro.xml 2001/05/05 18:06:21 1.1
+++ intro.xml 2001/05/07 11:11:54 1.2
@@ -18,10 +18,12 @@
</p>
<p>In many ways XTags is like XSLT implemented in JSP allowing you to
seamlessly work with JSP, custom tags, JavaBeans and the whole
- J2EE platform from inside in your stylesheets.
+ J2EE platform from inside a single piece of JSP!
</p>
<p>XTags is currently built on top of <a href="http://dom4j.org">dom4j</a> the
flexible open source XML framework for the Java platform.
+ Though increasingly XTags will use a pluggable XPath engine to support
+ the travesal of DOM and Java Beans too.
</p>
</section>
1.2 +25 -77 jakarta-taglibs/xtags/doc/web/xtags.html
Index: xtags.html
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/doc/web/xtags.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xtags.html 2001/05/05 18:06:21 1.1
+++ xtags.html 2001/05/07 11:11:57 1.2
@@ -30,9 +30,18 @@
<br>
<a name="overview"></a>
<h3>Overview</h3>
-<p>The <xtags> tag library implements an XSLT-like JSP tag library
+<p>The XTags tag library implements an XSLT-like JSP tag library
to allow navigating, processing and styling of XML documents directly in JSP.
</p>
+<p>In many ways XTags is like XSLT implemented in JSP allowing you to
+ seamlessly work with JSP, custom tags, JavaBeans and the whole
+ J2EE platform from inside a single piece of JSP!
+ </p>
+<p>XTags is currently built on top of <a href="http://dom4j.org">dom4j</a> the
+ flexible open source XML framework for the Java platform.
+ Though increasingly XTags will use a pluggable XPath engine to support
+ the travesal of DOM and Java Beans too.
+ </p>
<a name="requirements"></a>
<h3>Requirements</h3>
<p>
@@ -70,12 +79,9 @@
<h3>Tag Summary</h3>
<table summary="summary list of tags with short description of each.">
<tr>
-<td><a href="#document">document</a></td><td>Parses the given document and defines the current context node as the document</td>
+<td><a href="#parse">parse</a></td><td>Parsers some XML either from a given URL or from the body of this tag</td>
</tr>
<tr>
-<td><a href="#parse">parse</a></td><td>Parsers a piece of xml from the body of the tag</td>
-</tr>
-<tr>
<td><a href="#valueOf">valueOf</a></td><td>Evaluates the given XPath expression on the current context node and outputs the result as text</td>
</tr>
<tr>
@@ -141,19 +147,19 @@
<td colspan="2">
<table summary="name and tag library version availability of tag." cellspacing="0" width="100%" bgcolor="#cccccc" border="0">
<tr>
-<td><b><font size="+1"><a name="document">document</a></font></b></td><td align="right">Availability: version 1.0</td>
+<td><b><font size="+1"><a name="parse">parse</a></font></b></td><td align="right">Availability: version 1.0</td>
</tr>
</table>
</td>
</tr>
<tr>
-<td colspan="2">Parses the given document and defines the current context node as the document</td>
+<td colspan="2">Parsers some XML either from a given URL or from the body of this tag</td>
</tr>
<tr>
<td width="2%"> </td><td width="98%">
<table summary="Tag class, tag name, script variable (if any), and restrictions (if any)." width="100%" border="0">
<tr>
-<td width="20%"><span class="tclass">Tag Class</span></td><td width="80%">org.apache.taglibs.xtags.tags.DocumentTag</td>
+<td width="20%"><span class="tclass">Tag Class</span></td><td width="80%">org.apache.taglibs.xtags.tags.ParseTag</td>
</tr>
<tr>
<td width="20%"><span class="tbody">Tag Body</span></td><td width="80%">JSP</td>
@@ -174,13 +180,13 @@
<td width="40%">Name</td><td width="20%">Required</td><td width="40%">Runtime Expression Evaluation</td>
</tr>
<tr bgcolor="#cccccc">
-<td width="40%"><b>uri</b></td><td width="20%">false</td><td width="40%">true</td>
+<td width="40%"><b>name</b></td><td width="20%">false</td><td width="40%">false</td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr bgcolor="#cccccc">
-<td width="40%"><b>name</b></td><td width="20%">false</td><td width="40%">true</td>
+<td width="40%"><b>uri</b></td><td width="20%">false</td><td width="40%">true</td>
</tr>
<tr>
<td colspan="3"></td>
@@ -202,74 +208,10 @@
--%></span>
<br>
<p>
-<code>
- <xtags:document uri="foo/bar.xml"/>
- </code>
-</p>
-</li>
-</ol>
-</td>
-</tr>
-</table>
-</td>
-</tr>
-</table>
-<table summary="This table is for visual formatting of tag reference information." cellspacing="0" cellpadding="3" width="90%" border="0">
-<tr>
-<td colspan="2">
-<table summary="name and tag library version availability of tag." cellspacing="0" width="100%" bgcolor="#cccccc" border="0">
-<tr>
-<td><b><font size="+1"><a name="parse">parse</a></font></b></td><td align="right">Availability: version 1.0</td>
-</tr>
-</table>
-</td>
-</tr>
-<tr>
-<td colspan="2">Parsers a piece of xml from the body of the tag</td>
-</tr>
-<tr>
-<td width="2%"> </td><td width="98%">
-<table summary="Tag class, tag name, script variable (if any), and restrictions (if any)." width="100%" border="0">
-<tr>
-<td width="20%"><span class="tclass">Tag Class</span></td><td width="80%">org.apache.taglibs.xtags.tags.ParseTag</td>
-</tr>
-<tr>
-<td width="20%"><span class="tbody">Tag Body</span></td><td width="80%">JSP</td>
-</tr>
-<tr>
-<td width="20%"><span class="scriptvar">Script Variable</span></td><td width="80%">If the name attribute is set the variable with that name will be defined</td>
-</tr>
-<tr>
-<td width="20%"><span class="restrictions">Restrictions</span></td><td width="80%"></td>
-</tr>
-<tr>
-<td width="20%"><span class="attributes">Attributes</span></td><td width="80%"> </td>
-</tr>
-<tr>
-<td width="20%"> </td><td width="80%">
-<table summary="Tag attribute name, whether required, and whether rtexprvalue allowed." width="100%" border="0">
-<tr>
-<td width="40%">Name</td><td width="20%">Required</td><td width="40%">Runtime Expression Evaluation</td>
-</tr>
-<tr bgcolor="#cccccc">
-<td width="40%"><b>name</b></td><td width="20%">false</td><td width="40%">false</td>
-</tr>
-<tr>
-<td colspan="3"></td>
-</tr>
-</table>
-</td>
-</tr>
-<tr>
-<td valign="top" width="20%"><span class="example">Example</span></td><td width="80%">
-<ol>
-<li>
-<span class="comment"><%--
- --%></span>
-<br>
-<p>
<code>
-<xtags:parse name="myDoc">
+<xtags:parse name="doc1" url="foo/bar.xml"/>
+
+<xtags:parse name="doc2">
<root>
<author firstName="James" surname="Strachan"/>
</root>
@@ -1359,6 +1301,12 @@
</tr>
<tr bgcolor="#cccccc">
<td width="40%"><b>select</b></td><td width="20%">true</td><td width="40%">true</td>
+</tr>
+<tr>
+<td colspan="3"></td>
+</tr>
+<tr bgcolor="#cccccc">
+<td width="40%"><b>context</b></td><td width="20%">false</td><td width="40%">true</td>
</tr>
<tr>
<td colspan="3"></td>
1.2 +1 -1 jakarta-taglibs/xtags/examples/conf/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/conf/web.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- web.xml 2001/05/05 18:06:22 1.1
+++ web.xml 2001/05/07 11:12:07 1.2
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
- <display-name><xtags> Taglib</display-name>
+ <display-name>XTags Taglib</display-name>
<description>A JSP custom tag library for working with XML, XPath and XSLT.</description>
1.2 +8 -9 jakarta-taglibs/xtags/examples/web/hello_rss.jsp
Index: hello_rss.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/hello_rss.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hello_rss.jsp 2001/05/05 18:06:23 1.1
+++ hello_rss.jsp 2001/05/07 11:12:14 1.2
@@ -11,18 +11,17 @@
<h1>Hello RSS Demo</h1>
<ul>
-<xtags:document uri="http://p.moreover.com/cgi-local/page?c=Java%20news&o=rss">
- <xtags:forEach select="//item">
+<xtags:parse uri="http://p.moreover.com/cgi-local/page?c=Java%20news&o=rss"/>
+<xtags:forEach select="//item">
<xtags:variable name="url" type="string" select="link"/>
<li>
- <a href="<%= url %>">
- <xtags:valueOf select="title"/>
- </a>
- -
- <xtags:valueOf select="description"/>
+ <a href="<%= url %>">
+ <xtags:valueOf select="title"/>
+ </a>
+ -
+ <xtags:valueOf select="description"/>
</li>
- </xtags:forEach>
-</xtags:document>
+</xtags:forEach>
</ul>
</body>
1.2 +43 -45 jakarta-taglibs/xtags/examples/web/much_ado.jsp
Index: much_ado.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/much_ado.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- much_ado.jsp 2001/05/05 18:06:23 1.1
+++ much_ado.jsp 2001/05/07 11:12:16 1.2
@@ -7,62 +7,60 @@
</head>
<body>
-<xtags:document uri="much_ado.xml">
+<xtags:parse uri="much_ado.xml"/>
- <h1><xtags:valueOf select="/PLAY/TITLE"/></h1>
+<h1><xtags:valueOf select="/PLAY/TITLE"/></h1>
- <xtags:forEach select="/PLAY/ACT">
+<xtags:forEach select="/PLAY/ACT">
- <h2><xtags:valueOf select="TITLE"/></h2>
+ <h2><xtags:valueOf select="TITLE"/></h2>
- <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
-
- <xtags:forEach select="SCENE" name="scene">
- <xtags:variable name="title" select="TITLE/text()"/>
-
- <tr bgcolor="#dddddd">
- <td>Scene</td>
- <td><b><%= title %></b></td>
- </tr>
- <tr bgcolor="#eeeeee">
- <td valign="top">Speakers</td>
- <td>
-
- <xtags:forEach select="SPEECH/SPEAKER" sort="." distinct="true" name="speaker">
-
- <xtags:choose>
- <xtags:when test=".='HERO'">
- <b><xtags:valueOf select="."/></b>
- Our hero! in scene: <%= title %>
- </xtags:when>
- <xtags:otherwise>
- <xtags:valueOf select="."/>
- </xtags:otherwise>
- </xtags:choose>
-
- <xtags:if test=".='Messenger'">.
- This is act
- <xtags:valueOf select="../../../TITLE"/>
+ <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
+
+ <xtags:forEach select="SCENE" name="scene">
+ <xtags:variable name="title" select="TITLE/text()"/>
+
+ <tr bgcolor="#dddddd">
+ <td>Scene</td>
+ <td><b><%= title %></b></td>
+ </tr>
+ <tr bgcolor="#eeeeee">
+ <td valign="top">Speakers</td>
+ <td>
+
+ <xtags:forEach select="SPEECH/SPEAKER" sort="." distinct="true" name="speaker">
+
+ <xtags:choose>
+ <xtags:when test=".='HERO'">
+ <b><xtags:valueOf select="."/></b>
+ Our hero! in scene: <%= title %>
+ </xtags:when>
+ <xtags:otherwise>
+ <xtags:valueOf select="."/>
+ </xtags:otherwise>
+ </xtags:choose>
+
+ <xtags:if test=".='Messenger'">.
+ This is act
+ <xtags:valueOf select="../../../TITLE"/>
<%--
- The following breaks on Tomcat 4.0.b3 due to setting property
- of type Object with a String value.
+ The following breaks on Tomcat 4.0.b3 due to setting property
+ of type Object with a String value.
- <xtags:valueOf select="../TITLE" context="<%= scene %>"/>
+ <xtags:valueOf select="../TITLE" context="<%= scene %>"/>
--%>
- </xtags:if>
+ </xtags:if>
- <br>
- </xtags:forEach>
+ <br>
+ </xtags:forEach>
- </td>
- </tr>
- </xtags:forEach>
+ </td>
+ </tr>
+ </xtags:forEach>
- </table>
+ </table>
- </xtags:forEach>
-
-</xtags:document>
+</xtags:forEach>
</body>
</html>
1.2 +11 -13 jakarta-taglibs/xtags/examples/web/periodic_table.jsp
Index: periodic_table.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/periodic_table.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- periodic_table.jsp 2001/05/05 18:06:23 1.1
+++ periodic_table.jsp 2001/05/07 11:12:19 1.2
@@ -12,23 +12,21 @@
<p>This example demonstrates the direct use of the XPath tag library to format an XML document.</p>
-<xtags:document uri="periodic_table.xml">
+<xtags:parse uri="periodic_table.xml"/>
- <xtags:forEach select="//ATOM">
+<xtags:forEach select="//ATOM">
- <h2><xtags:valueOf select="NAME"/> : <xtags:valueOf select="SYMBOL"/></h2>
+ <h2><xtags:valueOf select="NAME"/> : <xtags:valueOf select="SYMBOL"/></h2>
- <p>
- The atom has an atomic weight of
- <b> <xtags:valueOf select="ATOMIC_WEIGHT"/> </b>
+ <p>
+ The atom has an atomic weight of
+ <b> <xtags:valueOf select="ATOMIC_WEIGHT"/> </b>
- and a boiling point of
- <b> <xtags:valueOf select="BOILING_POINT"/> </b>
- <xtags:valueOf select="BOILING_POINT/@UNITS"/>
- </p>
- </xtags:forEach>
-
-</xtags:document>
+ and a boiling point of
+ <b> <xtags:valueOf select="BOILING_POINT"/> </b>
+ <xtags:valueOf select="BOILING_POINT/@UNITS"/>
+ </p>
+</xtags:forEach>
</body>
</html>
1.2 +3 -2 jakarta-taglibs/xtags/examples/web/periodic_table2.jsp
Index: periodic_table2.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/periodic_table2.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- periodic_table2.jsp 2001/05/05 18:06:23 1.1
+++ periodic_table2.jsp 2001/05/07 11:12:22 1.2
@@ -7,10 +7,11 @@
</head>
<body>
-<xtags:parse name="doc">
+<%-- This example demonstrates that the body can be parsed --%>
+<%-- if no URL is specified --%>
+<xtags:parse name="doc">
<%@ include file="periodic_table.xml" %>
</xtags:parse>
-
<xtags:variable select="count(//ATOM)" name="count" type="Number"/>
1.2 +32 -32 jakarta-taglibs/xtags/examples/web/simple_rss.jsp
Index: simple_rss.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/simple_rss.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- simple_rss.jsp 2001/05/05 18:06:23 1.1
+++ simple_rss.jsp 2001/05/07 11:12:24 1.2
@@ -13,41 +13,41 @@
<p>This demo is created by querying an RSS source and formatting the XML returned.</p>
-<xtags:document uri="http://p.moreover.com/cgi-local/page?c=Java%20news&o=rss">
- <xtags:forEach select="rss/channel">
- <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
- <tr bgcolor="#dddddd">
+<xtags:parse uri="http://p.moreover.com/cgi-local/page?c=Java%20news&o=rss"/>
+
+<xtags:forEach select="rss/channel">
+ <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
+ <tr bgcolor="#dddddd">
+ <td>
+ <b>
+ <xtags:valueOf select="title"/>
+ </b>
+
+ <xtags:forEach select="image">
+ <xtags:element name="img">
+ <xtags:attribute name="src"><xtags:valueOf select="url"/></xtags:attribute>
+ <xtags:attribute name="width"><xtags:valueOf select="width"/></xtags:attribute>
+ <xtags:attribute name="height"><xtags:valueOf select="height"/></xtags:attribute>
+ <xtags:attribute name="alt"><xtags:valueOf select="title"/></xtags:attribute>
+ </xtags:element>
+ </xtags:forEach>
+ </td>
+ </tr>
+ <xtags:forEach select="item">
+ <tr bgcolor="#eeeeee">
<td>
- <b>
- <xtags:valueOf select="title"/>
- </b>
-
- <xtags:forEach select="image">
- <xtags:element name="img">
- <xtags:attribute name="src"><xtags:valueOf select="url"/></xtags:attribute>
- <xtags:attribute name="width"><xtags:valueOf select="width"/></xtags:attribute>
- <xtags:attribute name="height"><xtags:valueOf select="height"/></xtags:attribute>
- <xtags:attribute name="alt"><xtags:valueOf select="title"/></xtags:attribute>
- </xtags:element>
- </xtags:forEach>
+ <xtags:variable name="url" type="string" select="link"/>
+ <a href="<%= url %>"><xtags:valueOf select="title"/></a>
</td>
</tr>
- <xtags:forEach select="item">
- <tr bgcolor="#eeeeee">
- <td>
- <xtags:variable name="url" type="string" select="link"/>
- <a href="<%= url %>"><xtags:valueOf select="title"/></a>
- </td>
- </tr>
- <tr bgcolor="#eeeeee">
- <td>
- <xtags:valueOf select="description"/>
- </td>
- </tr>
- </xtags:forEach>
- </table>
- </xtags:forEach>
-</xtags:document>
+ <tr bgcolor="#eeeeee">
+ <td>
+ <xtags:valueOf select="description"/>
+ </td>
+ </tr>
+ </xtags:forEach>
+ </table>
+</xtags:forEach>
</body>
</html>
1.2 +46 -48 jakarta-taglibs/xtags/examples/web/stock_quote.jsp
Index: stock_quote.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/stock_quote.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- stock_quote.jsp 2001/05/05 18:06:23 1.1
+++ stock_quote.jsp 2001/05/07 11:12:27 1.2
@@ -20,7 +20,7 @@
%>
<p>This example demonstrates fetching XML stock quotes from a web service
-and formatting the results using the <xtags> library.</p>
+and formatting the results using the XTags library.</p>
@@ -41,55 +41,53 @@
<h2>Stock Quotes</h2>
-<xtags:document uri="<%= url %>">
+<xtags:parse uri="<%= url %>"/>
- <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
- <tr bgcolor="#dddddd">
- <th>Symbol</th>
- <th align="right">Ask</th>
- <th align="right">Open</th>
- <th align="right">Days High</th>
- <th align="right">Days Low</th>
- <th align="right">Price Change</th>
- <th align="right">Volume</th>
- <th>Date</th>
- <th>Time</th>
+<table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
+ <tr bgcolor="#dddddd">
+ <th>Symbol</th>
+ <th align="right">Ask</th>
+ <th align="right">Open</th>
+ <th align="right">Days High</th>
+ <th align="right">Days Low</th>
+ <th align="right">Price Change</th>
+ <th align="right">Volume</th>
+ <th>Date</th>
+ <th>Time</th>
+ </tr>
+
+ <xtags:forEach select="//stock_quote">
+ <tr bgcolor="#eeeeee">
+ <td>
+ <xtags:valueOf select="symbol"/>
+ </td>
+ <td align="right">
+ <xtags:valueOf select="price[@type='ask']/@value"/>
+ </td>
+ <td align="right">
+ <xtags:valueOf select="price[@type='open']/@value"/>
+ </td>
+ <td align="right">
+ <xtags:valueOf select="price[@type='dayhigh']/@value"/>
+ </td>
+ <td align="right">
+ <xtags:valueOf select="price[@type='daylow']/@value"/>
+ </td>
+ <td align="right">
+ <xtags:valueOf select="change"/>
+ </td>
+ <td align="right">
+ <xtags:valueOf select="volume"/>
+ </td>
+ <td>
+ <xtags:valueOf select="when/date"/>
+ </td>
+ <td>
+ <xtags:valueOf select="when/time"/>
+ </td>
</tr>
-
- <xtags:forEach select="//stock_quote">
- <tr bgcolor="#eeeeee">
- <td>
- <xtags:valueOf select="symbol"/>
- </td>
- <td align="right">
- <xtags:valueOf select="price[@type='ask']/@value"/>
- </td>
- <td align="right">
- <xtags:valueOf select="price[@type='open']/@value"/>
- </td>
- <td align="right">
- <xtags:valueOf select="price[@type='dayhigh']/@value"/>
- </td>
- <td align="right">
- <xtags:valueOf select="price[@type='daylow']/@value"/>
- </td>
- <td align="right">
- <xtags:valueOf select="change"/>
- </td>
- <td align="right">
- <xtags:valueOf select="volume"/>
- </td>
- <td>
- <xtags:valueOf select="when/date"/>
- </td>
- <td>
- <xtags:valueOf select="when/time"/>
- </td>
- </tr>
- </xtags:forEach>
- </table>
-
-</xtags:document>
+ </xtags:forEach>
+</table>
</body>
</html>
1.2 +1 -1 jakarta-taglibs/xtags/examples/web/test_context.jsp
Index: test_context.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/test_context.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- test_context.jsp 2001/05/05 18:06:23 1.1
+++ test_context.jsp 2001/05/07 11:12:28 1.2
@@ -15,7 +15,7 @@
<hr/>
-<xtags:document uri="http://p.moreover.com/cgi-local/page?c=Java%20news&o=rss"/>
+<xtags:parse uri="http://p.moreover.com/cgi-local/page?c=Java%20news&o=rss"/>
Channel title: <xtags:valueOf select="/rss/channel/title"/>
1.2 +21 -22 jakarta-taglibs/xtags/examples/web/xpath_wizard.jsp
Index: xpath_wizard.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/xpath_wizard.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xpath_wizard.jsp 2001/05/05 18:06:23 1.1
+++ xpath_wizard.jsp 2001/05/07 11:12:30 1.2
@@ -1,11 +1,10 @@
+<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.util.*" %>
<%@ page import="org.dom4j.*" %>
<%@ page import="org.dom4j.io.*" %>
<%@ page import="org.apache.taglibs.xtags.util.StringHelper" %>
-
-<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
<html>
<head>
</head>
@@ -143,32 +142,32 @@
<h3>Results</h3>
<table width="100%" cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
-
- <xtags:document uri="<%= uri %>">
- <xtags:variable name="context" type="list" select="<%= contextPath %>"/>
+<%
+ System.out.println( "About to parse: " + uri );
+%>
+ <xtags:parse uri="<%= uri %>"/>
- <xtags:forEach select="<%= path %>" context="<%= context %>" sort="<%= ( sort ) ? sortPath : null %>" distinct="<%= distinct %>" name="result">
+ <xtags:forEach select="<%= path %>" sort="<%= ( sort ) ? sortPath : null %>" distinct="<%= distinct %>" name="result">
<%
- String text = "";
- if ( result instanceof String ) {
- text = (String) result;
- }
- else if ( result instanceof Node ) {
- Node node = (Node) result;
- text = StringHelper.encodeHTML(node.asXML());
- }
- else if ( result != null ) {
- text = result.toString();
- }
+ String text = "";
+ if ( result instanceof String ) {
+ text = (String) result;
+ }
+ else if ( result instanceof Node ) {
+ Node node = (Node) result;
+ text = StringHelper.encodeHTML(node.asXML());
+ }
+ else if ( result != null ) {
+ text = result.toString();
+ }
%>
- <tr bgcolor="#eeeeee">
- <td><%= text %></td>
- </tr>
- </xtags:forEach>
+ <tr bgcolor="#eeeeee">
+ <td><%= text %></td>
+ </tr>
- </xtags:document>
+ </xtags:forEach>
<%
}
%>
1.2 +3 -4 jakarta-taglibs/xtags/examples/web/style/styledemo3.jsp
Index: styledemo3.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/style/styledemo3.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- styledemo3.jsp 2001/05/05 18:06:25 1.1
+++ styledemo3.jsp 2001/05/07 11:13:00 1.2
@@ -5,9 +5,8 @@
denotes the document to be styled
--%>
-<xtags:document uri="/style/test2.xml">
+<xtags:parse uri="/style/test2.xml"/>
- <%-- style the current document context --%>
- <xtags:style xsl="/style/article-html.xsl" outputMethod="html"/>
+<%-- style the current document context --%>
+<xtags:style xsl="/style/article-html.xsl" outputMethod="html"/>
-</xtags:document>
1.2 +2 -1 jakarta-taglibs/xtags/examples/web/test/test_param.jsp
Index: test_param.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/examples/web/test/test_param.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- test_param.jsp 2001/05/05 18:06:26 1.1
+++ test_param.jsp 2001/05/07 11:13:09 1.2
@@ -13,7 +13,8 @@
<p>This demo shows the use of the choose tag without any XML input.</p>
-<p> The request parameter <i>param</i> has value: <b>
+<p> The request parameter <i>param</i> has value:
+ <b>
<xtags:choose>
<xtags:when test="$param='1'">
One
1.2 +52 -4 jakarta-taglibs/xtags/src/org/apache/taglibs/xtags/tags/ParseTag.java
Index: ParseTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/src/org/apache/taglibs/xtags/tags/ParseTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParseTag.java 2001/05/05 18:06:31 1.1
+++ ParseTag.java 2001/05/07 11:13:20 1.2
@@ -60,7 +60,11 @@
import org.apache.taglibs.xtags.util.LogHelper;
+import java.io.IOException;
+import java.io.Reader;
import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Iterator;
import java.util.List;
@@ -88,7 +92,13 @@
/** Holds value of property name. */
private String name;
+ /** The URL of the document to parse. */
+ private URL url;
+ /** The Reader used to parse XML */
+ private Reader reader;
+
+
public ParseTag() {
}
@@ -99,11 +109,22 @@
}
public int doAfterBody() throws JspException {
- BodyContent body = getBodyContent();
try {
- String text = body.getString().trim();
- body.clearBody();
- Document document = getSAXReader().read( new StringReader(text) );
+ Document document = null;
+ if ( url != null ) {
+ // XXXX: check cache here...
+ document = getSAXReader().read( url );
+ }
+ else if ( reader != null ) {
+ document = getSAXReader().read( reader );
+ reader = null;
+ }
+ else {
+ BodyContent body = getBodyContent();
+ String text = body.getString().trim();
+ body.clearBody();
+ document = getSAXReader().read( new StringReader(text) );
+ }
defineVariable( document );
}
catch (Exception e) {
@@ -115,6 +136,8 @@
public void release() {
super.release();
name = null;
+ url = null;
+ reader = null;
}
// Properties
@@ -132,6 +155,31 @@
*/
public void setName(String name) {
this.name = name;
+ }
+
+ public String getUri() {
+ return (url != null) ? url.toString() : null;
+ }
+
+ public void setURL(URL url) {
+ this.url = url;
+
+ log.info( "Set URL to: " + url );
+ }
+
+ public void setUri( String uri ) throws IOException {
+ log.info( "Setting URI to: " + uri );
+
+ if ( uri.indexOf(':' ) > 0 ) {
+ setURL( new URL( uri ) );
+ }
+ else {
+ setURL( pageContext.getServletContext().getResource( uri ) );
+ }
+ }
+
+ public void setReader(Reader reader) {
+ this.reader = reader;
}
// Implementation methods
1.2 +26 -30 jakarta-taglibs/xtags/xml/xtags.xml
Index: xtags.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/xtags/xml/xtags.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xtags.xml 2001/05/05 18:06:35 1.1
+++ xtags.xml 2001/05/07 11:13:28 1.2
@@ -14,10 +14,20 @@
<info>XTags Library</info>
<overview>
- <p>The <xtags> tag library implements an XSLT-like JSP tag library
+ <p>The XTags tag library implements an XSLT-like JSP tag library
to allow navigating, processing and styling of XML documents directly in JSP.
</p>
+ <p>In many ways XTags is like XSLT implemented in JSP allowing you to
+ seamlessly work with JSP, custom tags, JavaBeans and the whole
+ J2EE platform from inside a single piece of JSP!
+ </p>
+ <p>XTags is currently built on top of <a href="http://dom4j.org">dom4j</a> the
+ flexible open source XML framework for the Java platform.
+ Though increasingly XTags will use a pluggable XPath engine to support
+ the travesal of DOM and Java Beans too.
+ </p>
+
</overview>
<requirements-info>
@@ -28,17 +38,18 @@
</requirements-info>
<tag>
- <name>document</name>
- <tagclass>org.apache.taglibs.xtags.tags.DocumentTag</tagclass>
+ <name>parse</name>
+ <tagclass>org.apache.taglibs.xtags.tags.ParseTag</tagclass>
+ <teiclass>org.apache.taglibs.xtags.tags.ParseTagExtraInfo</teiclass>
<bodycontent>JSP</bodycontent>
- <info>Parses the given document and defines the current context node as the document</info>
+ <info>Parsers some XML either from a given URL or from the body of this tag</info>
<attribute>
- <name>uri</name>
+ <name>name</name>
<required>false</required>
- <rtexprvalue>true</rtexprvalue>
+ <rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
- <name>name</name>
+ <name>uri</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
@@ -52,30 +63,10 @@
<usage>
<comment>
</comment>
- <code>
- <![CDATA[<xtags:document uri="foo/bar.xml"/>]]>
- </code>
- </usage>
- </tag>
-
- <tag>
- <name>parse</name>
- <tagclass>org.apache.taglibs.xtags.tags.ParseTag</tagclass>
- <teiclass>org.apache.taglibs.xtags.tags.ParseTagExtraInfo</teiclass>
- <bodycontent>JSP</bodycontent>
- <info>Parsers a piece of xml from the body of the tag</info>
- <attribute>
- <name>name</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- </attribute>
- <script-variable>If the name attribute is set the variable with that name will be defined</script-variable>
- <restrictions></restrictions>
- <usage>
- <comment>
- </comment>
<code><![CDATA[
-<xtags:parse name="myDoc">
+<xtags:parse name="doc1" url="foo/bar.xml"/>
+
+<xtags:parse name="doc2">
<root>
<author firstName="James" surname="Strachan"/>
</root>
@@ -509,6 +500,11 @@
<attribute>
<name>select</name>
<required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>context</name>
+ <required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<script-variable>No</script-variable>