|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.xml.XMLUtils
public final class XMLUtils
XML Utility methods.
| Method Summary | |
|---|---|
static Document |
createDOMDocument()
Construct a new (empty) DOM Document and return it. |
static String |
escape(Object content)
Escapes all the XML special characters in a String using numerical XML entities. |
static String |
escapeAttributeValue(Object content)
Escapes all the XML special characters and left curly bracket in a String using numerical XML
entities, so that the resulting string can safely be used as an XML attribute value. |
static String |
escapeElementContent(Object content)
Escapes the XML special characters in a String using numerical XML entities, so that the resulting
string can safely be used as an XML text node. |
static String |
escapeXMLComment(String content)
XML comment does not support some characters inside its content but there is no official escaping/unescaping for it so we made our own. |
static String |
extractXML(Node node,
int start,
int length)
Extracts a well-formed XML fragment from the given DOM tree. |
static Document |
parse(LSInput source)
Parse a DOM Document from a source. |
static String |
serialize(Node node)
Serialize a DOM Node into a string, including the XML declaration at the start. |
static String |
serialize(Node node,
boolean withXmlDeclaration)
Serialize a DOM Node into a string, with an optional XML declaration at the start. |
static String |
transform(Source xml,
Source xslt)
Apply an XSLT transformation to a Document. |
static String |
unescape(Object content)
Unescape encoded special XML characters. |
static String |
unescapeXMLComment(String content)
XML comment does not support some characters inside its content but there is no official escaping/unescaping for it so we made our own. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String extractXML(Node node,
int start,
int length)
node - the root of the DOM tree where the extraction takes placestart - the index of the first characterlength - the maximum number of characters in text nodes to include in the returned fragment
public static String escapeXMLComment(String content)
content - the XML comment content to escape
public static String unescapeXMLComment(String content)
content - the XML comment content to unescape
escapeXMLComment(String)public static String escape(Object content)
String using numerical XML entities. Specifically,
escapes <, >, ", ', & and {. Left curly bracket is included here to protect against {{/html}} in
xwiki 2.x syntax.
content - the text to escape, may be null
String, null if null inputpublic static String escapeAttributeValue(Object content)
String using numerical XML
entities, so that the resulting string can safely be used as an XML attribute value. Specifically, escapes <,
>, ", ', & and {. Left curly bracket is included here to protect against {{/html}} in xwiki 2.x syntax.
content - the text to escape, may be null
String, null if null inputpublic static String escapeElementContent(Object content)
String using numerical XML entities, so that the resulting
string can safely be used as an XML text node. Specifically, escapes <, >, and &.
content - the text to escape, may be null
String, null if null inputpublic static String unescape(Object content)
content - the text to decode, may be null
null if null inputpublic static Document createDOMDocument()
public static Document parse(LSInput source)
source - the source input to parse
null if the parsing failed.public static String serialize(Node node)
node - the node to export
public static String serialize(Node node,
boolean withXmlDeclaration)
node - the node to exportwithXmlDeclaration - whether to output the XML declaration or not
null
public static String transform(Source xml,
Source xslt)
xml - the document to transformxslt - the stylesheet to apply
null if an error occurs or null xml or xslt input
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||