@Component @Named(value="xml") @Singleton public class XMLScriptService extends Object implements org.xwiki.script.service.ScriptService
Constructor and Description |
---|
XMLScriptService()
Default component constructor.
|
Modifier and Type | Method and Description |
---|---|
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 |
escapeForAttributeValue(Object content)
Escapes all the XML special characters in a
String using numerical XML entities, so that the
resulting string can safely be used as an XML attribute value. |
static String |
escapeForElementContent(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. |
Document |
parse(byte[] content)
Parse a
byte[] into a DOM Document. |
Document |
parse(InputStream stream)
Parse an
InputStream into a DOM Document. |
Document |
parse(LSInput source)
Parse a DOM Document from a source.
|
Document |
parse(String content)
Parse a
String into a DOM Document. |
String |
serialize(Node node)
Serialize a DOM Node into a string, including the XML declaration at the start.
|
String |
serialize(Node node,
boolean withXmlDeclaration)
Serialize a DOM Node into a string, with an optional XML declaration at the start.
|
String |
transform(byte[] xml,
byte[] xslt)
Apply an XSLT transformation to a Document, both given as byte arrays.
|
String |
transform(Document xml,
Document xslt)
Apply an XSLT transformation to a Document, both given as DOM Documents.
|
String |
transform(Source xml,
Source xslt)
Apply an XSLT transformation to a Document.
|
String |
transform(String xml,
String xslt)
Apply an XSLT transformation to a Document, both given as strings.
|
static String |
unescape(Object content)
Unescape encoded special XML characters.
|
public static String escape(Object content)
String
using numerical XML entities. Specifically,
escapes <, >, ", ' and &.content
- the text to escape, may be null
String
, null
if null
inputpublic static String escapeForAttributeValue(Object content)
String
using numerical XML entities, so that the
resulting string can safely be used as an XML attribute value. Specifically, escapes <, >, ", ' and &.content
- the text to escape, may be null
String
, null
if null
inputpublic static String escapeForElementContent(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 Document createDOMDocument()
public Document parse(LSInput source)
source
- the source input to parsenull
if the parsing failed.public Document parse(byte[] content)
byte[]
into a DOM Document.content
- the content to parsenull
if the content can't be parsed successfullypublic Document parse(String content)
String
into a DOM Document.content
- the content to parsenull
if the content can't be parsed successfullypublic Document parse(InputStream stream)
InputStream
into a DOM Document.stream
- the content input to parsenull
if the content can't be parsed successfullypublic String serialize(Node node)
node
- the node to exportpublic String serialize(Node node, boolean withXmlDeclaration)
node
- the node to exportwithXmlDeclaration
- whether to output the XML declaration or notnull
public String transform(Source xml, Source xslt)
xml
- the document to transformxslt
- the stylesheet to applynull
if an error occurs or null
xml or xslt inputpublic String transform(Document xml, Document xslt)
xml
- the document to transformxslt
- the stylesheet to applynull
if an error occurs or null
xml or xslt inputpublic String transform(byte[] xml, byte[] xslt)
xml
- the document to transformxslt
- the stylesheet to applynull
if an error occurs or null
xml or xslt inputCopyright © 2004–2021 XWiki. All rights reserved.