jstrachan    01/05/10 05:12:10

  Modified:    xtags/doc/web intro.xml taglib.css xtags.html
               xtags/src/org/apache/taglibs/xtags/tags ParseTag.java
               xtags/xml xtags.xml
  Log:
  Improved the documentation to give an overview of the tags
  
  Revision  Changes    Path
  1.3       +3 -3      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- intro.xml 2001/05/07 11:11:54     1.2
  +++ intro.xml 2001/05/10 12:12:03     1.3
  @@ -9,7 +9,7 @@
     <body>
   
   
  -  <section name="XTags Tag Library" href="Welcome">
  +  <section name="XTags Library" href="Welcome">
   
     <p>XTags is a JSP custom tag library for working with XML. 
       XTags implements an XSLT-like language allowing XML to be styled and 
  @@ -32,7 +32,7 @@
   
     <p>For more information about the XTags Tag Library, look at the on-line 
documentation:</p>
     <ul>
  -  <li>View the <a href="xtags.html">XTags Taglib Documentation</a></li>
  +  <li>View the <a href="xtags.html">XTags Documentation</a></li>
     </ul>
   
     <p>For information on how to use the distributions, look at the following 
documentation:</p>
  @@ -48,7 +48,7 @@
   
     <p>A binary download of the XTags Tag Library is available</p>
     <ul>
  -  <li><strong>Download <a 
href="http://jakarta.apache.org/builds/jakarta-taglibs/nightly/projects/xtags/";>XTags 
Tag Library</a></strong></li>
  +  <li><strong>Download <a 
href="http://jakarta.apache.org/builds/jakarta-taglibs/nightly/projects/xtags/";>XTags 
Library</a></strong></li>
     </ul>
   
     <p>The following distributions are also available for download:</p>
  
  
  
  1.2       +13 -13    jakarta-taglibs/xtags/doc/web/taglib.css
  
  Index: taglib.css
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/xtags/doc/web/taglib.css,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- taglib.css        2001/05/05 18:06:21     1.1
  +++ taglib.css        2001/05/10 12:12:04     1.2
  @@ -1,13 +1,13 @@
  -body { background-color: #ffffff; }
  -h1   { text-align: center; }
  -code  { font: medium sans-serif; color: #990099; background-color: #ffffbb; }
  -.middle  { text-align: center; }
  -.comment { color: #3300cc; }
  -.jsp-squig { color: #009999; }
  -.scriptlet { color: #666666; }
  -.tclass { font-weight: bold; }
  -.tbody  { font-weight: bold; }
  -.scriptvar  { font-weight: bold; }
  -.restrictions  { font-weight: bold; }
  -.attributes  { font-weight: bold; }
  -.example  { font-weight: bold; }
  +body { background-color: #ffffff; }
  +h1   { text-align: center; }
  +code  { font: medium sans-serif; color: #990099; }
  +.middle  { text-align: center; }
  +.comment { color: #3300cc; }
  +.jsp-squig { color: #009999; }
  +.scriptlet { color: #666666; }
  +.tclass { font-weight: bold; }
  +.tbody  { font-weight: bold; }
  +.scriptvar  { font-weight: bold; }
  +.restrictions  { font-weight: bold; }
  +.attributes  { font-weight: bold; }
  +.example  { font-weight: bold; }
  
  
  
  1.6       +217 -29   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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- xtags.html        2001/05/09 16:06:29     1.5
  +++ xtags.html        2001/05/10 12:12:04     1.6
  @@ -27,25 +27,181 @@
           <br>
           <a name="overview"></a>
           <h3>Overview</h3>
  -        <p>The XTags tag library implements an XSLT-like JSP tag library
  +        <p>XTags 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 
  +   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 makes heavy use of the XPath expression language.
  +      For a good tutorial on XPath you could try the either the 
  +      <a href="http://www.zvon.org/xxl/XPathTutorial/General/examples.html";>Zvon 
tutorial</a> or the 
  +      <a href="http://www.w3.org/TR/xpath";>specification</a>.
  +  </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>
  +        <p>To begin with you need to parse an XML document from somewhere.
  +    You can parse a variety of sources of XML documents from local resources,
  +    the output of JSP or external web services.
  +  </p>
  +        <p>You can parse the body of the tag
  +  </p>
  +        <pre>
  +    &lt;xtags:parse&gt;
  +        &lt;root&gt;
  +            &lt;child/&gt;
  +        &lt;/root&gt;
  +    &lt;/xtags:parse&gt;
  +</pre>
  +        <p>Or parse an absolute URL via the "url" attribute
  +  </p>
  +        <pre>
  +    &lt;xtags:parse url="http://something.com"/&gt;
  +</pre>
  +        <p>You can parse a web app resource using an absolute URI relative to the 
web-app
  +  context using the "uri" attribute
  +  </p>
  +        <pre>
  +    &lt;xtags:parse uri="/data/foo.xml"/&gt;
  +</pre>
  +        <p>Or you can use a URI relative to the the current JSP file
  +  </p>
  +        <pre>
  +    &lt;xtags:parse uri="foo.xml"/&gt;
  +</pre>
  +        <p>Then for more complex
  +  requirements such as parsing the output of a piece of JSP, when we get to
  +  JSP 1.2, we'll be able to do...
  +  </p>
  +        <pre>
  +    &lt;xtags:parse&gt;
  +        &lt;jsp:include page="foo.jsp"/&gt;
  +    &lt;/xtags:parse&gt;
  +</pre>
  +        <p>Until then you can use the IO tag library to make these requests such as
  +  </p>
  +        <pre>
  +    &lt;xtags:parse&gt;
  +        &lt;io:request url="/foo.jsp"/&gt;
  +    &lt;/xtags:parse&gt;
  +</pre>
  +        <p>Though the above would result in a seperate HTTP request which would 
loose 
  +  all page, request and session scope state. 
  +  So if it must be in the same request the following should work
  +  though care should be taken to avoid scripting variable clashes
  +  </p>
  +        <pre>
  +    &lt;xtags:parse&gt;
  +        &lt;%@ include file="/foo.jsp" %&gt;
  +    &lt;/xtags:parse&gt;
  +</pre>
  +        <p>To parse the output of an XML-RPC (or SOAP) call, using the IO taglib
  +  you could do the following.
  +  </p>
  +        <pre>
  +    &lt;xtags:parse&gt;
  +        &lt;io:xmlrpc url="/xmlrpc_echo.jsp"&gt;
  +         &lt;io:pipe&gt;
  +          &lt;methodCall&gt;
  +             &lt;methodName&gt;examples.getStateName&lt;/methodName&gt;
  +             &lt;params&gt;
  +                &lt;param&gt;
  +                   &lt;value&gt;&lt;i4&gt;41&lt;/i4&gt;&lt;/value&gt;
  +                   &lt;/param&gt;
  +                &lt;/params&gt;
  +             &lt;/methodCall&gt;
  +         &lt;/io:pipe&gt;
  +        &lt;/io:xmlrpc&gt;
  +
  +    &lt;/xtags:parse&gt;
  +</pre>
  +        <p>Once you have a document parsed you can navigate around its structure 
using XPath
  +    expressions in a similar manner to that used in XSLT.</p>
  +        <p>Loops are as follows (an optional variable id can be specified to define 
a
  +  scriptlet expression inside the loop):-
  +  </p>
  +        <pre>
  +  &lt;xtags:forEach select="expression"&gt;
  +    ...
  +  &lt;/xtags:forEach&gt;
  +</pre>
  +        <p>Simple conditional branching is:-
  +  </p>
  +        <pre>
  +  &lt;xtags:if test="booeanExpression"&gt;
  +    ...
  +  &lt;/xtags:if&gt;
  +</pre>
  +        <p>More complex conditional branching is:-
  +  </p>
  +        <pre>
  +  &lt;xtags:choose&gt;
  +    &lt;xtags:when test="booeanExpression"&gt;
  +      ...
  +    &lt;/xtags:when&gt;
  +    &lt;xtags:when test="booeanExpression2"&gt;
  +      ...
  +    &lt;/xtags:when&gt;
  +    &lt;xtags:otherwise&gt;
  +      ...
  +    &lt;/xtags:otherwise&gt;
  +  &lt;/xtags:choose&gt;
  +</pre>
  +        <p>Expression evaluation
  +  </p>
  +        <pre>
  +  &lt;xtags:valueOf select="expression"/&gt;
  +</pre>
  +        <p>Defining scriptlet variables
  +  </p>
  +        <pre>
  +  &lt;xtags:variable id="variableName" select="expression"/&gt;
  +</pre>
  +        <p>All these tags are very similar to their XSLT equivalents, so anyone 
who's
  +  done XSLT before should find them familiar.
  +  There's also an &lt;xtags:style&gt; tag which performs complete XSL transform 
  +  in one tag.
  +  </p>
  +        <p>XPath expressions can use variables with the syntax $foo.
  +  XTags binds these variables to either page/request/session/application scope
  +  attributes or request parameters which allows xtags to be used as a
  +  conditional logic scripting language too - even without the existence of XML
  +  documents.
  +  </p>
  +        <p> For example, the following JSP would branch logically based on the 
value of
  +  the (say) request parameter "param":-
  +  </p>
  +        <pre>
  +  &lt;xtags:choose&gt;
  +    &lt;xtags:when test="$param='a'"&gt;
  +      current param is 'a'
  +    &lt;/xtags:when&gt;
  +    &lt;xtags:when test="$param='b'"&gt;
  +      current param is 'b'
  +    &lt;/xtags:when&gt;
  +    &lt;xtags:otherwise&gt;
  +      no valid param selected
  +    &lt;/xtags:otherwise&gt;
  +  &lt;/xtags:choose&gt;
  +</pre>
  +        <p>
  +  XTags even supports the &lt;xtags:stylesheet&gt; &lt;xtags:template&gt; and
  +  &lt;xtags:applyTemplates&gt; tags from XSLT too though the body of a template 
must
  +  be an Action object or a seperate JSP file.
  +  </p>
           <a name="requirements"></a>
           <h3>Requirements</h3>
           <p>
  -  This custom tag library depends on a servlet container
  -  that supports the JavaServer Pages Specification, version 1.1 or higher and
  -  also requires a distribution of dom4j
  -  and log4j
  +    This custom tag library depends on a servlet container
  +    that supports the JavaServer Pages Specification, version 1.1 or higher and
  +    also requires a distribution of <a href="http://dom4j.org";>dom4j</a>
  +    and <a href="http://log4j.org";>log4j</a>. 
  +
  +    To be able to use the &lt;xtags:style&gt; tag then a distribution of
  +    JAXP is required along with an XSLT implementation such as xalan.jar and 
crimson.jar
     </p>
           <a name="config"></a>
           <h3>Configuration</h3>
  @@ -60,7 +216,7 @@
   <pre>
   &lt;taglib&gt;
     &lt;taglib-uri&gt;http://jakarta.apache.org/taglibs/xtags-1.0&lt;/taglib-uri&gt;
  -  &lt;taglib-location&gt;&lt;/taglib-location&gt;
  +  &lt;taglib-location&gt;/WEB-INF/xtags.tld&lt;/taglib-location&gt;
   &lt;/taglib&gt;
   </pre>
               </li>
  @@ -141,7 +297,7 @@
                   <td><a href="#attribute">attribute</a></td><td>Like the XSLT tag, 
creates a new attribute for the outer element tag.</td>
               </tr>
               <tr>
  -                <td><a href="#copyOf">copyOf</a></td><td>Generates a copy of the 
current context like the XSLT 
  +                <td><a href="#copyOf">copyOf</a></td><td>Generates a deep copy of 
the current context like the XSLT 
         &lt;xsl:copy-of/&gt; tag. 
       </td>
               </tr>
  @@ -227,15 +383,19 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  -&lt;xtags:parse id="doc1" url="foo/bar.xml"/&gt;
  -
  -&lt;xtags:parse id="doc2"&gt;
  +                                            <pre>
  +                                                <code>
  +&lt;xtags:parse id="doc1"&gt;
     &lt;root&gt;
       &lt;author firstName="James" surname="Strachan"/&gt;
     &lt;/root&gt;
   &lt;/xtags:parse&gt;
  +
  +&lt;xtags:parse id="doc2" url="http://www.acme.com/foo/bar.xml"/&gt;
  +
  +&lt;xtags:parse id="doc3" uri="/foo/bar.xml"/&gt;
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -305,9 +465,11 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         &lt;xtags:valueOf select="//author/@surname" /&gt; 
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -406,11 +568,13 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
   &lt;xtags:forEach select="//author"&gt;
  -  &lt;xsl:valueof select="@name"/&gt;      
  +  &lt;xtags:valueOf select="@name"/&gt;      
   &lt;/xtags:forEach&gt;
          </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -459,7 +623,8 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
   &lt;xtags:choose&gt;
     &lt;xtags:when test="firstName"&gt;
       Hello &lt;xtags:valueOf select="@firstName"/&gt;
  @@ -469,6 +634,7 @@
     &lt;/xtags:otherwise&gt;
   &lt;/xtags:choose&gt;
          </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -538,8 +704,10 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -588,8 +756,10 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -638,8 +808,10 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -709,11 +881,13 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
   &lt;xtags:if select="@location='UK'"&gt;
     UK based
   &lt;/xtags:if&gt;
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -802,9 +976,11 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         &lt;xtags:variable id="surname" select="@surname"/&gt; 
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -922,7 +1098,8 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
   &lt;xtags:style xml="foo.xml" xsl="bar.xsl"/&gt;
   
   &lt;xtags:style context="&lt;%= myDoc %&gt;" xsl="bar.xsl"/&gt;
  @@ -934,6 +1111,7 @@
       &lt;/root&gt;
   &lt;/xtags:style&gt;
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -997,12 +1175,14 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
   &lt;xtags:stylesheet&gt;
     &lt;xtags:template match="author" jsp="author.jsp"/&gt;
     &lt;xtags:template match="painter" jsp="painter.jsp"/&gt;
   &lt;/xtags:stylesheet&gt;
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -1144,9 +1324,11 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         &lt;xtags:copyOf select="." /&gt; 
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -1210,9 +1392,11 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         &lt;xtags:element name="author"/&gt; 
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -1276,9 +1460,11 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         &lt;xtags:attribute name="location"&gt;UK&lt;/xtags:attribute&gt; 
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  @@ -1299,7 +1485,7 @@
                   </td>
               </tr>
               <tr>
  -                <td colspan="2">Generates a copy of the current context like the 
XSLT 
  +                <td colspan="2">Generates a deep copy of the current context like 
the XSLT 
         &lt;xsl:copy-of/&gt; tag. 
       </td>
               </tr>
  @@ -1350,9 +1536,11 @@
         --%&gt;</span>
                                           <br>
                                           <p>
  -                                            <code>
  +                                            <pre>
  +                                                <code>
         &lt;xtags:copyOf select="@*|text()" /&gt; 
         </code>
  +                                            </pre>
                                           </p>
                                       </li>
                                   </ol>
  
  
  
  1.6       +19 -10    
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ParseTag.java     2001/05/09 16:07:14     1.5
  +++ ParseTag.java     2001/05/10 12:12:07     1.6
  @@ -87,6 +87,9 @@
     */
   public class ParseTag extends BodyTagSupport {
   
  +    /** Allow tracing to be disabled */
  +    private static final boolean TRACE = false;    
  +    
       /** Logger */
       private static final Category log = Category.getInstance( ParseTag.class );
   
  @@ -107,7 +110,9 @@
       // Tag interface
       //------------------------------------------------------------------------- 
       public int doStartTag() throws JspException  {
  -        log.info( "doStartTag() !!" );
  +        if ( TRACE ) {
  +            log.info( "doStartTag() !!" );
  +        }
           document = null;
           
           if ( url != null ) {
  @@ -125,7 +130,9 @@
       }
       
       public int doAfterBody() throws JspException {
  -        log.info( "doAfterBody() !!" );
  +        if ( TRACE ) {
  +            log.info( "doAfterBody() !!" );
  +        }
           
           if ( document == null ) {
               try {
  @@ -176,17 +183,23 @@
       public void setURL( URL url ) {
           this.url = url;
           
  -        log.info( "Set URL to: " + url );
  +        if ( TRACE ) {
  +            log.info( "Set URL to: " + url );
  +        }
       }
       
       public void setUrl( String url ) throws IOException {
  -        log.info( "Setting absolute URL to: " + url );
  +        if ( TRACE ) {
  +            log.info( "Setting absolute URL to: " + url );
  +        }
           
           setURL( new URL( url ) );
       }
       
       public void setUri( String uri ) throws IOException {
  -        log.info( "Setting relative URI to: " + uri );
  +        if ( TRACE ) {
  +            log.info( "Setting relative URI to: " + uri );
  +        }
   
           if ( uri.charAt(0) != '/' ) {
               // calculate a URI relative to the current JSP page
  @@ -214,18 +227,14 @@
       }
       
       protected void defineVariable( Document document ) {
  -        log.info( "Setting context to: " + document );
  -        
           TagHelper.defineVariable( pageContext, getId(), document );
  -        
  -        log.info( "Context is now: " + TagHelper.getInputNodes( pageContext ) );
       }
   
       /** Handles non-JspExceptions thrown in this instance
         */
       protected void handleException( Exception e ) throws JspException {
           log.error( e );
  -        e.printStackTrace();
  +        //e.printStackTrace();
           throw new JspException( e.getMessage() );
       }
       
  
  
  
  1.5       +209 -13   jakarta-taglibs/xtags/xml/xtags.xml
  
  Index: xtags.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/xtags/xml/xtags.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- xtags.xml 2001/05/09 16:07:32     1.4
  +++ xtags.xml 2001/05/10 12:12:09     1.5
  @@ -9,32 +9,226 @@
     <tlibversion>1.0</tlibversion>
     <jspversion>1.1</jspversion>
     <shortname>xtags</shortname>
  +  <taglib-location>/WEB-INF/xtags.tld</taglib-location>
     <uri>/WEB-INF/xtags.tld</uri>
     <prefix>xtags</prefix>
     <info>XTags Library</info> 
     <overview>
   
  -  <p>The XTags tag library implements an XSLT-like JSP tag library
  +  <p>XTags 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 
  +   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 makes heavy use of the XPath expression language.
  +      For a good tutorial on XPath you could try the either the 
  +      <a href="http://www.zvon.org/xxl/XPathTutorial/General/examples.html";>Zvon 
tutorial</a> or the 
  +      <a href="http://www.w3.org/TR/xpath";>specification</a>.
  +  </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>
   
  +  <p>To begin with you need to parse an XML document from somewhere.
  +    You can parse a variety of sources of XML documents from local resources,
  +    the output of JSP or external web services.
  +  </p>
  +
  +  <p>You can parse the body of the tag
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse>
  +        <root>
  +            <child/>
  +        </root>
  +    </xtags:parse>
  +]]></pre>
  +
  +  <p>Or parse an absolute URL via the "url" attribute
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse url="http://something.com"/>
  +]]></pre>
  +
  +  <p>You can parse a web app resource using an absolute URI relative to the web-app
  +  context using the "uri" attribute
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse uri="/data/foo.xml"/>
  +]]></pre>
  +
  +  <p>Or you can use a URI relative to the the current JSP file
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse uri="foo.xml"/>
  +]]></pre>
  +
  +  <p>Then for more complex
  +  requirements such as parsing the output of a piece of JSP, when we get to
  +  JSP 1.2, we'll be able to do...
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse>
  +        <jsp:include page="foo.jsp"/>
  +    </xtags:parse>
  +]]></pre>
  +
  +  <p>Until then you can use the IO tag library to make these requests such as
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse>
  +        <io:request url="/foo.jsp"/>
  +    </xtags:parse>
  +]]></pre>
  +
  +  <p>Though the above would result in a seperate HTTP request which would loose 
  +  all page, request and session scope state. 
  +  So if it must be in the same request the following should work
  +  though care should be taken to avoid scripting variable clashes
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse>
  +        <%@ include file="/foo.jsp" %>
  +    </xtags:parse>
  +]]></pre>
  +
  +  <p>To parse the output of an XML-RPC (or SOAP) call, using the IO taglib
  +  you could do the following.
  +  </p>
  +
  +<pre><![CDATA[
  +    <xtags:parse>
  +        <io:xmlrpc url="/xmlrpc_echo.jsp">
  +         <io:pipe>
  +          <methodCall>
  +             <methodName>examples.getStateName</methodName>
  +             <params>
  +                <param>
  +                   <value><i4>41</i4></value>
  +                   </param>
  +                </params>
  +             </methodCall>
  +         </io:pipe>
  +        </io:xmlrpc>
  +
  +    </xtags:parse>
  +]]></pre>
  +
  +
  +  <p>Once you have a document parsed you can navigate around its structure using 
XPath
  +    expressions in a similar manner to that used in XSLT.</p>
  +    
  +  <p>Loops are as follows (an optional variable id can be specified to define a
  +  scriptlet expression inside the loop):-
  +  </p>
  +
  +<pre><![CDATA[
  +  <xtags:forEach select="expression">
  +    ...
  +  </xtags:forEach>
  +]]></pre>
  +
  +  <p>Simple conditional branching is:-
  +  </p>
  +
  +<pre><![CDATA[
  +  <xtags:if test="booeanExpression">
  +    ...
  +  </xtags:if>
  +]]></pre>
  +
  +  <p>More complex conditional branching is:-
  +  </p>
  +
  +<pre><![CDATA[
  +  <xtags:choose>
  +    <xtags:when test="booeanExpression">
  +      ...
  +    </xtags:when>
  +    <xtags:when test="booeanExpression2">
  +      ...
  +    </xtags:when>
  +    <xtags:otherwise>
  +      ...
  +    </xtags:otherwise>
  +  </xtags:choose>
  +]]></pre>
  +
  +  <p>Expression evaluation
  +  </p>
  +
  +<pre><![CDATA[
  +  <xtags:valueOf select="expression"/>
  +]]></pre>
  +
  +  <p>Defining scriptlet variables
  +  </p>
  +
  +<pre><![CDATA[
  +  <xtags:variable id="variableName" select="expression"/>
  +]]></pre>
  +
  +
  +  <p>All these tags are very similar to their XSLT equivalents, so anyone who's
  +  done XSLT before should find them familiar.
  +  There's also an &lt;xtags:style&gt; tag which performs complete XSL transform 
  +  in one tag.
  +  </p>
  +
  +  <p>XPath expressions can use variables with the syntax $foo.
  +  XTags binds these variables to either page/request/session/application scope
  +  attributes or request parameters which allows xtags to be used as a
  +  conditional logic scripting language too - even without the existence of XML
  +  documents.
  +  </p>
  +
  +  <p> For example, the following JSP would branch logically based on the value of
  +  the (say) request parameter "param":-
  +  </p>
  +
  +<pre><![CDATA[
  +  <xtags:choose>
  +    <xtags:when test="$param='a'">
  +      current param is 'a'
  +    </xtags:when>
  +    <xtags:when test="$param='b'">
  +      current param is 'b'
  +    </xtags:when>
  +    <xtags:otherwise>
  +      no valid param selected
  +    </xtags:otherwise>
  +  </xtags:choose>
  +]]></pre>
  +
  +  <p>
  +  XTags even supports the &lt;xtags:stylesheet&gt; &lt;xtags:template&gt; and
  +  &lt;xtags:applyTemplates&gt; tags from XSLT too though the body of a template 
must
  +  be an Action object or a seperate JSP file.
  +  </p>
  +
  +
     </overview> 
     
     <requirements-info>
  -  This custom tag library depends on a servlet container
  -  that supports the JavaServer Pages Specification, version 1.1 or higher and
  -  also requires a distribution of <a href="http://dom4j.org";>dom4j</a>
  -  and <a href="http://log4j.org";>log4j</a>
  +    This custom tag library depends on a servlet container
  +    that supports the JavaServer Pages Specification, version 1.1 or higher and
  +    also requires a distribution of <a href="http://dom4j.org";>dom4j</a>
  +    and <a href="http://log4j.org";>log4j</a>. 
  +
  +    To be able to use the &lt;xtags:style&gt; tag then a distribution of
  +    JAXP is required along with an XSLT implementation such as xalan.jar and 
crimson.jar
     </requirements-info>
   
     <tag>
  @@ -73,13 +267,15 @@
         <comment>
         </comment>
         <code><![CDATA[
  -<xtags:parse id="doc1" url="foo/bar.xml"/>
  -
  -<xtags:parse id="doc2">
  +<xtags:parse id="doc1">
     <root>
       <author firstName="James" surname="Strachan"/>
     </root>
   </xtags:parse>
  +
  +<xtags:parse id="doc2" url="http://www.acme.com/foo/bar.xml"/>
  +
  +<xtags:parse id="doc3" uri="/foo/bar.xml"/>
         ]]></code>
       </usage>
     </tag>
  @@ -158,7 +354,7 @@
         </comment>
         <code><![CDATA[
   <xtags:forEach select="//author">
  -  <xsl:valueof select="@name"/>      
  +  <xtags:valueOf select="@name"/>      
   </xtags:forEach>
         ]]> </code>
       </usage>
  @@ -511,7 +707,7 @@
       <name>copyOf</name>
       <tagclass>org.apache.taglibs.xtags.tags.CopyOfTag</tagclass>
       <bodycontent>JSP</bodycontent>
  -    <info>Generates a copy of the current context like the XSLT 
  +    <info>Generates a deep copy of the current context like the XSLT 
         &lt;xsl:copy-of/&gt; tag. 
       </info>
       <attribute>
  
  
  

Reply via email to