You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by er...@apache.org on 2003/09/26 00:40:12 UTC

cvs commit: xml-xmlbeans/v1/test/src/erictest EricTest.java

ericvas     2003/09/25 15:40:12

  Modified:    v1/src/xmlstore/org/apache/xmlbeans/impl/store Root.java
               v1/test/src/erictest EricTest.java
  Log:
  This fixes a drt failure where an instance tree becomes non-left-only after a parse when the load option addition namespaces is specified.
  
  Review: Remy
  drt: passes
  
  Revision  Changes    Path
  1.3       +32 -7     xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Root.java
  
  Index: Root.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Root.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Root.java	24 Sep 2003 23:31:16 -0000	1.2
  +++ Root.java	25 Sep 2003 22:40:12 -0000	1.3
  @@ -1228,11 +1228,6 @@
               return _root;
           }
   
  -        private Splay last ( )
  -        {
  -            return _root._leftSplay;
  -        }
  -
           private int getCp ( Splay s )
           {
               assert _root.isLeftOnly();
  @@ -1261,7 +1256,7 @@
               assert !_finished;
               assert s.getCch() == 0;
   
  -            _root.insertSplay( s, last() );
  +            _root.insertSplay( s, _root._leftSplay );
   
               _lastSplay = s;
               _lastPos = 0;
  @@ -1386,7 +1381,7 @@
   
                           if (s.namespaceForPrefix( prefix ) == null)
                           {
  -                            _root.insertSplay(
  +                            _root.insertSingleSplaySansSplayInLeftOnlyTree(
                                   new Xmlns( new QName( namespace, prefix ) ),
                                   s );
   
  @@ -2729,6 +2724,36 @@
           assert validateSplayTree();
       }
   
  +    /**
  +     * Special insert to insert a single splay into a leftonly tree without
  +     * causing the tree to go non left only.  Because this does not splay,
  +     * doing this too many times can be very inefficient.
  +     */
  +    
  +    void insertSingleSplaySansSplayInLeftOnlyTree ( Splay s, Splay a )
  +    {
  +        assert _leftOnly;
  +        assert s._rightSplay == null;
  +        assert s._leftSplay == null;
  +
  +        s._leftSplay = a;
  +        s._parentSplay = a._parentSplay;
  +        a._parentSplay._leftSplay = s;
  +        a._parentSplay = s;
  +
  +        s.adjustCchLeft( a.getCchLeft() + a.getCch() );
  +        s.adjustCdocBeginLeft( a.getCdocBeginLeft() + a.getCdocBegin() );
  +        
  +        int cch = s.getCch();
  +        int cbegin = s.getCdocBegin();
  +        
  +        for ( Splay p = s._parentSplay ; p != null ; p = p._parentSplay )
  +        {
  +            p.adjustCchLeft( cch );
  +            p.adjustCdocBeginLeft( cbegin );
  +        }
  +    }
  +            
       /**
        * Remove [ first, last ) splays from total sequence:
        *
  
  
  
  1.3       +8 -5      xml-xmlbeans/v1/test/src/erictest/EricTest.java
  
  Index: EricTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/test/src/erictest/EricTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EricTest.java	24 Sep 2003 23:31:17 -0000	1.2
  +++ EricTest.java	25 Sep 2003 22:40:12 -0000	1.3
  @@ -123,11 +123,14 @@
   {
       public static void main ( String[] args ) throws Exception
       {
  -        XmlObject x = XmlObject.Factory.parse( new File( "c:\\test\\foo.xml" ) );
  -
  -        XmlObject[] xes = x.selectPath( "declare namespace xq = 'http://openuri.org/bea/samples/workshop/xmlBeans/xquery' $this/xq:employees/xq:employee/xq:phone[@location='work']" );
  -
  -        System.out.println( xes.length );
  +        HashMap nses = new HashMap();
  +        nses.put( "x", "x.com" );
  +        nses.put( "y", "y.com" );
  +        XmlOptions options = new XmlOptions();
  +        options.setLoadAdditionalNamespaces( nses );
  +        
  +        XmlObject x = XmlObject.Factory.parse( "<a></a>", options );
  +        x.save( System.out );
       }
   }
   
  
  
  

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