elena       2002/12/30 17:55:06

  Modified:    java/src/org/apache/xerces/dom DOMConfigurationImpl.java
                        DOMNormalizer.java
               java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
               java/src/org/apache/xerces/parsers DOMBuilderImpl.java
  Log:
  Feature "discard-default-content" should only be supported in the DOMWriter
  (Minutes DOM teleconference 20021204).
  
  Revision  Changes    Path
  1.3       +5 -20     
xml-xerces/java/src/org/apache/xerces/dom/DOMConfigurationImpl.java
  
  Index: DOMConfigurationImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMConfigurationImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DOMConfigurationImpl.java 30 Dec 2002 21:31:02 -0000      1.2
  +++ DOMConfigurationImpl.java 31 Dec 2002 01:55:05 -0000      1.3
  @@ -182,11 +182,10 @@
       protected final static short DTNORMALIZATION     = 0x1<<1;
       protected final static short ENTITIES            = 0x1<<2;
       protected final static short CDATA               = 0x1<<3;
  -    protected final static short DEFAULTS            = 0x1<<4;
  -    protected final static short SPLITCDATA          = 0x1<<5;
  -    protected final static short COMMENTS            = 0x1<<6;
  -    protected final static short VALIDATE            = 0x1<<7;
  -    protected final static short PSVI                = 0x1<<8;
  +    protected final static short SPLITCDATA          = 0x1<<4;
  +    protected final static short COMMENTS            = 0x1<<5;
  +    protected final static short VALIDATE            = 0x1<<6;
  +    protected final static short PSVI                = 0x1<<7;
   
       // components
   
  @@ -253,7 +252,6 @@
               DYNAMIC_VALIDATION,
               NORMALIZE_DATA,
               SEND_PSVI,
  -            Constants.DOM_DISCARD_DEFAULT_CONTENT
           };
           addRecognizedFeatures(recognizedFeatures);
   
  @@ -263,7 +261,6 @@
           setFeature(DYNAMIC_VALIDATION, false);
           setFeature(NORMALIZE_DATA, false);
           setFeature(XERCES_NAMESPACES, true);
  -        setFeature(Constants.DOM_DISCARD_DEFAULT_CONTENT, true);
           setFeature(SEND_PSVI, true);
   
           // add default recognized properties
  @@ -286,7 +283,6 @@
           features |= ENTITIES;
           features |= COMMENTS;
           features |= CDATA;
  -        features |= DEFAULTS;
           features |= SPLITCDATA;
           
           if (symbolTable == null) {
  @@ -569,11 +565,6 @@
                   features = (short) (state ? features | ENTITIES : features & 
~ENTITIES);
   
               }
  -            else if (name.equals(Constants.DOM_DISCARD_DEFAULT_CONTENT)) {
  -                setFeature (Constants.DOM_DISCARD_DEFAULT_CONTENT, state);
  -                features = (short) (state ? features | DEFAULTS : features & 
~DEFAULTS);
  -
  -            }
               else if (name.equals(Constants.DOM_SPLIT_CDATA)) {
                   features = (short) (state ? features | SPLITCDATA : features & 
~SPLITCDATA);
   
  @@ -807,11 +798,6 @@
                }
                else if (name.equals(Constants.DOM_ENTITIES)) {
                        return (features & ENTITIES) != 0 ? Boolean.TRUE : 
Boolean.FALSE;
  -
  -             }
  -             else if (name.equals(Constants.DOM_DISCARD_DEFAULT_CONTENT)) {
  -                     return (features & DEFAULTS) != 0 ? Boolean.TRUE : 
Boolean.FALSE;
  -
                }
                else if (name.equals(Constants.DOM_SPLIT_CDATA)) {
                        return (features & SPLITCDATA) != 0 ? Boolean.TRUE : 
Boolean.FALSE;
  @@ -880,7 +866,6 @@
                        || name.equals(Constants.DOM_DATATYPE_NORMALIZATION)
                        || name.equals(Constants.DOM_CDATA_SECTIONS)
                        || name.equals(Constants.DOM_ENTITIES)
  -                     || name.equals(Constants.DOM_DISCARD_DEFAULT_CONTENT)
                        || name.equals(Constants.DOM_SPLIT_CDATA)
                        || name.equals(Constants.DOM_NAMESPACES)
                        || name.equals(Constants.DOM_VALIDATE)) {
  
  
  
  1.22      +26 -24    xml-xerces/java/src/org/apache/xerces/dom/DOMNormalizer.java
  
  Index: DOMNormalizer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMNormalizer.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DOMNormalizer.java        30 Dec 2002 21:31:02 -0000      1.21
  +++ DOMNormalizer.java        31 Dec 2002 01:55:05 -0000      1.22
  @@ -324,7 +324,7 @@
                       if ( attributes!=null ) {
                           for ( int i=0; i<attributes.getLength(); ++i ) {
                               Attr attr = (Attr)attributes.item(i);
  -                            removeDefault(attr, attributes);
  +                            //removeDefault(attr, attributes);
                               attr.normalize();
                               // XML 1.0 attribute value normalization
                               normalizeAttributeValue(attr.getValue(), attr);         
                   
  @@ -607,7 +607,7 @@
                                   //          xmlns:foo = ""
   
                               }
  -                            removeDefault (attr, attributes);
  +                            //removeDefault (attr, attributes);
                               continue;
                           } else { // (localpart == fXmlnsSymbol && prefix == 
fEmptySymbol)  -- xmlns
                               // empty prefix is always bound ("" or some string)
  @@ -615,7 +615,7 @@
                               fLocalNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, 
value);
                               
fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value);
   
  -                            removeDefault (attr, attributes);
  +                            //removeDefault (attr, attributes);
                               continue;
                           }
                       }  // end-else: valid declaration
  @@ -729,13 +729,14 @@
                           continue;
                       }
   
  -
                       // ---------------------------------------
                       // remove default attributes
                       // ---------------------------------------
  +                    /* 
                       if (removeDefault(attr, attributes)) {
                           continue;
                       }
  +                    */
                       // XML 1.0 Attribute value normalization
                       value = normalizeAttributeValue(value, attr);
   
  @@ -816,7 +817,7 @@
                           // ---------------------------------------
                           // remove default attributes
                           // ---------------------------------------
  -                        removeDefault(attr, attributes);
  +                        // removeDefault(attr, attributes);
                       }
                   }
               }
  @@ -853,7 +854,7 @@
           }
       }
   
  -    protected final boolean removeDefault (Attr attribute, AttributeMap attrMap){
  +    /*protected final boolean removeDefault (Attr attribute, AttributeMap attrMap){
           if ((fConfiguration.features & DOMConfigurationImpl.DEFAULTS) != 0) {
               // remove default attributes
               if (!attribute.getSpecified()) {
  @@ -866,6 +867,7 @@
           }
           return false;
       }
  +    */
   
   
       protected final DOMError modifyDOMError(String message, short severity, Node 
node){
  @@ -1431,36 +1433,36 @@
        * @exception XNIException
        *                   Thrown by handler to signal an error.
        */
  -     public void endElement(QName element, Augmentations augs) throws XNIException 
{ 
  -        if (DEBUG_EVENTS) {
  +     public void endElement(QName element, Augmentations augs) throws XNIException {
  +             if (DEBUG_EVENTS) {
                        System.out.println("==>endElement: " + element);
                }
  -        
  +
                ElementPSVI elementPSVI = (ElementPSVI) 
augs.getItem(Constants.ELEMENT_PSVI);
                if (elementPSVI != null) {
                        ElementImpl elementNode = (ElementImpl) fCurrentNode;
                        if (fPSVI) {
                                ((PSVIElementNSImpl) 
fCurrentNode).setPSVI(elementPSVI);
                        }
  -                     if ((fConfiguration.features & DOMConfigurationImpl.DEFAULTS) 
== 0) {
  -                             String normalizedValue = 
elementPSVI.getSchemaNormalizedValue();
  -                             if ((fConfiguration.features & 
DOMConfigurationImpl.DTNORMALIZATION) != 0) {
  +                     // include element default content (if one is available)
  +                     String normalizedValue = 
elementPSVI.getSchemaNormalizedValue();
  +                     if ((fConfiguration.features & 
DOMConfigurationImpl.DTNORMALIZATION) != 0) {
  +                             elementNode.setTextContent(normalizedValue);
  +                     }
  +                     else {
  +                             // NOTE: this is a hack: it is possible that DOM had 
an empty element
  +                             // and validator sent default value using 
characters(), which we don't 
  +                             // implement. Thus, here we attempt to add the default 
value.
  +                             String text = elementNode.getTextContent();
  +                             if (text.length() == 0) {
  +                                     // default content could be provided
  +                                     // REVISIT: should setTextConent(null) be 
allowed?
                                        elementNode.setTextContent(normalizedValue);
                                }
  -                             else {
  -                                     // NOTE: this is a hack: it is possible that 
DOM had an empty element
  -                                     // and validator sent default value using 
characters(), which we don't 
  -                                     // implement. Thus, here we attempt to add the 
default value.
  -                                     String text = elementNode.getTextContent();
  -                                     if (text.length() == 0) {
  -                                             // default content could be provided
  -                                             // REVISIT: should setTextConent(null) 
be allowed?
  -                                             
elementNode.setTextContent(normalizedValue);
  -                                     }
  -                             }
                        }
                }
        }
  +
   
       /**
        * The start of a CDATA section.
  
  
  
  1.127     +4 -14     
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- XMLSchemaValidator.java   30 Dec 2002 21:31:03 -0000      1.126
  +++ XMLSchemaValidator.java   31 Dec 2002 01:55:06 -0000      1.127
  @@ -314,8 +314,6 @@
       // to indicate whether we are in the scope of entity reference or CData
       protected boolean fEntityRef = false;
       protected boolean fInCDATA = false;
  -    // DOM Level 3: discard default attributes (
  -    protected boolean fDiscardDefaults = false;
   
       // properties
   
  @@ -709,7 +707,7 @@
   
           // call handlers
           if (fDocumentHandler != null) {
  -            if (fDiscardDefaults || !fSchemaElementDefault || fDefaultValue == 
null) {
  +            if (!fSchemaElementDefault || fDefaultValue == null) {
                   fDocumentHandler.emptyElement(element, attributes, modifiedAugs);
               } else {
                   fDocumentHandler.startElement(element, attributes, modifiedAugs);
  @@ -1310,15 +1308,7 @@
           catch (XMLConfigurationException e){
               fSchemaType = null;
           }
  -        
  -        try {
  -            fDiscardDefaults = 
componentManager.getFeature(Constants.DOM_DISCARD_DEFAULT_CONTENT);       
  -        }
  -        catch (XMLConfigurationException e){
  -            fDiscardDefaults = false;
  -        }
  -        
  -        
  +                
           fEntityResolver = 
(XMLEntityResolver)componentManager.getProperty(ENTITY_MANAGER);
           fSchemaLoader.setEntityResolver(fEntityResolver);
   
  @@ -2003,7 +1993,7 @@
           processAttributes(element, attributes, attrGrp);
   
           // add default attributes
  -        if (attrGrp != null && !fDiscardDefaults) {
  +        if (attrGrp != null) {
               addDefaultAttributes(element, attributes, attrGrp);
           }
   
  
  
  
  1.26      +1 -3      
xml-xerces/java/src/org/apache/xerces/parsers/DOMBuilderImpl.java
  
  Index: DOMBuilderImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMBuilderImpl.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- DOMBuilderImpl.java       30 Dec 2002 21:31:03 -0000      1.25
  +++ DOMBuilderImpl.java       31 Dec 2002 01:55:06 -0000      1.26
  @@ -189,7 +189,6 @@
               Constants.DOM_NAMESPACE_DECLARATIONS,
               Constants.DOM_SUPPORTED_MEDIATYPES_ONLY,
               Constants.DOM_CERTIFIED,
  -            Constants.DOM_DISCARD_DEFAULT_CONTENT
           };
   
           fConfiguration.addRecognizedFeatures(domRecognizedFeatures);
  @@ -204,7 +203,6 @@
           fConfiguration.setFeature(Constants.DOM_INFOSET, false);
           fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, true);
           fConfiguration.setFeature(Constants.DOM_SUPPORTED_MEDIATYPES_ONLY, false);
  -        fConfiguration.setFeature(Constants.DOM_DISCARD_DEFAULT_CONTENT, true);
           
           // REVISIT: by default Xerces assumes that input is certified.
           //          default is different from the one specified in the DOM spec
  
  
  

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

Reply via email to