You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@locus.apache.org on 2000/11/08 22:48:38 UTC

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

lehors      00/11/08 13:48:35

  Modified:    java/src/org/apache/xerces/parsers DOMParser.java
  Log:
  fixed handling of default attributes with a namespace
  -patch from Elena Litani
  
  Revision  Changes    Path
  1.28      +17 -4     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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- DOMParser.java	2000/09/01 18:10:19	1.27
  +++ DOMParser.java	2000/11/08 21:48:31	1.28
  @@ -108,7 +108,7 @@
    * DOMParser provides a parser which produces a W3C DOM tree as its output
    *
    * 
  - * @version $Id: DOMParser.java,v 1.27 2000/09/01 18:10:19 lehors Exp $
  + * @version $Id: DOMParser.java,v 1.28 2000/11/08 21:48:31 lehors Exp $
    */
   public class DOMParser
       extends XMLParser
  @@ -2064,19 +2064,32 @@
                   }
   
                   // REVISIT: Check for uniqueness of element name? -Ac
  -                // REVISIT: what about default attributes with URI? -ALH
   
                   // get attribute name and value index
                   String attrName      = fStringPool.toString(attributeDecl.rawname);
                   String attrValue     = fStringPool.toString(attDefaultValue);
   
                   // create attribute and set properties
  -                AttrImpl attr = (AttrImpl)fDocumentImpl.createAttribute(attrName);
  +                boolean nsEnabled = false;
  +                try { nsEnabled = getNamespaces(); }
  +                catch (SAXException s) {}
  +                AttrImpl attr;
  +                if (nsEnabled) {
  +                    attr = (AttrImpl)fDocumentImpl.createAttributeNS(fStringPool.toString(attributeDecl.uri),attrName);
  +                }
  +                else{
  +                    attr = (AttrImpl)fDocumentImpl.createAttribute(attrName);
  +                }
                   attr.setValue(attrValue);
                   attr.setSpecified(false);
   
                   // add default attribute to element definition
  -                elementDef.getAttributes().setNamedItem(attr);
  +                if(nsEnabled){
  +                    elementDef.getAttributes().setNamedItemNS(attr);
  +                }
  +                else{
  +                    elementDef.getAttributes().setNamedItem(attr);
  +                }
               }
   
               //