dleslie     00/10/13 14:06:41

  Modified:    java/src/org/apache/xml/serialize/transition
                        BaseMarkupSerializer.java
  Log:
  Added public serializeXPathResultNode(Node n) to
  serialize each of the nodes in a node-set returned by
  an XPath expression.  This method wraps the protected
  serializeNode(Node n) method, which uses a switch statement
  to handle different node types. Not all node types are included,
  and the default behavior does nothing, so I changed default
  to getNodeValue, and send the String if any to the characters()
  method. This handles attribute nodes, which were not handled
  previously.
  
  Used by the ApplyXPath sample.
  
  Revision  Changes    Path
  1.5       +18 -4     
xml-xalan/java/src/org/apache/xml/serialize/transition/BaseMarkupSerializer.java
  
  Index: BaseMarkupSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/BaseMarkupSerializer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseMarkupSerializer.java 2000/10/13 02:33:17     1.4
  +++ BaseMarkupSerializer.java 2000/10/13 21:06:40     1.5
  @@ -138,7 +138,7 @@
    * another element.
    *
    *
  - * @version $Revision: 1.4 $ $Date: 2000/10/13 02:33:17 $
  + * @version $Revision: 1.5 $ $Date: 2000/10/13 21:06:40 $
    * @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
    * @see Serializer
    * @see DOMSerializer
  @@ -952,7 +952,19 @@
       // Generic node serializing methods methods //
       //------------------------------------------//
   
  -
  +    /**
  +     * Serialize a node from the node-set value returned by an XPath 
expression.
  +     * @param node The node to serialize
  +     */
  +     public void serializeXPathReturnNode(Node node)
  +             throws IOException
  +     {
  +             prepare();
  +             serializeNode(node);
  +             _printer.breakLine();
  +             _printer.flush();
  +     }
  +     
       /**
        * Serialize the DOM node. This method is shared across XML, HTML and 
XHTML
        * serializers and the differences are masked out in a separate [EMAIL 
PROTECTED]
  @@ -969,7 +981,6 @@
           switch ( node.getNodeType() ) {
           case Node.TEXT_NODE : {
               String text;
  -
               text = node.getNodeValue();
               if ( text != null )
                   characters( node.getNodeValue() );
  @@ -1089,7 +1100,10 @@
               break;
           }
   
  -        default:
  +        default: // added dml
  +                     String text = node.getNodeValue();
  +            if ( text != null )
  +                characters(node.getNodeValue());
               break;
           }
       }
  
  
  

Reply via email to