jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject cvs commit: jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common XPathUtil.java XmlExprTag.java XmlSetTag.java
Date Mon, 19 Nov 2001 06:35:12 GMT
shawn       01/11/18 22:35:12

  Modified:    jsptl/conf x.tld
               jsptl/examples/web/xml Filter.jsp
               jsptl/src/org/apache/taglibs/jsptl/tag/common XPathUtil.java
                        XmlExprTag.java XmlSetTag.java
  Added:       jsptl/examples/web/xml Expr.jsp If.jsp When.jsp
  Removed:     jsptl/examples/web/xml Parse.jsp
  Log:
  XML tags update
  
  Revision  Changes    Path
  1.2       +8 -38     jakarta-taglibs/jsptl/conf/x.tld
  
  Index: x.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/conf/x.tld,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- x.tld	2001/11/19 04:18:06	1.1
  +++ x.tld	2001/11/19 06:35:11	1.2
  @@ -81,7 +81,7 @@
   
     <tag>
       <name>if</name>
  -    <tag-class>org.apache.taglibs.jsptl.tag.jx.IfTag</tag-class>
  +    <tag-class>org.apache.taglibs.jsptl.tag.common.XmlIfTag</tag-class>
       <body-content>JSP</body-content>
       <description>
           Simple conditional tag, which evalutes its body if the
  @@ -89,7 +89,7 @@
           scripting variable representing the evaluation of this condition
       </description>
       <attribute>
  -        <name>test</name>
  +        <name>select</name>
           <required>true</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>
  @@ -102,49 +102,19 @@
   
     <tag>
       <name>forEach</name>
  -    <tag-class>org.apache.taglibs.jsptl.tag.jx.ForEachTag</tag-class>
  -    <tei-class>org.apache.taglibs.jsptl.tei.ForEachTEI</tei-class>
  +    <tag-class>org.apache.taglibs.jsptl.tag.common.XmlForEachTag</tag-class>
       <body-content>JSP</body-content>
       <description>
  -	The basic iteration tag, accepting many different
  -        collection types and supporting subsetting and other
  -        functionality
  +	XML iteration tag.
       </description>
       <attribute>
  -	<name>items</name>
  -	<required>false</required>
  -	<rtexprvalue>false</rtexprvalue>
  -    </attribute>
  -    <attribute>
  -	<name>begin</name>
  -	<required>false</required>
  -	<rtexprvalue>false</rtexprvalue>
  -    </attribute>
  -    <attribute>
  -	<name>end</name>
  -	<required>false</required>
  -	<rtexprvalue>false</rtexprvalue>
  -    </attribute>
  -    <attribute>
  -	<name>step</name>
  -	<required>false</required>
  -	<rtexprvalue>false</rtexprvalue>
  -    </attribute>
  -    <!-- No label in EA1
  -    <attribute>
  -	<name>label</name>
  -	<required>false</required>
  -	<rtexprvalue>false</rtexprvalue>
  -    </attribute>
  -    -->
  -    <attribute>
   	<name>var</name>
   	<required>false</required>
   	<rtexprvalue>false</rtexprvalue>
       </attribute>
       <attribute>
  -	<name>status</name>
  -	<required>false</required>
  +	<name>select</name>
  +	<required>true</required>
   	<rtexprvalue>false</rtexprvalue>
       </attribute>
     </tag>
  @@ -212,14 +182,14 @@
   
     <tag>
       <name>when</name>
  -    <tag-class>org.apache.taglibs.jsptl.tag.jx.WhenTag</tag-class>
  +    <tag-class>org.apache.taglibs.jsptl.tag.common.XmlWhenTag</tag-class>
       <body-content>JSP</body-content>
       <description>
           Subtag of &lt;choose&gt; that includes its body if its
           condition evalutes to 'true'
       </description>
       <attribute>
  -        <name>test</name>
  +        <name>select</name>
           <required>true</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>
  
  
  
  1.2       +1 -1      jakarta-taglibs/jsptl/examples/web/xml/Filter.jsp
  
  Index: Filter.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/examples/web/xml/Filter.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Filter.jsp	2001/11/19 04:18:06	1.1
  +++ Filter.jsp	2001/11/19 06:35:11	1.2
  @@ -6,7 +6,7 @@
     <title>JSPTL: XML Support -- Parse / Filter / Expr</title>
   </head>
   <body bgcolor="#FFFFFF">
  -<h3>Parse / Expr</h3>
  +<h3>Parse / Filter / Expr</h3>
   
   <ex:SPath var="spath" select="//a"/>
   <x:parse var="a" filter="$spath">
  
  
  
  1.1                  jakarta-taglibs/jsptl/examples/web/xml/Expr.jsp
  
  Index: Expr.jsp
  ===================================================================
  <%@ taglib prefix="x" uri="http://java.sun.com/jsptl/ea/x" %>
  
  <html>
  <head>
    <title>JSPTL: XML Support -- Parse / Expr</title>
  </head>
  <body bgcolor="#FFFFFF">
  <h3>Parse / Expr</h3>
  
  <x:parse var="a">
    <a>
     <b>
      <c>
       foo
      </c>
     </b>
     <d>
       bar
     </d>
    </a>
  </x:parse>
  
  <x:expr select="$a//c"/>
  <x:expr select="$a/a/d"/>
  
  <hr />
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/jsptl/examples/web/xml/If.jsp
  
  Index: If.jsp
  ===================================================================
  <%@ taglib prefix="x" uri="http://java.sun.com/jsptl/ea/x" %>
  
  <html>
  <head>
    <title>JSPTL: XML Support -- Parse / If</title>
  </head>
  <body bgcolor="#FFFFFF">
  <h3>Parse / If</h3>
  
  <x:parse var="a">
    <a>
     <b>
      <c>
       foo
      </c>
     </b>
     <d>
       bar
     </d>
    </a>
  </x:parse>
  
  <x:if select="$a//c">
    $a//c exists
  </x:if>
  
  <br />
  
  <x:if select="$a/a/d">
    $a/a/d exists
  </x:if>
  
  <br />
  
  <x:if select="$a/w/o/l">
    $a/w/o/l exists
  </x:if>
  
  <hr />
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/jsptl/examples/web/xml/When.jsp
  
  Index: When.jsp
  ===================================================================
  <%@ taglib prefix="x" uri="http://java.sun.com/jsptl/ea/x" %>
  
  <html>
  <head>
    <title>JSPTL: XML Support -- Parse / When</title>
  </head>
  <body bgcolor="#FFFFFF">
  <h3>Parse / When</h3>
  
  <x:parse var="a">
    <a>
     <b>
      <c foo="bar">
       foo
      </c>
     </b>
     <d>
       bar
     </d>
    </a>
  </x:parse>
  
  <x:choose>
    <x:when select='$a//c[@foo="bar"]'>
      @foo = bar
    </x:when>
    <x:when select='$a//c[@foo="foo"]'>
      @foo = foo
    </x:when>
    <x:otherwise>
      @foo not recognized
    </x:otherwise>
  </x:choose>
  
  <br />
  
  <x:choose>
    <x:when select='$a//c[@foo="foo"]'>
      @foo = foo
    </x:when>
    <x:when select='$a//c[@foo="bar"]'>
      @foo = bar
    </x:when>
    <x:otherwise>
      @foo not recognized
    </x:otherwise>
  </x:choose>
  
  <br />
  
  <x:choose>
    <x:when select='$a//c[@foo="barr"]'>
      @foo = barr
    </x:when>
    <x:when select='$a//c[@foo="fooo"]'>
      @foo = fooo
    </x:when>
    <x:otherwise>
      @foo not recognized
    </x:otherwise>
  </x:choose>
  
  <br />
  
  <hr />
  
  </body>
  </html>
  
  
  
  1.2       +22 -5     jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/XPathUtil.java
  
  Index: XPathUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/XPathUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathUtil.java	2001/11/19 04:18:06	1.1
  +++ XPathUtil.java	2001/11/19 06:35:11	1.2
  @@ -158,6 +158,7 @@
       private PageContext pageContext;
       private static SimpleNamespaceContext nc;
       private static FunctionContext fc;
  +    private static DocumentNavigator dn;
   
       /** Initialize globally useful data. */
       private synchronized static void staticInit() {
  @@ -176,6 +177,9 @@
   
   	    // set up the global FunctionContext
   	    fc = XPathFunctionContext.getInstance();
  +
  +	    // set up the global DocumentNavigator
  +	    dn = DocumentNavigator.getInstance();
   	}
       }
   
  @@ -216,12 +220,25 @@
       private Context getLocalContext(Node n) {
   	// set up instance-specific contexts
           VariableContext vc = new JstlVariableContext();
  -        ContextSupport cs = new ContextSupport(nc, fc, vc,
  -	    DocumentNavigator.getInstance());
  +        ContextSupport cs = new ContextSupport(nc, fc, vc, dn);
           Context c = new Context(cs);
  -        Vector v = new Vector();
  -        v.add(n);
  -        c.setNodeSet(v);
  +        List l = new ArrayList(1);
  +        l.add(n);
  +        c.setNodeSet(l);
   	return c;
       }
  +
  +    //*********************************************************************
  +    // Static support for context retrieval from parent <forEach> tag
  +
  +    public static Node getContext(Tag t) throws JspTagException {
  +	XmlForEachTag xt = 
  +	    (XmlForEachTag) TagSupport.findAncestorWithClass(
  +		t, XmlForEachTag.class);
  +	if (xt == null)
  +	    return null;
  +	else
  +	    return (xt.getContext());
  +    }
  +
   }
  
  
  
  1.2       +1 -1      jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/XmlExprTag.java
  
  Index: XmlExprTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/XmlExprTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XmlExprTag.java	2001/11/19 04:18:06	1.1
  +++ XmlExprTag.java	2001/11/19 06:35:11	1.2
  @@ -97,7 +97,7 @@
       public int doStartTag() throws JspException {
           try {
   	    XPathUtil xu = new XPathUtil(pageContext);
  -	    String result = xu.valueOf(null, select);
  +	    String result = xu.valueOf(XPathUtil.getContext(this), select);
   	    pageContext.getOut().print(result);
   	    return SKIP_BODY;
           } catch (java.io.IOException ex) {
  
  
  
  1.2       +2 -1      jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/XmlSetTag.java
  
  Index: XmlSetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/XmlSetTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XmlSetTag.java	2001/11/19 04:18:07	1.1
  +++ XmlSetTag.java	2001/11/19 06:35:11	1.2
  @@ -98,7 +98,8 @@
       public int doStartTag() throws JspException {
           try {
   	    XPathUtil xu = new XPathUtil(pageContext);
  -	    org.w3c.dom.Node result = xu.selectSingleNode(null, select);
  +	    org.w3c.dom.Node result = 
  +		xu.selectSingleNode(XPathUtil.getContext(this), select);
   	    pageContext.setAttribute(var, result);
   	    return SKIP_BODY;
           } catch (org.saxpath.SAXPathException ex) {
  
  
  

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


Mime
View raw message