vgritsenko    2004/06/18 05:38:31

  Modified:    src/blocks/forms/samples/flow bindings.js
               src/java/org/apache/cocoon/xml XMLUtils.java
  Log:
  Add serializeNode(Node node), update bindings.js.
  Cache default properties created by createPropertiesForXML.
  
  Revision  Changes    Path
  1.6       +1 -1      cocoon-2.1/src/blocks/forms/samples/flow/bindings.js
  
  Index: bindings.js
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/samples/flow/bindings.js,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- bindings.js       9 Apr 2004 11:02:40 -0000       1.5
  +++ bindings.js       18 Jun 2004 12:38:31 -0000      1.6
  @@ -94,7 +94,7 @@
    * String representation .
    */
   function serializeNode(node) {
  -    return Packages.org.apache.cocoon.xml.XMLUtils.serializeNodeToXML(node);
  +    return Packages.org.apache.cocoon.xml.XMLUtils.serializeNode(node);
   }
   
   /** 
  
  
  
  1.10      +37 -9     cocoon-2.1/src/java/org/apache/cocoon/xml/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/xml/XMLUtils.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XMLUtils.java     18 Jun 2004 12:01:26 -0000      1.9
  +++ XMLUtils.java     18 Jun 2004 12:38:31 -0000      1.10
  @@ -50,6 +50,10 @@
   
       public static final AttributesImpl EMPTY_ATTRIBUTES = new 
AttributesImpl();
   
  +    private static final Properties XML_FORMAT = 
createDefaultPropertiesForXML(false);
  +    private static final Properties XML_FORMAT_NODECL = 
createDefaultPropertiesForXML(true);
  +
  +
       // FIXME: parent parameter not used anymore
       // Using parent because some dom implementations like jtidy are bugged,
       // cannot get parent or delete child
  @@ -145,13 +149,9 @@
       }
   
       /**
  -     * Create a new properties set for serializing xml
  -     * The omit xml declaration property can be controlled by the flag.
  -     * Method: xml
  -     * Omit xml declaration: according to the flag
  -     * Indent: yes
  +     * Method for static initializer
        */
  -    public static Properties createPropertiesForXML(boolean 
omitXMLDeclaration) {
  +    private static Properties createDefaultPropertiesForXML(boolean 
omitXMLDeclaration) {
           final Properties format = new Properties();
           format.put(OutputKeys.METHOD, "xml");
           format.put(OutputKeys.OMIT_XML_DECLARATION, (omitXMLDeclaration ? 
"yes" : "no"));
  @@ -160,9 +160,37 @@
       }
   
       /**
  -     * Serialize a DOM node to a String.
  -     * The format of the output can be specified with the properties.
  +     * Create a new properties set for serializing xml.
  +     * The omit xml declaration property can be controlled by the flag.
  +     *
  +     * <ul>
  +     * <li>Method: xml
  +     * <li>Omit xml declaration: according to the flag
  +     * <li>Indent: yes
  +     * </ul>
  +     */
  +    public static Properties createPropertiesForXML(boolean 
omitXMLDeclaration) {
  +        return new Properties(omitXMLDeclaration? XML_FORMAT_NODECL: 
XML_FORMAT);
  +    }
  +
  +    /**
  +     * Serialize a DOM node into a string using format created by
  +     * <code>createPropertiesForXML(false)</code>.
  +     *
  +     * @see #createPropertiesForXML
  +     */
  +    public static String serializeNode(Node node)
  +    throws ProcessingException {
  +        // Don't create new properties as we do not intend to modify 
defaults.
  +        return serializeNode(node, XML_FORMAT);
  +    }
  +
  +    /**
  +     * Serialize a DOM node into a string.
        * If the node is null the empty string is returned.
  +     *
  +     * @param format The format of the output to be used by SAX transformer.
  +     * @see OutputKeys
        */
       public static String serializeNode(Node node, Properties format)
       throws ProcessingException {
  
  
  

Reply via email to