|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.xml.XMLUtils
public class XMLUtils
XML utility methods.
Field Summary | |
---|---|
static Attributes |
EMPTY_ATTRIBUTES
Empty attributes immutable object. |
Constructor Summary | |
---|---|
XMLUtils()
|
Method Summary | |
---|---|
static void |
createElement(ContentHandler contentHandler,
String localName)
Create a start and endElement with a empty Namespace and without Attributes |
static void |
createElement(ContentHandler contentHandler,
String localName,
Attributes atts)
Create a start and endElement with a empty Namespace |
static void |
createElement(ContentHandler contentHandler,
String localName,
Attributes atts,
String stringValue)
Create a start and endElement with a empty Namespace The content of the Element is set to the stringValue parameter |
static void |
createElement(ContentHandler contentHandler,
String localName,
String stringValue)
Create a start and endElement with a empty Namespace and without Attributes The content of the Element is set to the stringValue parameter |
static void |
createElementNS(ContentHandler contentHandler,
String namespaceURI,
String localName)
Create a start and endElement without Attributes |
static void |
createElementNS(ContentHandler contentHandler,
String namespaceURI,
String localName,
Attributes atts)
Create a start and endElement |
static void |
createElementNS(ContentHandler contentHandler,
String namespaceURI,
String localName,
Attributes atts,
String stringValue)
Create a start and endElement with a empty Namespace The content of the Element is set to the stringValue parameter |
static void |
createElementNS(ContentHandler contentHandler,
String namespaceURI,
String localName,
String stringValue)
Create a start and endElement without Attributes The content of the Element is set to the stringValue parameter |
static Properties |
createPropertiesForXML(boolean omitXMLDeclaration)
Create a new properties set for serializing xml. |
static void |
data(ContentHandler contentHandler,
String data)
Add string data |
static Properties |
defaultSerializeToXMLFormat()
Deprecated. Use createPropertiesForXML(false) instead and add the encoding |
static Properties |
defaultSerializeToXMLFormat(boolean omitXMLDeclaration)
Deprecated. Use createPropertiesForXML(boolean) instead and add the encoding |
static void |
endElement(ContentHandler contentHandler,
String localName)
Create endElement with empty Namespace For information on the names, see startElement. |
static void |
endElement(ContentHandler contentHandler,
String namespaceURI,
String localName)
Create endElement Prefix must be mapped to empty String For information on the names, see startElement. |
static XMLConsumer |
getConsumer(ContentHandler ch)
Get an XMLConsumer from ContentHandler . |
static XMLConsumer |
getConsumer(ContentHandler ch,
LexicalHandler lh)
Get an XMLConsumer from a ContentHandler and
a LexicalHandler . |
static String |
serialize(XMLizable xml,
Properties format)
Serialize a XMLizable into a string. |
static String |
serializeNode(Node node)
Serialize a DOM node into a string using format created by createPropertiesForXML(false) . |
static String |
serializeNode(Node node,
Properties format)
Serialize a DOM node into a string. |
static String |
serializeNodeToXML(Node node)
Deprecated. use serializeNode(Node, Properties) instead |
static void |
startElement(ContentHandler contentHandler,
String localName)
Create a startElement with a empty Namespace and without Attributes |
static void |
startElement(ContentHandler contentHandler,
String localName,
Attributes atts)
Create a startElement with a empty Namespace |
static void |
startElement(ContentHandler contentHandler,
String namespaceURI,
String localName)
Create a startElement without Attributes Prefix must be mapped to empty String |
static void |
startElement(ContentHandler contentHandler,
String namespaceURI,
String localName,
Attributes atts)
Create a startElement with a empty Namespace Prefix must be mapped to empty String |
static void |
stripDuplicateAttributes(Node node,
Node parent)
|
static void |
valueOf(ContentHandler contentHandler,
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(ContentHandler contentHandler,
Node v)
Implementation of <xsp:expr> for org.w3c.dom.Node :
converts the Node to a SAX event stream. |
static void |
valueOf(ContentHandler contentHandler,
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(ContentHandler contentHandler,
String text)
Implementation of <xsp:expr> for String :
outputs characters representing the value. |
static void |
valueOf(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 |
---|
public static final Attributes EMPTY_ATTRIBUTES
Constructor Detail |
---|
public XMLUtils()
Method Detail |
---|
public static void stripDuplicateAttributes(Node node, Node parent)
public static XMLConsumer getConsumer(ContentHandler ch, LexicalHandler lh)
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.
ch
- the content handler, which should not be null
lh
- the lexical handler, which can be null
XMLConsumer
for ch
an lh
public static XMLConsumer getConsumer(ContentHandler ch)
XMLConsumer
from ContentHandler
. If the
content handler is already an XMLConsumer
, it is returned as
is, otherwise it is wrapped in an XMLConsumer
.
ch
- the content handler, which should not be null
XMLConsumer
for ch
public static String serializeNodeToXML(Node node) throws ProcessingException
ProcessingException
public static Properties defaultSerializeToXMLFormat()
public static Properties defaultSerializeToXMLFormat(boolean omitXMLDeclaration)
public static Properties createPropertiesForXML(boolean omitXMLDeclaration)
public static String serializeNode(Node node) throws ProcessingException
createPropertiesForXML(false)
.
ProcessingException
createPropertiesForXML(boolean)
public static String serializeNode(Node node, Properties format) throws ProcessingException
format
- The format of the output to be used by SAX transformer.
ProcessingException
OutputKeys
public static String serialize(XMLizable xml, Properties format) throws ProcessingException
format
- The format of the output to be used by SAX transformer.
ProcessingException
OutputKeys
public static void data(ContentHandler contentHandler, String data) throws SAXException
contentHandler
- The SAX content handlerdata
- The string data
SAXException
public static void valueOf(ContentHandler contentHandler, String text) throws SAXException
String
:
outputs characters representing the value.
contentHandler
- the SAX content handlertext
- the value
SAXException
public static void valueOf(ContentHandler contentHandler, XMLizable v) throws SAXException
XMLizable
:
outputs the value by calling v.toSax(contentHandler)
.
contentHandler
- the SAX content handlerv
- the XML fragment
SAXException
public static void valueOf(ContentHandler contentHandler, Node v) throws SAXException
org.w3c.dom.Node
:
converts the Node to a SAX event stream.
contentHandler
- the SAX content handlerv
- the value
SAXException
public static void valueOf(ContentHandler contentHandler, Collection v) throws SAXException
java.util.Collection
:
outputs the value by calling xspExpr()
on each element of the
collection.
contentHandler
- the SAX content handlerv
- the XML fragment
SAXException
public static void valueOf(ContentHandler contentHandler, Object v) throws SAXException
Object
depending on its class :
xspExpr()
on all its elements,xspExpr()
implementation, use it,
contentHandler
- the SAX content handlerv
- the value
SAXException
public static void createElement(ContentHandler contentHandler, String localName) throws SAXException
localName
- The local name (without prefix)
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
public static void createElement(ContentHandler contentHandler, String localName, String stringValue) throws SAXException
localName
- The local name (without prefix)stringValue
- The content of the Element
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
public static void createElement(ContentHandler contentHandler, String localName, Attributes atts) throws SAXException
localName
- The local name (without prefix)atts
- The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
,
Attributes
public static void createElement(ContentHandler contentHandler, String localName, Attributes atts, String stringValue) throws SAXException
localName
- The local name (without prefix)atts
- The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.stringValue
- The content of the Element
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
,
Attributes
public static void createElementNS(ContentHandler contentHandler, String namespaceURI, String localName) throws SAXException
localName
- The local name (without prefix)
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
public static void createElementNS(ContentHandler contentHandler, String namespaceURI, String localName, String stringValue) throws SAXException
localName
- The local name (without prefix)stringValue
- The content of the Element
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
public static void createElementNS(ContentHandler contentHandler, String namespaceURI, String localName, Attributes atts) throws SAXException
localName
- The local name (without prefix)atts
- The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
,
Attributes
public static void createElementNS(ContentHandler contentHandler, String namespaceURI, String localName, Attributes atts, String stringValue) throws SAXException
localName
- The local name (without prefix)atts
- The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.stringValue
- The content of the Element
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
,
Attributes
public static void endElement(ContentHandler contentHandler, String localName) throws SAXException
For information on the names, see startElement.
localName
- The local name (without prefix)
SAXException
- Any SAX exception, possibly
wrapping another exception.public static void endElement(ContentHandler contentHandler, String namespaceURI, String localName) throws SAXException
For information on the names, see startElement.
localName
- The local name (without prefix)
SAXException
- Any SAX exception, possibly
wrapping another exception.public static void startElement(ContentHandler contentHandler, String localName) throws SAXException
localName
- The local name (without prefix)
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
public static void startElement(ContentHandler contentHandler, String namespaceURI, String localName) throws SAXException
namespaceURI
- The Namespace URIlocalName
- The local name (without prefix)
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
public static void startElement(ContentHandler contentHandler, String localName, Attributes atts) throws SAXException
localName
- The local name (without prefix)atts
- The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
,
Attributes
public static void startElement(ContentHandler contentHandler, String namespaceURI, String localName, Attributes atts) throws SAXException
namespaceURI
- The Namespace URIlocalName
- The local name (without prefix)atts
- The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(ContentHandler, String)
,
Attributes
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |