xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daver...@apache.org
Subject cvs commit: xml-xmlbeans/v1/test/src/drt/drtcases JaxenXPathTests.java
Date Wed, 03 Mar 2004 02:03:50 GMT
daveremy    2004/03/02 18:03:50

  Modified:    v1/src/xmlpublic/org/apache/xmlbeans XmlBeans.java
                        XmlOptions.java
               v1/src/xmlstore/org/apache/xmlbeans/impl/store Path.java
                        XqrlDelegate.java
               v1/test/src/drt/drtcases JaxenXPathTests.java
  Log:
  on behalf of Kevin Krouse
  adding option for xqrl external variable binding
  DRTs: passed
  
  Revision  Changes    Path
  1.4       +3 -1      xml-xmlbeans/v1/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
  
  Index: XmlBeans.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XmlBeans.java	12 Feb 2004 20:06:01 -0000	1.3
  +++ XmlBeans.java	3 Mar 2004 02:03:50 -0000	1.4
  @@ -191,7 +191,9 @@
        * @param  options  Options for the query. For example, you can call 
        * the {@link XmlOptions#setXqueryCurrentNodeVar(String) XmlOptions.setXqueryCurrentNodeVar(String)}
        * method to specify a particular name for the expression 
  -     * variable that indicates the context node.
  +     * variable that indicates the context node and the
  +     * {@link XmlOptions#setXqueryVariables(Map) XmlOptions.setXqueryVariables(Map)}
  +     * method to map external variable names to values.
        */
       public static String compileQuery ( String queryExpr, XmlOptions options )
           throws XmlException
  
  
  
  1.5       +19 -0     xml-xmlbeans/v1/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
  
  Index: XmlOptions.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XmlOptions.java	12 Feb 2004 20:06:01 -0000	1.4
  +++ XmlOptions.java	3 Mar 2004 02:03:50 -0000	1.5
  @@ -426,6 +426,23 @@
       }
   
       /**
  +     * Map the names and values of external variables in an xquery
  +     * expression.  The keys of the map are the variable names
  +     * in the query without the '$' prefix.  The values of the map
  +     * are objects and can be any of the primitive wrapper classes,
  +     * String, XmlObject, or XmlCursor. The mapping only applies to
  +     * xquery and has no effect on xpath expressions.
  +     *
  +     * @param varMap a map from <code>String</code>s to variable instances.
  +     *
  +     * @see XmlObject#execQuery
  +     * @see XmlCursor#execQuery
  +     */
  +    public XmlOptions setXqueryVariables (Map varMap) { 
  +        return set( XQUERY_VARIABLE_MAP, varMap ); 
  +    }
  +
  +    /**
        * This option sets the document source name into the xml store
        * when parsing a document.  If a document is parsed from a
        * File or URI, it is automatically set to the URI of the
  @@ -594,6 +611,8 @@
   
       /** @exclude */
       public static final String XQUERY_CURRENT_NODE_VAR         =  "XQUERY_CURRENT_NODE_VAR";
  +    /** @exclude */
  +    public static final String XQUERY_VARIABLE_MAP             =  "XQUERY_VARIABLE_MAP";
   
       /** @exclude */
       public static final String CHARACTER_ENCODING              =  "CHARACTER_ENCODING";
  
  
  
  1.5       +14 -5     xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Path.java
  
  Index: Path.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Path.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Path.java	12 Feb 2004 20:06:04 -0000	1.4
  +++ Path.java	3 Mar 2004 02:03:50 -0000	1.5
  @@ -121,6 +121,16 @@
           
           options = XmlOptions.maskNull( options );
           
  +        // ensure options doesn't contain XQuery variable mapping.
  +        // someday we should implement this in all the pathing engines
  +        // but for now it only applies to the xqrl.
  +        if (options.hasOption( XmlOptions.XQUERY_VARIABLE_MAP ))
  +        {
  +            throw
  +                new XmlRuntimeException(
  +                    "XmlOptions.XQUERY_VARIABLE_MAP is not allowed in XPath expressions.");
  +        }
  +
           String currentNodeVar = getCurrentNodeVar( options );
   
           synchronized ( _xbeanPathCache )
  @@ -155,7 +165,7 @@
   
                   if (path == null)
                   {
  -                    path = XqrlPathImpl.create( pathExpr, currentNodeVar );
  +                    path = XqrlPathImpl.create( pathExpr, options );
   
                       if (path != null)
                           _xqrlPathCache.put( path.getPathExpr(), path );
  @@ -202,7 +212,6 @@
       public static String getCompiledQuery ( String queryExpr, XmlOptions options )
       {
           Query query = null;
  -        String currentNodeVar = getCurrentNodeVar( options );
           
           synchronized ( _xqrlQueryCache )
           {
  @@ -210,7 +219,7 @@
   
               if (query == null)
               {
  -                query = XqrlDelegate.compileQuery( queryExpr, currentNodeVar );
  +                query = XqrlDelegate.compileQuery( queryExpr, options );
   
                   if (query != null)
                       _xqrlQueryCache.put( query.getQueryExpr(), query );
  @@ -250,11 +259,11 @@
           private String _pathExpr;
           private Query  _compiledPath;
   
  -        static Path create ( String pathExpr, String currentNodeVar )
  +        static Path create ( String pathExpr, XmlOptions options )
           {
               return new XqrlPathImpl(
                   pathExpr,
  -                XqrlDelegate.compilePath( pathExpr, currentNodeVar ) );
  +                XqrlDelegate.compilePath( pathExpr, options ) );
           }
   
           protected PathEngine execute (
  
  
  
  1.4       +7 -6      xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/XqrlDelegate.java
  
  Index: XqrlDelegate.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/XqrlDelegate.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XqrlDelegate.java	12 Feb 2004 20:06:04 -0000	1.3
  +++ XqrlDelegate.java	3 Mar 2004 02:03:50 -0000	1.4
  @@ -16,6 +16,7 @@
   package org.apache.xmlbeans.impl.store;
   
   import java.lang.reflect.Method;
  +import org.apache.xmlbeans.XmlOptions;
   
   public final class XqrlDelegate 
   {
  @@ -33,19 +34,19 @@
           }
       }
   
  -    static Path.Query compilePath ( String path, String currentNodeVar )
  +    static Path.Query compilePath ( String path, XmlOptions options )
       {
           return
               (Path.Query)
  -                invoke( _compilePath, new Object[] { path, currentNodeVar } );
  +                invoke( _compilePath, new Object[] { path, options } );
       }
       
  -    static Path.Query compileQuery ( String queryExpr, String currentNodeVar )
  +    static Path.Query compileQuery ( String queryExpr, XmlOptions options )
       {
           return
               (Path.Query)
                   invoke(
  -                    _compileQuery, new Object[] { queryExpr, currentNodeVar, new Boolean(true)
} );
  +                    _compileQuery, new Object[] { queryExpr, options, new Boolean(true)
} );
       }
       
       private static void throwRuntimeException ( Throwable e )
  @@ -113,12 +114,12 @@
                   _compilePath =
                       xqrlImpl.getDeclaredMethod(
                           "compilePath",
  -                        new Class[] { String.class, String.class } );
  +                        new Class[] { String.class, XmlOptions.class } );
   
                   _compileQuery =
                       xqrlImpl.getDeclaredMethod(
                           "compileQuery",
  -                        new Class[] { String.class, String.class, Boolean.class } );
  +                        new Class[] { String.class, XmlOptions.class, Boolean.class } );
                   
               }
               catch ( Exception e )
  
  
  
  1.4       +1 -1      xml-xmlbeans/v1/test/src/drt/drtcases/JaxenXPathTests.java
  
  Index: JaxenXPathTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/test/src/drt/drtcases/JaxenXPathTests.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JaxenXPathTests.java	12 Feb 2004 20:06:04 -0000	1.3
  +++ JaxenXPathTests.java	3 Mar 2004 02:03:50 -0000	1.4
  @@ -42,7 +42,7 @@
           }
           catch (ClassNotFoundException e)
           {
  -            System.out.println("\n\nWARNING!!!\n\nJaxen.jar not on classpath skipping this
test.\n\n");
  +            System.out.println("\n\nWARNING!!!\n\nJaxen.jar not on classpath skipping JaxenXPathTests.\n\n");
               return new TestSuite();
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message