jkesselm    01/04/27 11:12:15

  Modified:    java/src/org/apache/xml/dtm Tag: DTM_EXP DTM.java
                        DTMBuilder.java DTMDocumentImpl.java
               java/src/org/apache/xml/dtm/dom2dtm Tag: DTM_EXP
                        DOM2DTM.java
  Log:
  DTMBuilder to DTMDocumentImpl connections established.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.10  +29 -47    xml-xalan/java/src/org/apache/xml/dtm/Attic/DTM.java
  
  Index: DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTM.java,v
  retrieving revision 1.1.2.9
  retrieving revision 1.1.2.10
  diff -u -r1.1.2.9 -r1.1.2.10
  --- DTM.java  2001/04/27 16:33:00     1.1.2.9
  +++ DTM.java  2001/04/27 18:12:06     1.1.2.10
  @@ -209,29 +209,13 @@
     public int getLastChild(int nodeHandle);
   
     /**
  -   * Retrieves an attribute node by qualified name. 
  -   * <br>To retrieve an attribute node by local name and namespace URI, 
  -   * use the <code>getAttributeNode(ns,local)</code> method.
  -   *
  -   * %REVIEW% I don't think XPath model needs it... but DOM support might.
  -   *
  -   * @param name The qualified name of the attribute to 
  -   *   retrieve.
  -   * @return The attribute node handle with the specified name (
  -   *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such 
  -   *   attribute.
  -   */
  -  public int getAttributeNode(String name);
  -
  -  /**
      * Retrieves an attribute node by local name and namespace URI
      *
  -   * %REVIEW% Note that this uses method overloading by argument signature.
  -   * since we also have the single-string lookup by qname.
  -   * If we ever want to port this to a language which doesn't support this
  -   * capability, we might want to rename this to getAttributeNodeNS.
  +   * %TBD% Note that we currently have no way to support
  +   * the DOM's old getAttribute() call, which accesses only the qname.
      *
  -   * @param name The namespace URI of the attribute to 
  +   * @param elementHandle Handle of the node upon which to look up this 
attribute.
  +   * @param namespaceURI The namespace URI of the attribute to 
      *   retrieve, or null.
      * @param name The local name of the attribute to 
      *   retrieve.
  @@ -239,7 +223,7 @@
      *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such 
      *   attribute.
      */
  -  public int getAttributeNode(String namespaceURI, String name);
  +  public int getAttributeNode(int elementHandle,String namespaceURI, String 
name);
   
     /**
      * Given a node handle, get the index of the node's first attribute.
  @@ -572,14 +556,13 @@
     public boolean isSupported(String feature, 
                                String version);
     
  -  /**
  -   * Return the base URI of the specified node. If it is not known
  -   * (because the document was parsed from a socket connection or from
  -   * standard input, for example), the value of this property is null.
  -   * If you need the document's base URI, you can retrieve the Document
  -   * node and then ask it this question.
  +  /** Return the base URI of the specified node's Document node. If it
  +   * is not known (because the document was parsed from a socket
  +   * connection or from standard input, for example), the value of
  +   * this property is null.  If you need the document's base URI, you
  +   * can retrieve the Document node and then ask it this question.
      *
  -   * %REVIEW% Should this query any node, or only the Document?
  +   * %REVIEW% Should this the base URI at the specified node instead?
      * (The Document's base URI may not match that of other nodes,
      * due to External Parsed Entities and <xml:base/>. Supporting that
      * would require tagging nodes with their base URI, or reintroducing
  @@ -587,8 +570,8 @@
      *
      * @param nodeHandle The node id, which can be any valid node handle.
      * @return the document base URI String object or null if unknown.
  -   */
  -  public String getNodeBaseURI(int nodeHandle);
  +   * */
  +  public String getDocumentBaseURI(int nodeHandle);
   
     /**
      * Return the system identifier of the document entity. If
  @@ -664,7 +647,7 @@
      *
      * @return the public identifier String object, or null if there is none.
      */
  -  public int getDocumentTypeDeclarationPublicIdentifier();
  +  public String getDocumentTypeDeclarationPublicIdentifier();
   
     /**
      * Returns the <code>Element</code> whose <code>ID</code> is given by 
  @@ -848,32 +831,31 @@
         // Should it be a separate interface to make that distinction explicit?
         // I suspect we need element and attribute factories, maybe others.
     
  -  /**
  -   * Append a child to the end of the document. Please note that the node 
  -   * is always cloned if it is owned by another document.
  -   * <p>
  -   * %REVIEW% "End of the document" needs to be defined better. I believe the
  -   * intent is equivalent to the DOM sequence
  -   * currentInsertPoint.appendChild(document.importNode(newChild)))
  +  /** Append a child to "the end of the document". Please note that
  +   * the node is always cloned in a base DTM, since our basic behavior
  +   * is immutable so nodes can't be removed from their previous
  +   * location.
  +   *
  +   * <p> %REVIEW%  DTM maintains an insertion cursor which
  +   * performs a depth-first tree walk as nodes come in, and this operation
  +   * is really equivalent to:
  +   *    insertionCursor.appendChild(document.importNode(newChild)))
      * where the insert point is the last element that was appended (or
  -   * the last one popped back to by an end-element operation),
  -   * but we need to nail that down more explicitly.
  -   * <p>
  -   * %REVIEW% ISSUE -- In DTM, I believe we must ALWAYS clone the node, since
  -   * the base DTM is immutable and nodes never exist in isolation.
  -   * 
  +   * the last one popped back to by an end-element operation).</p>
  +   *
      * @param newChild Must be a valid new node handle.
      * @param clone true if the child should be cloned into the document.
      * @param cloneDepth if the clone argument is true, specifies that the 
  -   *                   clone should include all it's children.
  -   */
  +   *                   clone should include all it's children.  */
     public void appendChild(int newChild, boolean clone, boolean cloneDepth);
   
     /**
      * Append a text node child that will be constructed from a string, 
      * to the end of the document. Behavior is otherwise like appendChild().
      * 
  -   * @param str Non-null reverence to a string.
  +   * @param str Non-null reference to a string.
      */
     public void appendTextChild(String str);
   }
  +
  +
  
  
  
  1.1.2.3   +72 -34    
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMBuilder.java
  
  Index: DTMBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMBuilder.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DTMBuilder.java   2001/04/27 16:33:01     1.1.2.2
  +++ DTMBuilder.java   2001/04/27 18:12:07     1.1.2.3
  @@ -107,6 +107,14 @@
     // Data
     //
   
  +  /** Document being built.
  +   *
  +   * <p>%TBD% The DTM API doesn't currently have construction calls,
  +   * so this is explicitly defined as a DTMDocumentImpl. That needs to
  +   * be fixed.</p>
  +   * */
  +  private DTMDocumentImpl m_dtm;
  +
     private CoroutineManager fCoroutineManager = null;
     private int fAppCoroutine = -1;
     private int fParserCoroutine = -1;
  @@ -135,31 +143,42 @@
     //
     // Constructors
     //
  -  public DTMBuilder(DTM dtm, InputSource source, org.xml.sax.XMLReader 
parser)
  +
  +  /*
  +   * @param dtm DTM object to be written into
  +   * <p>%TBD% The DTM API doesn't currently have construction calls,
  +   * so this is explicitly defined as a DTMDocumentImpl. That needs to
  +   * be fixed.</p>
  +   * @param source SAX InputSource to read the XML document from.
  +   * @param parser SAX XMLReader to be used to parse source into dtm
  +   * */
  +  public DTMBuilder(DTMDocumentImpl dtm, InputSource source, 
org.xml.sax.XMLReader parser)
     {
  +    m_dtm=dtm;
  +    
       // Start with persistant shared pools unless the DTM expresses
       // other preferences
  -    localElementNames=dtm.getElementNameTable();
  +    localElementNames=m_dtm.getElementNameTable();
       if(localElementNames==null)
  -      dtm.setElementNameTable(localElementNames=commonLocalElementNames);
  +      m_dtm.setElementNameTable(localElementNames=commonLocalElementNames);
   
  -    localAttributeNames=dtm.getAttributeNameTable();
  +    localAttributeNames=m_dtm.getAttributeNameTable();
       if(localAttributeNames==null)
  -      
dtm.setAttributeNameTable(localAttributeNames=commonLocalAttributeNames);
  +      
m_dtm.setAttributeNameTable(localAttributeNames=commonLocalAttributeNames);
   
  -    namespaceNames=dtm.getNsNameTable();
  +    namespaceNames=m_dtm.getNsNameTable();
       if(namespaceNames==null)
  -      dtm.setNsNameTable(namespaceNames=commonNamespaceNames);
  +      m_dtm.setNsNameTable(namespaceNames=commonNamespaceNames);
   
  -    prefixes=dtm.getPrefixNameTable();
  +    prefixes=m_dtm.getPrefixNameTable();
       if(prefixes==null)
  -      dtm.setPrefixNameTable(prefixes=commonPrefixes);
  +      m_dtm.setPrefixNameTable(prefixes=commonPrefixes);
   
       // Unlike the other strings, which may be shared and thus should be
       // reset elsewhere (if at all), content starts empty each time we parse.
  -    content=dtm.getContentBuffer();
  +    content=m_dtm.getContentBuffer();
       if(content==null)
  -      dtm.setContentBuffer(content=new FastStringBuffer());
  +      m_dtm.setContentBuffer(content=new FastStringBuffer());
       else
         content.reset();
       contentStart=0;
  @@ -180,7 +199,17 @@
       // Begin incremental parsing
       // Note that this doesn't return until the first chunk of parsing
       // has been completed and the parser coroutine yields.
  -    fCoroutineManager.co_resume(source,fAppCoroutine,fParserCoroutine);
  +    try
  +      {
  +     fCoroutineManager.co_resume(source,fAppCoroutine,fParserCoroutine);
  +      }
  +    catch(NoSuchMethodException e)
  +      {
  +     // Shouldn't happen unless we've miscoded our coroutine logic
  +     // "Shut down the garbage smashers on the detention level!"
  +     e.printStackTrace(System.err);
  +     fCoroutineManager.co_exit(fAppCoroutine);
  +      }
     }
     
     //
  @@ -194,7 +223,7 @@
       if(len!=contentStart)
         {
        // The FastStringBuffer has been previously agreed upon
  -     dtm.appendTextChild(contentStart,len-contentStart);
  +     m_dtm.appendTextChild(contentStart,len-contentStart);
        contentStart=len;
         }
     }
  @@ -215,7 +244,7 @@
     {
       // May need to tell the low-level builder code to pop up a level.
       // There _should't_ be any significant pending text at this point.
  -    dtm.endDocument();
  +    m_dtm.appendEndDocument();
     }
     public void endElement(java.lang.String namespaceURI, java.lang.String 
localName,
         java.lang.String qName) 
  @@ -224,7 +253,7 @@
       processAccumulatedText();
       // No args but we do need to tell the low-level builder code to
       // pop up a level.
  -    dtm.endElement();
  +    m_dtm.appendEndElement();
     }
     public void endPrefixMapping(java.lang.String prefix) 
          throws org.xml.sax.SAXException
  @@ -256,7 +285,7 @@
          throws org.xml.sax.SAXException
     {
       // No-op for DTM?
  -    //dtm.startDocument();
  +    //m_dtm.startDocument();
     }
     public void startElement(java.lang.String namespaceURI, java.lang.String 
localName,
         java.lang.String qName, Attributes atts) 
  @@ -271,7 +300,7 @@
         prefix=qName.substring(0,colon);
   
       // %TBD% Where do we pool expandedName, or is it just the union, or...
  -    dtm.startElement(namespaceNames.stringToIndex(namespaceURI),
  +    m_dtm.startElement(namespaceNames.stringToIndex(namespaceURI),
                     localElementNames.stringToIndex(localName),
                     prefixes.stringToIndex(prefix)); /////// %TBD%
   
  @@ -285,22 +314,21 @@
        qName=atts.getQName(i);
        if(qName.startsWith("xmlns:") || "xmlns".equals(qName))
          {
  -         
  -         // %TBD% I hate having to extract the prefix into a new
  -         // string when we may never use it. Consider pooling whole
  -         // qNames, which are already strings?
            prefix=null;
            colon=qName.indexOf(':');
            if(colon>0)
  -           prefix=qName.substring(0,colon);
  -         
  -         content.append(atts.getValue(i)); // Single-string value
  -         int contentEnd=content.length();
  +           {
  +             prefix=qName.substring(0,colon);
  +           }
  +         else
  +           {
  +             prefix=""; // Default prefix
  +           }
            
  -         
dtm.appendNSDeclaration(namespaceNames.stringToIndex(atts.getURI(i)),
  -                                 
localAttributeNames.stringToIndex(localName),
  +
  +         m_dtm.appendNSDeclaration(
                                    prefixes.stringToIndex(prefix),
  -                                 contentStart, contentEnd-contentStart,
  +                                 
namespaceNames.stringToIndex(atts.getValue(i)),
                                    atts.getType(i).equalsIgnoreCase("ID"));
          }
         }
  @@ -316,18 +344,26 @@
            prefix=null;
            colon=qName.indexOf(':');
            if(colon>0)
  -           prefix=qName.substring(0,colon);
  +           {
  +             prefix=qName.substring(0,colon);
  +             localName=qName.substring(colon+1);
  +           }
  +         else
  +           {
  +             prefix=""; // Default prefix
  +             localName=qName;
  +           }
            
  +         
            content.append(atts.getValue(i)); // Single-string value
            int contentEnd=content.length();
            
            if(!("xmlns".equals(prefix) || "xmlns".equals(qName)))
  -           dtm.appendAttribute(namespaceNames.stringToIndex(atts.getURI(i)),
  +           
m_dtm.appendAttribute(namespaceNames.stringToIndex(atts.getURI(i)),
                                  localAttributeNames.stringToIndex(localName),
                                  prefixes.stringToIndex(prefix),
                                  atts.getType(i).equalsIgnoreCase("ID"),
  -                               contentStart, contentEnd-contentStart,
  -                               atts.getType(i).equalsIgnoreCase("ID"));
  +                               contentStart, contentEnd-contentStart);
            contentStart=contentEnd;
          }
         }
  @@ -348,7 +384,7 @@
       processAccumulatedText();
   
       content.append(ch,start,length); // Single-string value
  -    dtm.appendComment(contentStart,length);
  +    m_dtm.appendComment(contentStart,length);
       contentStart+=length;    
     }
     public void endCDATA() 
  @@ -430,7 +466,6 @@
            System.err.println("\tStopping parser rather than risk deadlock");
            throw new RuntimeException("Coroutine parameter error ("+arg+')');
          }
  -
         }
       catch(java.lang.NoSuchMethodException e)
         {
  @@ -439,6 +474,9 @@
        e.printStackTrace(System.err);
        fCoroutineManager.co_exit(fAppCoroutine);
         }
  +
  +    // Only reached if NoSuchMethodException was thrown (no coroutine)
  +    return(false); 
     }
   
   } // class DTMBuilder
  
  
  
  1.1.2.3   +108 -5    
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDocumentImpl.java
  
  Index: DTMDocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDocumentImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DTMDocumentImpl.java      2001/04/27 16:33:01     1.1.2.2
  +++ DTMDocumentImpl.java      2001/04/27 18:12:08     1.1.2.3
  @@ -702,7 +702,7 @@
        /**
         * Retrieves an attribute node by by qualified name and namespace URI.
         *
  -      * @param nodeHandle int Handle of the node.
  +      * @param node Handle of the node upon which to look up this attribute.
         * @param namespaceURI The namespace URI of the attribute to
         *   retrieve, or null.
         * @param name The local name of the attribute to
  @@ -711,7 +711,7 @@
         *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
         *   attribute.
         */
  -     public int getAttributeNode(int nodeHandle, String namespaceURI, String 
name) {
  +     public int getAttributeNode(int node,String namespaceURI, String name) {
                //m_nsNames.stringToIndex(namespaceURI);
                return -1;
        }
  @@ -1269,7 +1269,10 @@
         *
         * @return the public identifier String object, or null if there is 
none.
         */
  -     public int getDocumentTypeDeclarationPublicIdentifier() {return 0;}
  +     public String getDocumentTypeDeclarationPublicIdentifier()
  +        {
  +       return null; // %TBD%
  +     }
   
        /**
         * Returns the <code>Element</code> whose <code>ID</code> is given by
  @@ -1461,9 +1464,109 @@
         * <p>%REVIEW% "End of the document" needs to be defined more clearly.
         * Does it become the last child of the Document? Of the root 
element?</p>
         *
  -      * @param str Non-null reverence to a string.
  +      * @param str Non-null reference to a string.
         */
        public void appendTextChild(String str) {}
  -}
   
  +  // ==== BUILDER methods (should probably replace above construction 
methods) =====
   
  +  /** Append a text child at the current insertion point. Assumes that the
  +   * actual content of the text has previously been appended to the m_char
  +   * buffer (shared with the builder).
  +   *
  +   * @param contentStart int Starting offset of node's content in m_char.
  +   * @param contentLength int Length of node's content in m_char.
  +   * */
  +  void appendTextChild(int contentStart,int contentLength)
  +  {
  +    // %TBD%
  +  }
  +  
  +  /** Append a comment child at the current insertion point. Assumes that the
  +   * actual content of the comment has previously been appended to the m_char
  +   * buffer (shared with the builder).
  +   *
  +   * @param contentStart int Starting offset of node's content in m_char.
  +   * @param contentLength int Length of node's content in m_char.
  +   * */
  +  void appendComment(int contentStart,int contentLength)
  +  {
  +    // %TBD%
  +  }
  +  
  +  
  +  /** Append an Element child at the current insertion point. This
  +   * Element then _becomes_ the insertion point; subsequent appends
  +   * become its lastChild until an appendEndElement() call is made.
  +   * 
  +   * Assumes that the symbols (local name, namespace URI and prefix)
  +   * have already been added to the pools
  +   *
  +   * @param namespaceIndex: Index within the namespaceURI string pool
  +   * @param localNameIndex Index within the local name string pool
  +   * @param prefixIndex: Index within the prefix string pool
  +   * */
  +  void startElement(int namespaceIndex,int localNameIndex, int prefixIndex)
  +  {
  +    // %TBD%
  +  }
  +  
  +  /** Append a Namespace Declaration child at the current insertion point.
  +   * Assumes that the symbols (namespace URI and prefix) have already been
  +   * added to the pools
  +   *
  +   * @param prefixIndex: Index within the prefix string pool
  +   * @param namespaceIndex: Index within the namespaceURI string pool
  +   * @param isID: If someone really insists on writing a bad DTD, it is
  +   * theoretically possible for a namespace declaration to also be declared
  +   * as being a node ID. I don't really want to support that stupidity,
  +   * but I'm not sure we can refuse to accept it.
  +   * */
  +  void appendNSDeclaration(int prefixIndex, int namespaceIndex,
  +                        boolean isID)
  +  {
  +    // %TBD%
  +  }
  +
  +  /** Append a Namespace Declaration child at the current insertion
  +   * point.  Assumes that the symbols (namespace URI, local name, and
  +   * prefix) have already been added to the pools, and that the content has
  +   * already been appended to m_char. Note that the attribute's content has
  +   * been flattened into a single string; DTM does _NOT_ attempt to model
  +   * the details of entity references within attribute values.
  +   *
  +   * @param namespaceIndex int Index within the namespaceURI string pool
  +   * @param localNameIndex int Index within the local name string pool
  +   * @param prefixIndex int Index within the prefix string pool
  +   * @param isID boolean True if this attribute was declared as an ID
  +   * (for use in supporting getElementByID).
  +   * @param contentStart int Starting offset of node's content in m_char.
  +   * @param contentLength int Length of node's content in m_char.
  +   * */
  +  void appendAttribute(int namespaceIndex, int localNameIndex, int 
prefixIndex,
  +                    boolean isID,
  +                    int contentStart, int contentLength)
  +  {
  +    // %TBD%
  +  }
  +  
  +
  +
  +  /** Terminate the element currently acting as an insertion point. 
Subsequent
  +   * insertions will occur as the last child of this element's parent.
  +   * */
  +  void appendEndElement()
  +  {
  +    // %TBD%
  +  }
  +  
  +  /**  All appends to this document have finished; do whatever final
  +   * cleanup is needed. I expect this will actually be a no-op.
  +   * */
  +  void appendEndDocument()
  +  {
  +    // %TBD%
  +  }
  +
  +  
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +1 -1      
xml-xalan/java/src/org/apache/xml/dtm/dom2dtm/Attic/DOM2DTM.java
  
  Index: DOM2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/dom2dtm/Attic/DOM2DTM.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- DOM2DTM.java      2001/04/18 17:42:29     1.1.2.4
  +++ DOM2DTM.java      2001/04/27 18:12:13     1.1.2.5
  @@ -598,7 +598,7 @@
     /**
      * Retrieves an attribute node by by qualified name and namespace URI.
      *
  -   * @param nodeHandle int Handle of the node.
  +   * @param nodeHandle int Handle of the node upon which to look up this 
attribute..
      * @param namespaceURI The namespace URI of the attribute to
      *   retrieve, or null.
      * @param name The local name of the attribute to
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to