org.apache.cocoon.xml
Class XMLUtils

java.lang.Object
  |
  +--org.apache.cocoon.xml.XMLUtils

public class XMLUtils
extends java.lang.Object

XML utility methods.

Version:
CVS $Id: XMLUtils.java,v 1.6.2.3 2002/10/23 04:17:55 vgritsenko Exp $
Author:
Nicola Ken Barozzi, Sylvain Wallez, Carsten Ziegeler

Field Summary
static java.lang.String xalanBugStylesheet
           
 
Constructor Summary
XMLUtils()
           
 
Method Summary
static void data(org.xml.sax.ContentHandler contentHandler, java.lang.String data)
          Add string data
static java.util.Properties defaultSerializeToXMLFormat()
          This is the default properties set used to serialize xml.
static java.util.Properties defaultSerializeToXMLFormat(boolean omitXMLDeclaration)
          This is the default properties set used to serialize xml.
static XMLConsumer getConsumer(org.xml.sax.ContentHandler ch)
          Get an XMLConsumer from ContentHandler.
static XMLConsumer getConsumer(org.xml.sax.ContentHandler ch, org.xml.sax.ext.LexicalHandler lh)
          Get an XMLConsumer from a ContentHandler and a LexicalHandler.
static java.lang.String serializeNode(org.w3c.dom.Node node, java.util.Properties format)
          Serialize a DOM node to a String.
static java.lang.String serializeNodeToXML(org.w3c.dom.Node node)
          Serialize a DOM node to a String.
static void stripDuplicateAttributes(org.w3c.dom.Node node, org.w3c.dom.Node parent)
           
static void valueOf(org.xml.sax.ContentHandler contentHandler, java.util.Collection v)
          Implementation of <xsp:expr> for java.util.Collection : outputs the value by calling xspExpr() on each element of the collection.
static void valueOf(org.xml.sax.ContentHandler contentHandler, org.w3c.dom.Node v)
          Implementation of <xsp:expr> for org.w3c.dom.Node : converts the Node to a SAX event stream.
static void valueOf(org.xml.sax.ContentHandler contentHandler, java.lang.Object v)
          Implementation of <xsp:expr> for Object depending on its class : if it's an array, call xspExpr() on all its elements, if it's class has a specific xspExpr()implementation, use it, else, output it's string representation.
static void valueOf(org.xml.sax.ContentHandler contentHandler, java.lang.String text)
          Implementation of <xsp:expr> for String : outputs characters representing the value.
static void valueOf(org.xml.sax.ContentHandler contentHandler, XMLizable v)
          Implementation of <xsp:expr> for XMLizable : outputs the value by calling v.toSax(contentHandler).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xalanBugStylesheet

public static java.lang.String xalanBugStylesheet
Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

stripDuplicateAttributes

public static void stripDuplicateAttributes(org.w3c.dom.Node node,
                                            org.w3c.dom.Node parent)

getConsumer

public static XMLConsumer getConsumer(org.xml.sax.ContentHandler ch,
                                      org.xml.sax.ext.LexicalHandler lh)
Get an XMLConsumer from a ContentHandler and a LexicalHandler. If the content handler is already an XMLConsumer, it is returned as is, otherwise it is wrapped in an XMLConsumer with the lexical handler.
Parameters:
ch - the content handler, which should not be null
lh - the lexical handler, which can be null
Returns:
an XMLConsumer for ch an lh

getConsumer

public static XMLConsumer getConsumer(org.xml.sax.ContentHandler ch)
Get an XMLConsumer from ContentHandler. If the content handler is already an XMLConsumer, it is returned as is, otherwise it is wrapped in an XMLConsumer.
Parameters:
ch - the content handler, which should not be null
Returns:
an XMLConsumer for ch

serializeNodeToXML

public static java.lang.String serializeNodeToXML(org.w3c.dom.Node node)
                                           throws ProcessingException
Serialize a DOM node to a String. The defaultSerializeToXMLFormat() is used to format the serialized xml.

defaultSerializeToXMLFormat

public static java.util.Properties defaultSerializeToXMLFormat()
This is the default properties set used to serialize xml. It is used by the serializeNodeToXML() method. The format is as follows: Method: xml Encoding: ISO-8859-1 Omit xml declaration: no Indent: yes

defaultSerializeToXMLFormat

public static java.util.Properties defaultSerializeToXMLFormat(boolean omitXMLDeclaration)
This is the default properties set used to serialize xml. It is used by the serializeNodeToXML() method. The omit xml declaration property can be controlled by the flag. Method: xml Encoding: ISO-8859-1 Omit xml declaration: according to the flag Indent: yes

serializeNode

public static java.lang.String serializeNode(org.w3c.dom.Node node,
                                             java.util.Properties format)
                                      throws ProcessingException
Serialize a DOM node to a String. The format of the output can be specified with the properties. If the node is null the empty string is returned.

data

public static void data(org.xml.sax.ContentHandler contentHandler,
                        java.lang.String data)
                 throws org.xml.sax.SAXException
Add string data
Parameters:
contentHandler - The SAX content handler
data - The string data

valueOf

public static void valueOf(org.xml.sax.ContentHandler contentHandler,
                           java.lang.String text)
                    throws org.xml.sax.SAXException
Implementation of <xsp:expr> for String : outputs characters representing the value.
Parameters:
contentHandler - the SAX content handler
text - the value

valueOf

public static void valueOf(org.xml.sax.ContentHandler contentHandler,
                           XMLizable v)
                    throws org.xml.sax.SAXException
Implementation of <xsp:expr> for XMLizable : outputs the value by calling v.toSax(contentHandler).
Parameters:
contentHandler - the SAX content handler
v - the XML fragment

valueOf

public static void valueOf(org.xml.sax.ContentHandler contentHandler,
                           org.w3c.dom.Node v)
                    throws org.xml.sax.SAXException
Implementation of <xsp:expr> for org.w3c.dom.Node : converts the Node to a SAX event stream.
Parameters:
contentHandler - the SAX content handler
v - the value

valueOf

public static void valueOf(org.xml.sax.ContentHandler contentHandler,
                           java.util.Collection v)
                    throws org.xml.sax.SAXException
Implementation of <xsp:expr> for java.util.Collection : outputs the value by calling xspExpr() on each element of the collection.
Parameters:
contentHandler - the SAX content handler
v - the XML fragment

valueOf

public static void valueOf(org.xml.sax.ContentHandler contentHandler,
                           java.lang.Object v)
                    throws org.xml.sax.SAXException
Implementation of <xsp:expr> for Object depending on its class :
Parameters:
contentHandler - the SAX content handler
v - the value


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.