xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject cvs commit: xml-xerces/java/src/org/apache/xml/serialize XMLSerializer.java
Date Thu, 12 Feb 2004 17:36:34 GMT
elena       2004/02/12 09:36:34

  Modified:    java/src/org/apache/xml/serialize XMLSerializer.java
  Log:
  Per latest LS draft, attribute nodes must be passed to a filter.
  
  Revision  Changes    Path
  1.58      +19 -5     xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- XMLSerializer.java	10 Feb 2004 17:25:27 -0000	1.57
  +++ XMLSerializer.java	12 Feb 2004 17:36:33 -0000	1.58
  @@ -90,6 +90,7 @@
   import org.w3c.dom.Element;
   import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Node;
  +import org.w3c.dom.traversal.NodeFilter;
   import org.xml.sax.AttributeList;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -1061,7 +1062,7 @@
                           // change prefix for this attribute
                       }
   
  -                    printAttribute (name, (value==null)?XMLSymbols.EMPTY_STRING:value,
attr.getSpecified());
  +                    printAttribute (name, (value==null)?XMLSymbols.EMPTY_STRING:value,
attr.getSpecified(), attr);
                   } else { // attribute uri == null
                       if (attr.getLocalName() == null) {
                           if (fDOMErrorHandler != null) {
  @@ -1078,12 +1079,12 @@
               	                   "SerializationStopped", null));
                               }
                           }
  -                        printAttribute (name, value, attr.getSpecified());
  +                        printAttribute (name, value, attr.getSpecified(), attr);
                       } else { // uri=null and no colon
   
                           // no fix up is needed: default namespace decl does not 
                           // apply to attributes
  -                        printAttribute (name, value, attr.getSpecified());
  +                        printAttribute (name, value, attr.getSpecified(), attr);
                       }
                   }
               } // end loop for attributes
  @@ -1166,9 +1167,22 @@
        * @param isSpecified
        * @exception IOException
        */
  -    private void printAttribute (String name, String value, boolean isSpecified) throws
IOException{
  +    private void printAttribute (String name, String value, boolean isSpecified, Attr attr)
throws IOException{
   
           if (isSpecified || (features & DOMSerializerImpl.DISCARDDEFAULT) != 0) {
  +            if (fDOMFilter !=null && 
  +                (fDOMFilter.getWhatToShow() & NodeFilter.SHOW_ATTRIBUTE)!= 0) {
  +                short code = fDOMFilter.acceptNode(attr);
  +                switch (code) {
  +                    case NodeFilter.FILTER_REJECT:
  +                    case NodeFilter.FILTER_SKIP: { 
  +                        return;
  +                    }
  +                    default: {
  +                        // fall through
  +                    }
  +                }
  +            }
               _printer.printSpace();
               _printer.printText( name );
               _printer.printText( "=\"" );
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org


Mime
View raw message