You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@locus.apache.org on 2000/06/15 04:19:21 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/parsers DOMParser.java

andyc       00/06/14 19:19:20

  Modified:    java/src/org/apache/xerces/parsers DOMParser.java
  Log:
  When parsing a document with a Schema, the DocumentType node
  was always returned as null. While this was not a big concern,
  users asked that the document type node never be null. So now
  this is fixed and the document type node is always created.
  
  Having done this fix, I realized that we have a larger problem.
  Default attribute values are stored in the DocumentTypeImpl
  class in ElementDefinition objects. Schema documents are not
  currently populating these values. Therefore, default attribute
  values don't work in DOM documents that have an associated XML
  Schema.
  
  But this problem is compounded by the fact that XML Schema
  allows element types to be defined locally. These locally
  declared elements can have attributes with default values
  so the entire default attribute value implementation in the
  DOM would have to be rethought.
  
  This is definitely a REVISIT!
  
  Revision  Changes    Path
  1.20      +14 -15    xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java
  
  Index: DOMParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DOMParser.java	2000/05/31 16:29:59	1.19
  +++ DOMParser.java	2000/06/15 02:19:19	1.20
  @@ -108,7 +108,7 @@
    * DOMParser provides a parser which produces a W3C DOM tree as its output
    *
    * 
  - * @version $Id: DOMParser.java,v 1.19 2000/05/31 16:29:59 andyc Exp $
  + * @version $Id: DOMParser.java,v 1.20 2000/06/15 02:19:19 andyc Exp $
    */
   public class DOMParser
       extends XMLParser
  @@ -983,18 +983,18 @@
               // copy schema grammar, if needed
               if (!fSeenRootElement) {
                   fSeenRootElement = true;
  +                if (fDocumentTypeIndex == -1) {
  +                    fDocumentTypeIndex = fDeferredDocumentImpl.createDocumentType(elementQName.rawname, -1, -1);
  +                    fDeferredDocumentImpl.appendChild(0, fDocumentTypeIndex);
  +                }
                   if (fGrammarAccess) {
                       // REVISIT: How do we know which grammar is in use?
                       //Document schemaDocument = fValidator.getSchemaDocument();
  -                    if (fGrammarResolver.size() > 0) {
  +                    int size = fGrammarResolver.size();
  +                    if (size > 0) {
                           Enumeration schemas = fGrammarResolver.nameSpaceKeys();
                           Document schemaDocument = fGrammarResolver.getGrammar((String)schemas.nextElement()).getGrammarDocument();
                           if (schemaDocument != null) {
  -                            if (fDocumentTypeIndex == -1) {
  -                                fDocumentTypeIndex = fDeferredDocumentImpl.createDocumentType(elementQName.rawname, -1, -1);
  -                                fDeferredDocumentImpl.appendChild(0, fDocumentTypeIndex);
  -                            }
  -
                               Element schema = schemaDocument.getDocumentElement();
                               copyInto(schema, fDocumentTypeIndex);
                           }
  @@ -1076,20 +1076,19 @@
               // copy schema grammar, if needed
               if (!fSeenRootElement) {
                   fSeenRootElement = true;
  +                if (fDocumentType == null) {
  +                    String rootName = elementName;
  +                    String systemId = ""; // REVISIT: How do we get this value? -Ac
  +                    String publicId = ""; // REVISIT: How do we get this value? -Ac
  +                    fDocumentType = fDocumentImpl.createDocumentType(rootName, publicId, systemId);
  +                    fDocument.appendChild(fDocumentType);
  +                }
                   if (fDocumentImpl != null && fGrammarAccess)  {
                       //Document schemaDocument = fValidator.getSchemaDocument();
                       if (fGrammarResolver.size() > 0) {
                           Enumeration schemas = fGrammarResolver.nameSpaceKeys();
                           Document schemaDocument = fGrammarResolver.getGrammar((String)schemas.nextElement()).getGrammarDocument();
                           if (schemaDocument != null) {
  -                            if (fDocumentType == null) {
  -                                String rootName = elementName;
  -                                String systemId = ""; // REVISIT: How do we get this value? -Ac
  -                                String publicId = ""; // REVISIT: How do we get this value? -Ac
  -                                fDocumentType = fDocumentImpl.createDocumentType(rootName, publicId, systemId);
  -                                fDocument.appendChild(fDocumentType);
  -                            }
  -
                               Element schema = schemaDocument.getDocumentElement();
                               XUtil.copyInto(schema, fDocumentType);
                           }