elena       2003/01/16 14:53:45

  Modified:    java/src/org/apache/xerces/dom AttrImpl.java AttrNSImpl.java
                        DeferredAttrImpl.java DeferredAttrNSImpl.java
                        DeferredDocumentImpl.java
                        DeferredElementNSImpl.java DeferredNode.java
                        ElementImpl.java ElementNSImpl.java NodeImpl.java
               java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java
               java/src/org/apache/xerces/impl/xs/opti AttrImpl.java
                        DefaultElement.java
               java/src/org/apache/xerces/parsers AbstractDOMParser.java
  Added:       java/src/org/apache/xerces/dom3 TypeInfo.java
  Log:
  Implement DOM L3 TypeInfo.
  Clean up a bit DOMParser -- it used to create notation declarations from external 
DTD...
  
  Revision  Changes    Path
  1.49      +37 -2     xml-xerces/java/src/org/apache/xerces/dom/AttrImpl.java
  
  Index: AttrImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/AttrImpl.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- AttrImpl.java     31 Dec 2002 01:16:06 -0000      1.48
  +++ AttrImpl.java     16 Jan 2003 22:53:44 -0000      1.49
  @@ -61,6 +61,7 @@
   import java.io.ObjectInputStream;
   import java.io.ObjectOutputStream;
   
  +import org.apache.xerces.dom3.TypeInfo;
   import org.w3c.dom.Attr;
   import org.w3c.dom.DOMException;
   import org.w3c.dom.Element;
  @@ -149,7 +150,7 @@
    */
   public class AttrImpl
       extends NodeImpl
  -    implements Attr {
  +    implements Attr, TypeInfo{
   
       //
       // Constants
  @@ -167,6 +168,9 @@
   
       /** Attribute name. */
       protected String name;
  +    
  +    /** Type information */
  +    Object type;
   
       protected static TextImpl textNode = null;
   
  @@ -305,6 +309,28 @@
       public void setNodeValue(String value) throws DOMException {
        setValue(value);
       }
  +    
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeName()
  +     */
  +    public String getTypeName() {
  +        return (String)type;
  +    }
  +
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeNamespace()
  +     */
  +    public String getTypeNamespace() {
  +        return null;
  +    }
  +    
  +    /**
  +     * Method getSchemaTypeInfo.
  +     * @return TypeInfo
  +     */
  +    public TypeInfo getSchemaTypeInfo(){
  +      return this;
  +    }
   
       /**
        * In Attribute objects, NodeValue is considered a synonym for
  @@ -564,6 +590,14 @@
        isSpecified(arg);
   
       } // setSpecified(boolean)
  +    
  +     /**
  +      * NON-DOM: used by the parser
  +      * @param type
  +      */
  +    public void setType (Object type){
  +        this.type = type;
  +    }
   
       //
       // Object methods
  @@ -1178,5 +1212,6 @@
           needsSyncChildren(false);
   
       } // readObject(ObjectInputStream)
  +
   
   } // class AttrImpl
  
  
  
  1.33      +28 -1     xml-xerces/java/src/org/apache/xerces/dom/AttrNSImpl.java
  
  Index: AttrNSImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/AttrNSImpl.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- AttrNSImpl.java   2 Nov 2002 01:02:23 -0000       1.32
  +++ AttrNSImpl.java   16 Jan 2003 22:53:44 -0000      1.33
  @@ -58,6 +58,7 @@
   package org.apache.xerces.dom;
   
   import org.w3c.dom.DOMException;
  +import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
   import org.apache.xerces.xni.NamespaceContext;
   
   /**
  @@ -324,5 +325,31 @@
               synchronizeData();
           }
           return localName;
  +    }
  +    
  +    
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeName()
  +     */
  +    public String getTypeName() {
  +        if (type !=null){
  +            if (type instanceof XSSimpleTypeDecl){
  +                return ((XSSimpleTypeDecl)type).getName();
  +            }
  +            return (String)type;
  +        }
  +        return null;
  +    }
  +
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeNamespace()
  +     */
  +    public String getTypeNamespace() {
  +        if (type !=null){
  +            if (type instanceof XSSimpleTypeDecl){
  +                return ((XSSimpleTypeDecl)type).getNamespace();
  +            }
  +        }
  +        return null;
       }
   }
  
  
  
  1.19      +4 -2      xml-xerces/java/src/org/apache/xerces/dom/DeferredAttrImpl.java
  
  Index: DeferredAttrImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeferredAttrImpl.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DeferredAttrImpl.java     12 Apr 2002 15:43:48 -0000      1.18
  +++ DeferredAttrImpl.java     16 Jan 2003 22:53:44 -0000      1.19
  @@ -161,8 +161,10 @@
           name = ownerDocument.getNodeName(fNodeIndex);
           int extra = ownerDocument.getNodeExtra(fNodeIndex);
           isSpecified((extra & SPECIFIED) != 0);
  -        isIdAttribute((extra & IDATTRIBUTE) != 0);
  +        isIdAttribute((extra & ID) != 0);
   
  +        int extraNode = ownerDocument.getLastChild(fNodeIndex);
  +        type = ownerDocument.getTypeInfo(extraNode);        
       } // synchronizeData()
   
       /**
  
  
  
  1.23      +5 -23     
xml-xerces/java/src/org/apache/xerces/dom/DeferredAttrNSImpl.java
  
  Index: DeferredAttrNSImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeferredAttrNSImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DeferredAttrNSImpl.java   9 Aug 2002 15:18:14 -0000       1.22
  +++ DeferredAttrNSImpl.java   16 Jan 2003 22:53:44 -0000      1.23
  @@ -133,39 +133,21 @@
   
           // extract prefix and local part from QName
           int index = name.indexOf(':');
  -        String prefix;
           if (index < 0) {
  -            prefix = null;
               localName = name;
           } 
           else {
  -            prefix = name.substring(0, index); 
               localName = name.substring(index + 1);
           }
   
           int extra = ownerDocument.getNodeExtra(fNodeIndex);
           isSpecified((extra & SPECIFIED) != 0);
  -        isIdAttribute((extra & IDATTRIBUTE) != 0);
  +        isIdAttribute((extra & ID) != 0);
   
           namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
  -        // hide the fact that our parser uses an empty string for null
  -        if (namespaceURI != null && namespaceURI.length() == 0) {
  -            namespaceURI = null;
  -        }
  -     // DOM Level 2 wants all namespace declaration attributes
  -     // to be bound to "http://www.w3.org/2000/xmlns/";
  -     // So as long as the XML parser doesn't do it, it needs to
  -     // done here.
  -     if (namespaceURI == null) {
  -         if (prefix != null)  {
  -             if (prefix.equals("xmlns")) {
  -                 namespaceURI = "http://www.w3.org/2000/xmlns/";;
  -             }
  -         } else if (name.equals("xmlns")) {
  -             namespaceURI = "http://www.w3.org/2000/xmlns/";;
  -         }
  -     }
  -
  +        
  +        int extraNode = ownerDocument.getLastChild(fNodeIndex);
  +        type = ownerDocument.getTypeInfo(extraNode);
       } // synchronizeData()
   
       /**
  
  
  
  1.49      +136 -22   
xml-xerces/java/src/org/apache/xerces/dom/DeferredDocumentImpl.java
  
  Index: DeferredDocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeferredDocumentImpl.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- DeferredDocumentImpl.java 8 Aug 2002 20:45:36 -0000       1.48
  +++ DeferredDocumentImpl.java 16 Jan 2003 22:53:44 -0000      1.49
  @@ -230,19 +230,10 @@
           int chunk     = nodeIndex >> CHUNK_SHIFT;
           int index     = nodeIndex & CHUNK_MASK;
   
  -        // added for DOM2: createDoctype factory method includes
  -        // name, publicID, systemID
  -
  -        // create extra data node
  -        int extraDataIndex = createNode((short)0); // node type unimportant
  -        int echunk = extraDataIndex >> CHUNK_SHIFT;
  -        int eindex = extraDataIndex & CHUNK_MASK;
  -
           // save name, public id, system id
           setChunkValue(fNodeName, rootElementName, chunk, index);
           setChunkValue(fNodeValue, publicId, chunk, index);
           setChunkValue(fNodeURI, systemId, chunk, index);
  -        setChunkIndex(fNodeExtra, extraDataIndex, chunk, index);
   
           // return node index
           return nodeIndex;
  @@ -252,9 +243,12 @@
       public void setInternalSubset(int doctypeIndex, String subset) {
           int chunk     = doctypeIndex >> CHUNK_SHIFT;
           int index     = doctypeIndex & CHUNK_MASK;
  -        int extraDataIndex = fNodeExtra[chunk][index];
  +
  +        // create extra data node to store internal subset
  +        int extraDataIndex = createNode(Node.DOCUMENT_TYPE_NODE); 
           int echunk = extraDataIndex >> CHUNK_SHIFT;
           int eindex = extraDataIndex & CHUNK_MASK;
  +        setChunkIndex(fNodeExtra, extraDataIndex, chunk, index);        
           setChunkValue(fNodeValue, subset, echunk, eindex);
       }
   
  @@ -338,8 +332,7 @@
           return null;
       }
   
  -    // DOM Level 3
  -    // setting encoding and version
  +    // DOM Level 3: setting encoding and version
       public void setEntityInfo(int currentEntityDecl,
                                 String version, String encoding){
           int eNodeIndex = getNodeExtra(currentEntityDecl, false);
  @@ -382,12 +375,30 @@
   
       } // createDeferredEntityReference(String):int
   
  -    /** Creates an element node in the table. */
  +
  +    /** Creates an element node with a URI in the table and type information. */
  +    public int createDeferredElement(String elementURI, String elementName, 
  +                                      Object type) {
  +
  +        // create node
  +        int elementNodeIndex = createNode(Node.ELEMENT_NODE);
  +        int elementChunk     = elementNodeIndex >> CHUNK_SHIFT;
  +        int elementIndex     = elementNodeIndex & CHUNK_MASK;
  +        setChunkValue(fNodeName, elementName, elementChunk, elementIndex);
  +        setChunkValue(fNodeURI, elementURI, elementChunk, elementIndex);
  +        setChunkValue(fNodeValue, type, elementChunk, elementIndex);
  + 
  +        // return node index
  +        return elementNodeIndex;
  +
  +    } // createDeferredElement(String,String):int
  +
  +    /** @deprecated. Creates an element node in the table. */
       public int createDeferredElement(String elementName) {
           return createDeferredElement(null, elementName);
       }
   
  -    /** Creates an element node with a URI in the table. */
  +    /** @deprecated. Creates an element node with a URI in the table. */
       public int createDeferredElement(String elementURI, String elementName) {
   
           // create node
  @@ -401,8 +412,70 @@
           return elementNodeIndex;
   
       } // createDeferredElement(String,String):int
  -
  -    /** Sets an attribute on an element node. */
  +    
  +    
  +     /**
  +      * This method is used by the DOMParser to create attributes.
  +      * @param elementNodeIndex
  +      * @param attrName
  +      * @param attrURI
  +      * @param attrValue
  +      * @param specified
  +      * @param id
  +      * @param type
  +      * @return int
  +      */
  +     public int setDeferredAttribute(int elementNodeIndex,
  +                                     String attrName,
  +                                     String attrURI,
  +                                     String attrValue,
  +                                     boolean specified,
  +                                     boolean id,
  +                                     Object type) {
  +                                    
  +             // create attribute
  +             int attrNodeIndex = createDeferredAttribute(attrName, attrURI, 
attrValue, specified);
  +             int attrChunk = attrNodeIndex >> CHUNK_SHIFT;
  +             int attrIndex = attrNodeIndex & CHUNK_MASK;
  +             // set attribute's parent to element
  +             setChunkIndex(fNodeParent, elementNodeIndex, attrChunk, attrIndex);
  +
  +             int elementChunk = elementNodeIndex >> CHUNK_SHIFT;
  +             int elementIndex = elementNodeIndex & CHUNK_MASK;
  +
  +             // get element's last attribute
  +             int lastAttrNodeIndex = getChunkIndex(fNodeExtra, elementChunk, 
elementIndex);
  +             if (lastAttrNodeIndex != 0) {
  +                     int lastAttrChunk = lastAttrNodeIndex >> CHUNK_SHIFT;
  +                     int lastAttrIndex = lastAttrNodeIndex & CHUNK_MASK;
  +                     // add link from new attribute to last attribute
  +                     setChunkIndex(fNodePrevSib, lastAttrNodeIndex, attrChunk, 
attrIndex);
  +             }
  +             // add link from element to new last attribute
  +             setChunkIndex(fNodeExtra, attrNodeIndex, elementChunk, elementIndex);
  +
  +             int extra = getChunkIndex(fNodeExtra, attrChunk, attrIndex);
  +             if (id) {
  +                     extra = extra | ID;
  +                     setChunkIndex(fNodeExtra, extra, attrChunk, attrIndex);
  +                     String value = getChunkValue(fNodeValue, attrChunk, attrIndex);
  +                     putIdentifier(value, elementNodeIndex);
  +             }
  +             // store type information
  +             if (type != null) {
  +                     int extraDataIndex = createNode(DeferredNode.TYPE_NODE);
  +                     int echunk = extraDataIndex >> CHUNK_SHIFT;
  +                     int eindex = extraDataIndex & CHUNK_MASK;
  +
  +                     setChunkIndex(fNodeLastChild, extraDataIndex, attrChunk, 
attrIndex);
  +                     setChunkValue(fNodeValue, type, echunk, eindex);
  +             }
  +
  +             // return node index
  +             return attrNodeIndex;
  +     }
  +    
  +    /** @deprecated. Sets an attribute on an element node.*/
       public int setDeferredAttribute(int elementNodeIndex,
                                       String attrName, String attrURI,
                                       String attrValue, boolean specified) {
  @@ -461,7 +534,7 @@
   
       } // createDeferredAttribute(String,String,String,boolean):int
   
  -    /** Creates an element definition in the table. */
  +    /** Creates an element definition in the table.*/
       public int createDeferredElementDefinition(String elementName) {
   
           // create node
  @@ -680,7 +753,7 @@
           int chunk = attrIndex >> CHUNK_SHIFT;
           int index = attrIndex & CHUNK_MASK;
           int extra = getChunkIndex(fNodeExtra, chunk, index);
  -        extra = extra | IDATTRIBUTE;
  +        extra = extra | ID;
           setChunkIndex(fNodeExtra, extra, chunk, index);
   
           String value = getChunkValue(fNodeValue, chunk, index);
  @@ -694,7 +767,7 @@
           int chunk = attrIndex >> CHUNK_SHIFT;
           int index = attrIndex & CHUNK_MASK;
           int extra = getChunkIndex(fNodeExtra, chunk, index);
  -        extra = extra | IDATTRIBUTE;
  +        extra = extra | ID;
           setChunkIndex(fNodeExtra, extra, chunk, index);
       }
   
  @@ -1176,6 +1249,32 @@
       public String getNodeValue(int nodeIndex) {
           return getNodeValue(nodeIndex, true);
       }
  +    
  +     /**
  +      * Clears the type info that is stored in the fNodeValue array
  +      * @param nodeIndex
  +      * @return Object - type information for the attribute/element node
  +      */
  +    public Object getTypeInfo(int nodeIndex) {
  +        if (nodeIndex == -1) {
  +            return null;
  +        }
  +
  +        int chunk = nodeIndex >> CHUNK_SHIFT;
  +        int index = nodeIndex & CHUNK_MASK;
  +        
  +        
  +        Object value = fNodeValue[chunk][index];
  +        if (value != null) {
  +            fNodeValue[chunk][index] = null;
  +            RefCount c = (RefCount) fNodeValue[chunk][CHUNK_SIZE];
  +            c.fCount--;
  +            if (c.fCount == 0) {
  +                fNodeValue[chunk] = null;
  +            }
  +        }
  +        return value;
  +    }
   
       /**
        * Returns the value of the given node.
  @@ -1361,6 +1460,7 @@
                           case Node.ENTITY_REFERENCE_NODE: { 
System.out.print("ERef"); break; }
                           case Node.TEXT_NODE: { System.out.print("Text"); break; }
                           case Node.ATTRIBUTE_NODE: { System.out.print("Attr"); 
break; }
  +                        case DeferredNode.TYPE_NODE: { 
System.out.print("TypeInfo"); break; }
                           default: { System.out.print("?"+fNodeType[i][CHUNK_SIZE]); }
                       }
                       System.out.print('\t');
  @@ -1413,12 +1513,13 @@
                       case Node.ENTITY_REFERENCE_NODE: { System.out.print("ERef"); 
break; }
                       case Node.TEXT_NODE: { System.out.print("Text"); break; }
                       case Node.ATTRIBUTE_NODE: { System.out.print("Attr"); break; }
  +                    case DeferredNode.TYPE_NODE: { System.out.print("TypeInfo"); 
break; }
                       default: { System.out.print("?"+getChunkIndex(fNodeType, chunk, 
index)); }
                   }
                   System.out.print('\t');
                   System.out.print(getChunkValue(fNodeName, chunk, index));
                   System.out.print('\t');
  -                System.out.print(getChunkValue(fNodeValue, chunk, index));
  +                System.out.print(getNodeValue(chunk, index));
                   System.out.print('\t');
                   System.out.print(getChunkValue(fNodeURI, chunk, index));
                   System.out.print('\t');
  @@ -1772,7 +1873,6 @@
   
       /** Creates a node of the specified type. */
       protected int createNode(short nodeType) {
  -
           // ensure tables are large enough
           int chunk = fNodeCount >> CHUNK_SHIFT;
           int index = fNodeCount & CHUNK_MASK;
  @@ -1907,6 +2007,20 @@
       private final String getChunkValue(Object data[][], int chunk, int index) {
           return data[chunk] != null ? (String) data[chunk][index] : null;
       }
  +    private final String getNodeValue(int chunk, int index) {
  +        Object data = fNodeValue[chunk][index];
  +        if (data == null){
  +            return null;
  +        }
  +        else if (data instanceof String){
  +            return (String)data;
  +        }
  +        else {
  +            // type information
  +            return data.toString();
  +        }
  +    }
  +    
   
       /**
        * Clears the specified value in the given data at the chunk and index.
  
  
  
  1.16      +4 -6      
xml-xerces/java/src/org/apache/xerces/dom/DeferredElementNSImpl.java
  
  Index: DeferredElementNSImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeferredElementNSImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DeferredElementNSImpl.java        9 Aug 2002 15:18:14 -0000       1.15
  +++ DeferredElementNSImpl.java        16 Jan 2003 22:53:44 -0000      1.16
  @@ -66,6 +66,7 @@
   
   package org.apache.xerces.dom;
   
  +import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
   import org.w3c.dom.NamedNodeMap;
   
   /**
  @@ -145,11 +146,8 @@
               localName = name.substring(index + 1);
           }
   
  -     namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
  -        // hide the fact that our parser uses an empty string for null
  -        if (namespaceURI != null && namespaceURI.length() == 0) {
  -            namespaceURI = null;
  -        }
  +         namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
  +        type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex);
   
           // attributes
           setupDefaultAttributes();
  
  
  
  1.6       +4 -1      xml-xerces/java/src/org/apache/xerces/dom/DeferredNode.java
  
  Index: DeferredNode.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeferredNode.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DeferredNode.java 29 Jan 2002 01:15:07 -0000      1.5
  +++ DeferredNode.java 16 Jan 2003 22:53:44 -0000      1.6
  @@ -66,6 +66,9 @@
    */
   public interface DeferredNode extends Node {
   
  +
  +     public static final short TYPE_NODE  =  20;
  +
       //
       // DeferredNode methods
       //
  
  
  
  1.58      +24 -2     xml-xerces/java/src/org/apache/xerces/dom/ElementImpl.java
  
  Index: ElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ElementImpl.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- ElementImpl.java  8 Jan 2003 21:42:04 -0000       1.57
  +++ ElementImpl.java  16 Jan 2003 22:53:44 -0000      1.58
  @@ -65,6 +65,7 @@
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Text;
   
  +import org.apache.xerces.dom3.TypeInfo;
   import org.apache.xerces.util.URI;
   
   /**
  @@ -93,7 +94,7 @@
    */
   public class ElementImpl
       extends ParentNode
  -    implements Element {
  +    implements Element, TypeInfo {
   
       //
       // Constants
  @@ -994,7 +995,28 @@
               ownerDocument.putIdentifier(at.getValue(), this);
           }
      }
  +   
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeName()
  +     */
  +     public String getTypeName() {
  +        return null;
  +     }
  +
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeNamespace()
  +     */
  +    public String getTypeNamespace() {
  +        return null;
  +    }
   
  +     /**
  +      * Method getSchemaTypeInfo.
  +      * @return TypeInfo
  +      */
  +    public TypeInfo getSchemaTypeInfo(){
  +      return this;
  +    }
   
       //
       // Public methods
  
  
  
  1.29      +38 -4     xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java
  
  Index: ElementNSImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ElementNSImpl.java        2 Nov 2002 01:02:23 -0000       1.28
  +++ ElementNSImpl.java        16 Jan 2003 22:53:44 -0000      1.29
  @@ -57,11 +57,11 @@
   
   package org.apache.xerces.dom;
   
  -import org.w3c.dom.DOMException;
  -import org.w3c.dom.Attr;
  -
  +import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
   import org.apache.xerces.util.URI;
   import org.apache.xerces.xni.NamespaceContext;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.DOMException;
   
   
   
  @@ -94,6 +94,9 @@
     
       /** DOM2: localName. */
       protected String localName;
  +    
  +    /** DOM3: type information */
  +    XSTypeDefinition type;
   
       protected ElementNSImpl() {
           super();
  @@ -357,4 +360,35 @@
           }
           return baseURI;
       }
  +    
  +        
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeName()
  +     */
  +    public String getTypeName() {        
  +        if (type !=null){
  +            return type.getName();
  +        }
  +        return null;
  +    }
  +
  +    /**
  +     * @see org.apache.xerces.dom3.TypeInfo#getTypeNamespace()
  +     */
  +    public String getTypeNamespace() {
  +        if (type !=null){
  +            return type.getNamespace();
  +        }
  +        return null;
  +    }
  +    
  +    
  +    /**
  +     * NON-DOM: setting type used by the DOM parser
  +     * @see NodeImpl#setReadOnly
  +     */
  +    public void setType(XSTypeDefinition type) {
  +        type = type;
  +    }
  +    
   }
  
  
  
  1.61      +4 -4      xml-xerces/java/src/org/apache/xerces/dom/NodeImpl.java
  
  Index: NodeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/NodeImpl.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- NodeImpl.java     20 Nov 2002 00:49:46 -0000      1.60
  +++ NodeImpl.java     16 Jan 2003 22:53:44 -0000      1.61
  @@ -190,7 +190,7 @@
       protected final static short IGNORABLEWS  = 0x1<<6;
       protected final static short HASSTRING    = 0x1<<7;
       protected final static short UNNORMALIZED = 0x1<<8;
  -    protected final static short IDATTRIBUTE  = 0x1<<9;
  +    protected final static short ID           = 0x1<<9;
   
       //
       // Constructors
  @@ -1725,11 +1725,11 @@
       }
   
       final boolean isIdAttribute() {
  -        return (flags & IDATTRIBUTE) != 0;
  +        return (flags & ID) != 0;
       }
   
       final void isIdAttribute(boolean value) {
  -        flags = (short) (value ? flags | IDATTRIBUTE : flags & ~IDATTRIBUTE);
  +        flags = (short) (value ? flags | ID : flags & ~ID);
       }
   
       //
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/dom3/TypeInfo.java
  
  Index: TypeInfo.java
  ===================================================================
  /*
   * Copyright (c) 2002 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE.
   * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
   */
  package org.apache.xerces.dom3;
  
  /**
   *  The <code>TypeInfo</code> interface represent a type referenced from 
   * <code>Element</code> or <code>Attr</code> nodes, specified in the schemas 
   * associated with the document. The type is a pair of a namespace URI and 
   * name properties, and depends on the document's schema.  should you be 
   * able to return <code>null</code> on <code>name</code>? for anonymous 
   * type? for undeclared elements/attributes? Can schemaType be 
   * <code>null</code>? 
   * <p> If the document's schema is an XML DTD [<a 
href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>], the values are 
computed as 
   * follows:  If this type is referenced from an <code>Attr</code> node, 
   * <code>namespace</code> is <code>null</code> and <code>name</code> 
   * represents the [attribute type] property in the [<a 
href='http://www.w3.org/TR/2001/REC-xml-infoset-20011024/'>XML Information set</a>]. 
If there is no 
   * declaration for the attribute, <code>name</code> is <code>null</code>.  
   * Unlike for XML Schema, the name contain the declared type, and does not 
   * relate to "validity".  If this type is referenced from an 
   * <code>Element</code> node, the <code>namespace</code> and 
   * <code>name</code> are <code>null</code>. 
   * <p> 
   * If the document's schema is an XML Schema [XML Schema Part 1], the
   * values are computed as follows (for definitions see Post-Schema
   * Validation infoset):
   * <p>If the [validity] property exists AND is "invalid" or "notKnown":
   * the {target namespace} and {name} properties of the declared type 
   * if available, otherwise null.
   * <p>Note: At the time of writing, the XML Schema specification does not 
   * require exposing the declared type. Thus, DOM implementations
   * might choose not to provide type information if validity is not valid.
   * <p>If the [validity] property exists and is "valid" the name and namespace
   * computed as follows:
   * <p>a) If [member type definition] exists, then expose the 
   * {target namespace} and {name} properties of the 
   * [member type definition] property;
   * <p>b) If the [member type definition namespace] and the 
   * [member type definition name] exist, then expose these properties.
   * <p>c) If the [type definition] property exists, then expose the {target
   * namespace} and {name} properties of the [type definition] property;
   * <p>d) If the [type definition namespace] and the [type definition name]
   * exist, then expose these properties.
   * 
   * <p> Note: At the time of writing, the XML Schema specification does not
   * define how to expose annonimous types. If future specifications
   * define how to expose annonimous types, DOM implementations can expose
   * annonimous types via "name" and "namespace" parameters.
   * 
   * Other schema languages are outside the scope of the 
   * W3C and therefore should define how to represent their type systems using 
   * <code>TypeInfo</code>. 
   * <p>See also the <a 
href='http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20021022'>Document Object Model 
(DOM) Level 3 Core Specification</a>.
   * @since DOM Level 3
   */
  public interface TypeInfo {
      /**
       *  The name of a type declared for the associated element or attribute, 
       * or <code>null</code> if unknown. Implementations may also use 
       * <code>null</code> to represent XML Schema anonymous types. "name" 
       * seems too generic and may conflict. shoud we rename it?
       */
      public String getTypeName();
  
      /**
       *  The namespace of the type declared for the associated element or 
       * attribute or <code>null</code> if the element does not have 
       * declaration or if no namespace information is available. 
       * Implementations may also use <code>null</code> to represent XML 
       * Schema anonymous types. "namespace" seems too generic and may 
       * conflict. shoud we rename it?
       */
      public String getTypeNamespace();
  
  }
  
  
  
  1.28      +11 -1     
xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
  
  Index: XSSimpleTypeDecl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- XSSimpleTypeDecl.java     14 Jan 2003 20:21:44 -0000      1.27
  +++ XSSimpleTypeDecl.java     16 Jan 2003 22:53:45 -0000      1.28
  @@ -2190,5 +2190,15 @@
           // REVISIT: implement
                return null;
        }
  +    
  +    
  +
  +     /**
  +      * @see java.lang.Object#toString()
  +      */
  +     public String toString() {
  +        
  +             return this.fTargetNamespace+"," +this.fTypeName;
  +     }
   
   } // class XSSimpleTypeDecl
  
  
  
  1.4       +10 -1     xml-xerces/java/src/org/apache/xerces/impl/xs/opti/AttrImpl.java
  
  Index: AttrImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/opti/AttrImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AttrImpl.java     3 Jan 2003 00:18:21 -0000       1.3
  +++ AttrImpl.java     16 Jan 2003 22:53:45 -0000      1.4
  @@ -57,6 +57,7 @@
   
   package org.apache.xerces.impl.xs.opti;
   
  +import org.apache.xerces.dom3.TypeInfo;
   import org.w3c.dom.Attr;
   import org.w3c.dom.Node;
   import org.w3c.dom.Element;
  @@ -127,6 +128,14 @@
        */
       public boolean getIsId(){
           return false;
  +    }
  +    
  +        /**
  +     * Method getSchemaTypeInfo.
  +     * @return TypeInfo
  +     */
  +    public TypeInfo getSchemaTypeInfo(){
  +      return null;
       }
   
   }
  
  
  
  1.5       +6 -1      
xml-xerces/java/src/org/apache/xerces/impl/xs/opti/DefaultElement.java
  
  Index: DefaultElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/opti/DefaultElement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultElement.java       8 Jan 2003 21:42:04 -0000       1.4
  +++ DefaultElement.java       16 Jan 2003 22:53:45 -0000      1.5
  @@ -57,6 +57,7 @@
   
   package org.apache.xerces.impl.xs.opti;
   
  +import org.apache.xerces.dom3.TypeInfo;
   import org.w3c.dom.Attr;
   import org.w3c.dom.Element;
   import org.w3c.dom.NodeList;
  @@ -129,6 +130,10 @@
   
       public boolean hasAttributeNS(String namespaceURI, String localName) {
        return false;
  +    }
  +    
  +    public TypeInfo getSchemaTypeInfo(){
  +      return null;
       }
       
   
  
  
  
  1.80      +141 -73   
xml-xerces/java/src/org/apache/xerces/parsers/AbstractDOMParser.java
  
  Index: AbstractDOMParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/AbstractDOMParser.java,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- AbstractDOMParser.java    8 Jan 2003 21:42:04 -0000       1.79
  +++ AbstractDOMParser.java    16 Jan 2003 22:53:45 -0000      1.80
  @@ -57,50 +57,45 @@
   
   package org.apache.xerces.parsers;
   
  +import java.util.Locale;
  +import java.util.Stack;
  +
   import org.apache.xerces.dom.AttrImpl;
  -import org.apache.xerces.dom.DeferredDocumentImpl;
   import org.apache.xerces.dom.CoreDocumentImpl;
  +import org.apache.xerces.dom.DeferredDocumentImpl;
   import org.apache.xerces.dom.DocumentImpl;
   import org.apache.xerces.dom.DocumentTypeImpl;
   import org.apache.xerces.dom.ElementDefinitionImpl;
   import org.apache.xerces.dom.ElementImpl;
  +import org.apache.xerces.dom.ElementNSImpl;
   import org.apache.xerces.dom.EntityImpl;
   import org.apache.xerces.dom.EntityReferenceImpl;
   import org.apache.xerces.dom.NodeImpl;
   import org.apache.xerces.dom.NotationImpl;
  -import org.apache.xerces.dom.ProcessingInstructionImpl;
   import org.apache.xerces.dom.PSVIAttrNSImpl;
   import org.apache.xerces.dom.PSVIElementNSImpl;
  +import org.apache.xerces.dom.ProcessingInstructionImpl;
   import org.apache.xerces.dom.TextImpl;
   import org.apache.xerces.impl.Constants;
  -import org.apache.xerces.util.ObjectFactory;
  -import org.apache.xerces.util.XMLAttributesImpl;
  -
  -// id types
  -import org.apache.xerces.xni.psvi.AttributePSVI;
   import org.apache.xerces.impl.dv.XSSimpleType;
  -
  +import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
  +import org.apache.xerces.util.ObjectFactory;
   import org.apache.xerces.xni.Augmentations;
   import org.apache.xerces.xni.NamespaceContext;
   import org.apache.xerces.xni.QName;
   import org.apache.xerces.xni.XMLAttributes;
  -import org.apache.xerces.xni.XMLDocumentHandler;
  -import org.apache.xerces.xni.XMLDTDHandler;
   import org.apache.xerces.xni.XMLLocator;
   import org.apache.xerces.xni.XMLResourceIdentifier;
   import org.apache.xerces.xni.XMLString;
   import org.apache.xerces.xni.XNIException;
   import org.apache.xerces.xni.parser.XMLParserConfiguration;
  -import org.apache.xerces.xni.parser.XMLConfigurationException;
   import org.apache.xerces.xni.psvi.AttributePSVI;
   import org.apache.xerces.xni.psvi.ElementPSVI;
  -
   import org.w3c.dom.Attr;
   import org.w3c.dom.CDATASection;
   import org.w3c.dom.Comment;
   import org.w3c.dom.Document;
   import org.w3c.dom.DocumentType;
  -import org.w3c.dom.DOMImplementation;
   import org.w3c.dom.Element;
   import org.w3c.dom.EntityReference;
   import org.w3c.dom.NamedNodeMap;
  @@ -108,13 +103,9 @@
   import org.w3c.dom.NodeList;
   import org.w3c.dom.ProcessingInstruction;
   import org.w3c.dom.Text;
  -
   import org.w3c.dom.ls.DOMBuilderFilter;
   import org.w3c.dom.traversal.NodeFilter;
   
  -import java.util.Locale;
  -import java.util.Stack;
  -
   /**
    * This is the base class of all DOM parsers. It implements the XNI
    * callback methods to create the DOM tree. After a successful parse of
  @@ -584,6 +575,9 @@
        * @throws XNIException Thrown by handler to signal an error.
        */
       public void textDecl(String version, String encoding, Augmentations augs) 
throws XNIException {
  +        if (fInDTD){
  +            return;
  +        }
           if (!fDeferNodeExpansion) {
               if (fCurrentEntityDecl != null && !fFilterReject) {
                   fCurrentEntityDecl.setEncoding(encoding);
  @@ -926,11 +920,12 @@
                   Attr attr = createAttrNode(fAttrQName);
   
                   String attrValue = attributes.getValue(i);
  -                if (fStorePSVI) {
  -                    AttributePSVI attrPSVI = 
(AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
  -                    if (attrPSVI != null)
  -                        ((PSVIAttrNSImpl)attr).setPSVI(attrPSVI);
  +
  +                AttributePSVI attrPSVI =(AttributePSVI) 
attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
  +                         if (fStorePSVI && attrPSVI != null){
  +                               ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                   }
  +            
                   
                   attr.setValue(attrValue);
                   el.setAttributeNode(attr);
  @@ -938,26 +933,60 @@
                   //       the node value because that turns the "specified"
                   //       flag to "true" which may overwrite a "false"
                   //       value from the attribute list. -Ac
  -                if (fDocumentImpl != null) {
  -                    AttrImpl attrImpl = (AttrImpl)attr;
  -                    boolean specified = attributes.isSpecified(i);
  -                    attrImpl.setSpecified(specified);
  -                    // REVISIT: when DOM Level 3 becomes Rec this code
  -                    // should not depend odn fDocumentImpl
  -                    // Identifier registration
  -                    if (attributes.getType(i).equals("ID")) {
  -                        ((ElementImpl) el).setIdAttributeNode(attr, true);
  -                    }
  -                    else if (attributes instanceof XMLAttributesImpl) {
  -                        XMLAttributesImpl attrs = (XMLAttributesImpl)attributes;
  -                        if (attrs.getSchemaId(i))
  -                            ((ElementImpl) el).setIdAttributeNode(attr, true);
  +                             if (fDocumentImpl != null) {
  +                                     AttrImpl attrImpl = (AttrImpl) attr;
  +                                     Object type = null;
  +                                     boolean id = false;
  +
  +                                     // REVISIT: currently it is possible that 
someone turns off
  +                                     // namespaces and turns on xml schema 
validation 
  +                                     // To avoid classcast exception in AttrImpl 
check for namespaces
  +                                     // however the correct solution should 
probably disallow setting
  +                                     // namespaces to false when schema processing 
is turned on.
  +                                     if (attrPSVI != null && fNamespaceAware) {
  +                                             // XML Schema 
  +                                             type = 
attrPSVI.getMemberTypeDefinition();
  +                                             if (type == null) {
  +                                                     type = 
attrPSVI.getTypeDefinition();
  +                                                     if (type != null) {
  +                                                             id = ((XSSimpleType) 
type).isIDType();
  +                                                             attrImpl.setType(type);
  +                                                     }
  +                                             }
  +                                             else {
  +                                                     id = ((XSSimpleType) 
type).isIDType();
  +                                                     attrImpl.setType(type);
  +                                             }
  +                                     }
  +                                     else {
  +                                             // DTD 
  +                        type = attributes.getType(i);
  +                                             attrImpl.setType(type);
  +                                             id = (type.equals("ID")) ? true : 
false;
  +                                     }
  +                
  +                                     if (id) {
  +                                             ((ElementImpl) 
el).setIdAttributeNode(attr, true);
  +                                     }
  +
  +                                     
attrImpl.setSpecified(attributes.isSpecified(i));
  +                                     // REVISIT: Handle entities in attribute value.
  +                }
  +            }
  +            setCharacterData(false);
  +            
  +            if (augs != null) {
  +                ElementPSVI elementPSVI = 
(ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
  +                if (elementPSVI != null && fNamespaceAware) {
  +                    XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
  +                    if (type == null) {
  +                        type = elementPSVI.getTypeDefinition();
                       }
  +                    ((ElementNSImpl)el).setType(type);
                   }
  -                // REVISIT: Handle entities in attribute value.
               }
   
  -            setCharacterData(false);
  +            
               // filter nodes
               if (fDOMFilter != null) {
                   short code = fDOMFilter.startElement(el);
  @@ -983,29 +1012,63 @@
               fCurrentNode = el;
           }
           else {
  +           Object type = null;
  +           if (augs != null) {
  +                ElementPSVI elementPSVI = 
(ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
  +                if (elementPSVI != null) {
  +                    type = elementPSVI.getMemberTypeDefinition();
  +                    if (type == null) {
  +                        type = elementPSVI.getTypeDefinition();
  +                    }
  +                }
  +            }
  +
               int el =
                   fDeferredDocumentImpl.createDeferredElement(fNamespaceAware ?
                                                               element.uri : null,
  -                                                            element.rawname);
  +                                                            element.rawname,
  +                                                            type);
               int attrCount = attributes.getLength();
               for (int i = 0; i < attrCount; i++) {
  -                String attrValue = attributes.getValue(i);
  +                // set type information
  +                AttributePSVI attrPSVI = 
(AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
  +                boolean id = false;
  +
  +                // REVISIT: currently it is possible that someone turns off
  +                // namespaces and turns on xml schema validation 
  +                // To avoid classcast exception in AttrImpl check for namespaces
  +                // however the correct solution should probably disallow setting
  +                // namespaces to false when schema processing is turned on.
  +                             if (attrPSVI != null && fNamespaceAware) {
  +                                     // XML Schema 
  +                                     type = attrPSVI.getMemberTypeDefinition();
  +                                     if (type == null) {
  +                                             type = attrPSVI.getTypeDefinition();
  +                        if (type != null){
  +                                               id = ((XSSimpleType) 
type).isIDType();
  +                        }
  +                                     }
  +                                     else {
  +                                             id = ((XSSimpleType) type).isIDType();
  +                                     }
  +                             }
  +                             else {
  +                                     // DTD 
  +                                     type = attributes.getType(i);
  +                                     id = (type.equals("ID")) ? true : false;
  +                             }
                   
  -                int attr = fDeferredDocumentImpl.setDeferredAttribute(el,
  -                                                    attributes.getQName(i),
  -                                                    attributes.getURI(i),
  -                                                    attrValue,
  -                                                    attributes.isSpecified(i));
  -                // Identifier registration
  -                if (attributes.getType(i).equals("ID")) {
  -                    fDeferredDocumentImpl.setIdAttributeNode(el, attr);
  -                }
  -                else if (attributes instanceof XMLAttributesImpl) {
  -                    XMLAttributesImpl attrs = (XMLAttributesImpl)attributes;
  -                    if (attrs.getSchemaId(i))
  -                        fDeferredDocumentImpl.setIdAttributeNode(el, attr);
  -                }
  +                // create attribute
  +               fDeferredDocumentImpl.setDeferredAttribute(
  +                        el,
  +                        attributes.getQName(i),
  +                        attributes.getURI(i),
  +                        attributes.getValue(i),
  +                        attributes.isSpecified(i),
  +                        id,
  +                        type);
               }
  +            
               fDeferredDocumentImpl.appendChild(fCurrentNodeIndex, el);
               fCurrentNodeIndex = el;
           }
  @@ -2068,23 +2131,26 @@
           // internal subset string
           String publicId = identifier.getPublicId();
           String literalSystemId = identifier.getLiteralSystemId();
  -        if (fInternalSubset != null && !fInDTDExternalSubset) {
  -            fInternalSubset.append("<!NOTATION ");
  -            fInternalSubset.append(name);
  -            if (publicId != null) {
  -                fInternalSubset.append(" PUBLIC '");
  -                fInternalSubset.append(publicId);
  -                if (literalSystemId != null) {
  -                    fInternalSubset.append("' '");
  -                    fInternalSubset.append(literalSystemId);
  -                }
  -            }
  -            else {
  -                fInternalSubset.append(" SYSTEM '");
  -                fInternalSubset.append(literalSystemId);
  -            }
  -            fInternalSubset.append("'>\n");
  -        }
  +             if (fInDTD) {
  +                     if (fInternalSubset != null && !fInDTDExternalSubset) {
  +                             fInternalSubset.append("<!NOTATION ");
  +                             fInternalSubset.append(name);
  +                             if (publicId != null) {
  +                                     fInternalSubset.append(" PUBLIC '");
  +                                     fInternalSubset.append(publicId);
  +                                     if (literalSystemId != null) {
  +                                             fInternalSubset.append("' '");
  +                                             
fInternalSubset.append(literalSystemId);
  +                                     }
  +                             }
  +                             else {
  +                                     fInternalSubset.append(" SYSTEM '");
  +                                     fInternalSubset.append(literalSystemId);
  +                             }
  +                             fInternalSubset.append("'>\n");
  +                     }
  +                     return;
  +             }
   
           // NOTE: We only know how to create these nodes for the Xerces
           //       DOM implementation because DOM Level 2 does not specify 
  @@ -2232,7 +2298,9 @@
               }
               fInternalSubset.append(">\n");
           }
  -
  +        // REVISIT: This code applies to the support of domx/grammar-access 
  +        // feature in Xerces 1
  + 
           // deferred expansion
           if (fDeferredDocumentImpl != null) {
   
  @@ -2308,7 +2376,7 @@
               }
   
           } // if NOT defer-node-expansion
  -
  +      
       } // attributeDecl(String,String,String,String[],String,XMLString, XMLString, 
Augmentations)
   
   
  
  
  

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

Reply via email to