You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/07/31 00:48:06 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/stree Child.java ElementImpl.java Parent.java

sboag       00/07/30 15:48:06

  Modified:    java/src/org/apache/xalan/stree Child.java ElementImpl.java
                        Parent.java
  Log:
  Try to make it possible to handle unparented nodes, at least to a point.
  
  Revision  Changes    Path
  1.4       +3 -1      xml-xalan/java/src/org/apache/xalan/stree/Child.java
  
  Index: Child.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/Child.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Child.java	2000/07/28 17:12:55	1.3
  +++ Child.java	2000/07/30 22:48:06	1.4
  @@ -119,7 +119,9 @@
      */
     DocumentImpl getDocumentImpl()
     {
    Child n = this;
    while(n.getUid() > 1)
  -      n = (Child)n.getParentNode(); 
  +      n = (Child)n.getParentNode();
  +    // if((n == null) || !(n instanceof DocumentImpl))
  +    //    return null;
       return (DocumentImpl)n;
     }
   
  
  
  
  1.5       +11 -1     xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java
  
  Index: ElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ElementImpl.java	2000/07/28 17:12:56	1.4
  +++ ElementImpl.java	2000/07/30 22:48:06	1.5
  @@ -353,7 +353,7 @@
       {
         for (int i = 0; i < getAttrCount(); i++)
         {
  -        AttrImplNS attr = (AttrImplNS)getChildAttribute(i);
  +        AttrImpl attr = (AttrImpl)getChildAttribute(i);
           if (attr.getLocalName().equals(localPart) &&
               attr.getNamespaceURI().equals(uri))
             return i;
  @@ -514,6 +514,16 @@
           return null;
         
       }
  +    
  +    /**
  +     * The number of nodes (attributes) in this map. 
  +     * The range of valid child node indices 
  +     * is <code>0</code> to <code>length-1</code> inclusive. 
  +     */
  +    public int getLength()
  +    {
  +      return getAttrCount();
  +    } // getLength():int
   
       /**
        *  Returns the <code>index</code> th item in the map. If 
  
  
  
  1.3       +16 -4     xml-xalan/java/src/org/apache/xalan/stree/Parent.java
  
  Index: Parent.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/Parent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Parent.java	2000/07/21 20:57:00	1.2
  +++ Parent.java	2000/07/30 22:48:06	1.3
  @@ -174,14 +174,26 @@
       m_children[childCount] = child;
       child.SetChildPosition(childCount);
   
  -    DocumentImpl doc = (DocumentImpl)this.getOwnerDocument();
  -    doc.incrementDocOrderCount();
  -    child.setUid(doc.getDocOrderCount());
  +    DocumentImpl doc;
  +    try
  +    {
  +      doc = (DocumentImpl)this.getOwnerDocument();
  +      doc.incrementDocOrderCount();
  +      child.setUid(doc.getDocOrderCount());
  +    }
  +    catch(ClassCastException cce)
  +    {
  +      // TODO: Make ResultTreeFrag be an Stree DocumentFragment, or some such.
  +      // No owner doc, so we can't set the document order count, 
  +      // which will be a problem when result tree fragments need to 
  +      // be treated like node-sets.
  +      doc = null;
  +    }
       child.setParent(this);
       child.setLevel((short)(getLevel() + 1));
   	  // getDocumentImpl().getLevelIndexer().insertNode(child);
       
  -    if(Node.ELEMENT_NODE == child.getNodeType())
  +    if((null != doc) && (Node.ELEMENT_NODE == child.getNodeType()))
       {
         SourceTreeHandler sh = doc.getSourceTreeHandler();
         TransformerImpl transformer = sh.getTransformer();