You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2006/05/13 00:28:27 UTC

svn commit: r405903 - in /xmlbeans/trunk/src: store/org/apache/xmlbeans/impl/store/ xmlpublic/org/apache/xmlbeans/

Author: cezar
Date: Fri May 12 15:28:25 2006
New Revision: 405903

URL: http://svn.apache.org/viewcvs?rev=405903&view=rev
Log:
Fix for assert in XmlInputStream saver plus first cut for xquery var support.

checkintest passing.


Modified:
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlCursor.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java?rev=405903&r1=405902&r2=405903&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java Fri May 12 15:28:25 2006
@@ -899,7 +899,7 @@
 
         assert _pathEngine == null;
 
-        _pathEngine = Path.getCompiledPath(pathExpr, options).execute(_cur);
+        _pathEngine = Path.getCompiledPath(pathExpr, options).execute(_cur, options);
 
         _cur._locale.registerForChange(this);
     }

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java?rev=405903&r1=405902&r2=405903&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java Fri May 12 15:28:25 2006
@@ -55,7 +55,7 @@
         boolean next(Cur c);
     }
 
-    abstract PathEngine execute(Cur c);
+    abstract PathEngine execute(Cur c, XmlOptions options);
 
     //
     //
@@ -221,7 +221,7 @@
             _compiledPath = xpath;
         }
 
-        PathEngine execute(Cur c)
+        PathEngine execute(Cur c, XmlOptions options)
         {
             // The builtin XPath engine works only on containers.  Delegate to
             // xqrl otherwise.  Also, if the path had a //. at the end, the
@@ -231,7 +231,7 @@
             if (!c.isContainer() || _compiledPath.sawDeepDot())
             {
                 int force = USE_SAXON | USE_XQRL;
-                return getCompiledPath(_pathKey, force, _currentVar).execute(c);
+                return getCompiledPath(_pathKey, force, _currentVar).execute(c, options);
             }
             return new XbeanPathEngine(_compiledPath, c);
         }
@@ -461,7 +461,7 @@
             _xpathImpl = xpathImpl;
         }
 
-        protected PathEngine execute(Cur c)
+        protected PathEngine execute(Cur c, XmlOptions options)
         {
             return new SaxonPathEngine(_xpathImpl, c);
         }

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java?rev=405903&r1=405902&r2=405903&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java Fri May 12 15:28:25 2006
@@ -2557,7 +2557,7 @@
 
             for ( int i=0; i<attrNames.size(); i++ )
             {
-                XMLName attXMLName = computeName((QName)attrNames.get(i),this);
+                XMLName attXMLName = computeName((QName)attrNames.get(i), this, true);
                 StartElementImpl.AttributeImpl attr =
                     new StartElementImpl.NormalAttributeImpl(attXMLName, (String)attrValues.get(i) );
 
@@ -2589,7 +2589,7 @@
 
 
             QName name = c.getName();
-            enqueue( new StartElementImpl( computeName(name, this), attributes, namespaces, getPrefixMap() ) );
+            enqueue( new StartElementImpl( computeName(name, this, false), attributes, namespaces, getPrefixMap() ) );
 
             return false;  // still need to be called on end element
         }
@@ -2600,7 +2600,7 @@
                 enqueue( new EndDocumentImpl(  ) );
             else
             {
-                XMLName xmlName = computeName(c.getName(), this);
+                XMLName xmlName = computeName(c.getName(), this, false);
                 enqueue( new EndElementImpl( xmlName ) );
             }
 
@@ -2716,7 +2716,7 @@
         //
         //
 
-        private static XMLName computeName ( QName name, Saver saver )
+        private static XMLName computeName ( QName name, Saver saver, boolean needsPrefix )
         {
             String uri = name.getNamespaceURI();
             String local = name.getLocalPart();
@@ -2741,7 +2741,7 @@
                 // _urpMap and _prefixMap.  This way, I would not have to look it up manually
                 // here
 
-                if (prefix.length() == 0)
+                if (needsPrefix && prefix.length() == 0)
                     prefix = saver.getNonDefaultUriMapping( uri );
 
             }

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java?rev=405903&r1=405902&r2=405903&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Fri May 12 15:28:25 2006
@@ -301,7 +301,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(java.util.Map) XmlOptions.setXqueryVariables(Map)}
+     * method to map external variable names to values.
      */
     public static String compileQuery ( String queryExpr, XmlOptions options )
         throws XmlException

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlCursor.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlCursor.java?rev=405903&r1=405902&r2=405903&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlCursor.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlCursor.java Fri May 12 15:28:25 2006
@@ -917,11 +917,30 @@
      * returns false and does not move the cursor if there are no
      * attributes. The order of attributes is arbitrary, but stable.<br/><br/>
      *
+     * If the cursor is on a STARTDOC of a document-fragment, this method will
+     * move it to the first top level attribute if one exists.<br></br>
+     *
      * xmlns attributes (namespace declarations) are not considered 
      * attributes by this function.<br/><br/>
      *
-     * The cursor must be on a START or STARTDOC for this method to
+     * The cursor must be on a START or STARTDOC (in the case of a
+     * document fragment with top level attributes) for this method to
      * succeed.
+     *
+     * Example for looping through attributes:
+     * <pre>
+     *      XmlCursor cursor = ... //cursor on START or STARTDOC
+     *      if (cursor.toFirstAttribute())
+     *      {
+     *          do
+     *          {
+     *              // do something using attribute's name and value
+     *              cursor.getName();
+     *              cursor.getTextValue();
+     *          }
+     *          while (cursor.toNextAttribute());
+     *      }
+     * </pre>
      * 
      * @return  true if the cursor was moved; otherwise, false.
      */
@@ -953,7 +972,8 @@
      * attributes by this function.<br/><br/>
      *
      * The cursor must be on an attribute for this method to succeed.
-     * 
+     * @see #toFirstAttribute()
+     *
      * @return  true if the cursor was moved; otherwise, false.
      */
 

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java?rev=405903&r1=405902&r2=405903&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java Fri May 12 15:28:25 2006
@@ -542,6 +542,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 Strings 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
@@ -783,6 +800,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";



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