public abstract class XmlRepresentation extends WriterRepresentation implements NamespaceContext
| Modifier and Type | Field and Description |
|---|---|
static boolean |
XML_EXPANDING_ENTITY_REFS
True for expanding entity references when parsing XML representations;
default value provided by system property
"org.restlet.ext.xml.expandingEntityRefs", false by default.
|
static boolean |
XML_VALIDATING_DTD
True for validating DTD documents when parsing XML representations;
default value provided by system property
"org.restlet.ext.xml.validatingDtd", false by default.
|
UNKNOWN_SIZE| Constructor and Description |
|---|
XmlRepresentation(MediaType mediaType)
Constructor.
|
XmlRepresentation(MediaType mediaType,
long expectedSize)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Boolean |
getBoolean(String expression)
Evaluates an XPath expression as a boolean.
|
protected Document |
getDocument()
Returns the XML representation as a DOM document.
|
protected DocumentBuilder |
getDocumentBuilder()
Returns a document builder properly configured.
|
DOMSource |
getDomSource()
Returns a DOM source.
|
EntityResolver |
getEntityResolver()
Return the possibly null current SAX
EntityResolver. |
ErrorHandler |
getErrorHandler()
Return the possibly null current SAX
ErrorHandler. |
abstract InputSource |
getInputSource()
Returns the XML representation as a SAX input source.
|
Map<String,String> |
getNamespaces()
Returns the map of namespaces.
|
String |
getNamespaceURI(String prefix) |
Node |
getNode(String expression)
Evaluates an XPath expression as a DOM Node.
|
NodeList |
getNodes(String expression)
Evaluates an XPath expression as a DOM NodeList.
|
Double |
getNumber(String expression)
Evaluates an XPath expression as a number.
|
String |
getPrefix(String namespaceURI) |
Iterator<String> |
getPrefixes(String namespaceURI) |
SAXSource |
getSaxSource()
Returns a SAX source.
|
static SAXSource |
getSaxSource(Representation xmlRepresentation)
Returns a SAX source.
|
Schema |
getSchema()
Return the possibly null
Schema to use for
this type of XML representations. |
StreamSource |
getStreamSource()
Returns a stream of XML markup.
|
String |
getText(String expression)
Evaluates an XPath expression as a string.
|
boolean |
isCoalescing()
Indicates if the parser should be coalescing text.
|
boolean |
isExpandingEntityRefs()
Indicates if the parser will expand entity reference nodes.
|
boolean |
isIgnoringComments()
Indicates if the parser will ignore comments.
|
boolean |
isIgnoringExtraWhitespaces()
Indicates if the parser will ignore extra white spaces in element
content.
|
boolean |
isNamespaceAware()
Indicates if processing is namespace aware.
|
boolean |
isValidatingDtd()
Indicates the desire for validating this type of XML representations
against an XML schema if one is referenced within the contents.
|
boolean |
isXIncludeAware()
Indicates the desire for processing XInclude if found in this
type of XML representations.
|
void |
release()
Releases the namespaces map.
|
void |
setCoalescing(boolean coalescing)
Indicates if the parser should be coalescing text.
|
void |
setEntityResolver(EntityResolver entityResolver)
Set the
EntityResolver to use when resolving external entity
references encountered in this type of XML representations. |
void |
setErrorHandler(ErrorHandler errorHandler)
Set the
ErrorHandler to use when signaling SAX event exceptions. |
void |
setExpandingEntityRefs(boolean expandEntityRefs)
Indicates if the parser will expand entity reference nodes.
|
void |
setIgnoringComments(boolean ignoringComments)
Indicates if the parser will ignore comments.
|
void |
setIgnoringExtraWhitespaces(boolean ignoringExtraWhitespaces)
Indicates if the parser will ignore extra white spaces in element
content.
|
void |
setNamespaceAware(boolean namespaceAware)
Indicates if processing is namespace aware.
|
void |
setNamespaces(Map<String,String> namespaces)
Sets the map of namespaces.
|
void |
setSchema(Representation schemaRepresentation)
Set a schema representation to be compiled and used when parsing and
validating this type of XML representations.
|
void |
setSchema(Schema schema)
Set a (compiled)
Schema to use when parsing
and validating this type of XML representations. |
void |
setValidatingDtd(boolean validating)
Indicates the desire for validating this type of XML representations
against an XML schema if one is referenced within the contents.
|
void |
setXIncludeAware(boolean includeAware)
Indicates the desire for processing XInclude if found in this
type of XML representations.
|
void |
validate(Representation schemaRepresentation)
Validates the XML representation against a given schema.
|
void |
validate(Representation schemaRepresentation,
Result result)
Validates the XML representation against a given schema.
|
void |
validate(Schema schema)
Validates the XML representation against a given schema.
|
void |
validate(Schema schema,
Result result)
Validates the XML representation against a given schema.
|
getReadergetChannel, getStream, write, writeappend, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient, writegetModificationDate, getTag, setModificationDate, setTagcreateClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toStringpublic static final boolean XML_EXPANDING_ENTITY_REFS
public static final boolean XML_VALIDATING_DTD
public XmlRepresentation(MediaType mediaType)
mediaType - The representation's mediaType.public XmlRepresentation(MediaType mediaType, long expectedSize)
mediaType - The representation's mediaType.expectedSize - The expected input stream size.public static SAXSource getSaxSource(Representation xmlRepresentation) throws IOException
xmlRepresentation - The XML representation to wrap.IOExceptionpublic Boolean getBoolean(String expression)
protected Document getDocument() throws Exception
Exceptionprotected DocumentBuilder getDocumentBuilder() throws IOException
IOExceptionpublic DOMSource getDomSource() throws IOException
IOExceptionpublic EntityResolver getEntityResolver()
EntityResolver.EntityResolver.public ErrorHandler getErrorHandler()
ErrorHandler.ErrorHandler.public abstract InputSource getInputSource() throws IOException
IOExceptionpublic Map<String,String> getNamespaces()
public String getNamespaceURI(String prefix)
getNamespaceURI in interface NamespaceContextpublic Node getNode(String expression)
public NodeList getNodes(String expression)
public Double getNumber(String expression)
public String getPrefix(String namespaceURI)
getPrefix in interface NamespaceContextpublic Iterator<String> getPrefixes(String namespaceURI)
getPrefixes in interface NamespaceContextpublic SAXSource getSaxSource() throws IOException
IOExceptionpublic Schema getSchema()
Schema to use for
this type of XML representations.Schema object of this type of
XML representations.public StreamSource getStreamSource() throws IOException
IOExceptionpublic String getText(String expression)
public boolean isCoalescing()
public boolean isExpandingEntityRefs()
public boolean isIgnoringComments()
public boolean isIgnoringExtraWhitespaces()
isValidatingDtd() must be true when this
property is 'true' as validation is needed for it to work. By default the
value of this is set to false.public boolean isNamespaceAware()
public boolean isValidatingDtd()
public boolean isXIncludeAware()
public void release()
release in class Representationpublic void setCoalescing(boolean coalescing)
coalescing - True if parser should be coalescing text.public void setEntityResolver(EntityResolver entityResolver)
EntityResolver to use when resolving external entity
references encountered in this type of XML representations.entityResolver - the EntityResolver to set.public void setErrorHandler(ErrorHandler errorHandler)
ErrorHandler to use when signaling SAX event exceptions.errorHandler - the ErrorHandler to set.public void setExpandingEntityRefs(boolean expandEntityRefs)
expandEntityRefs - True if the parser will expand entity reference nodes.public void setIgnoringComments(boolean ignoringComments)
ignoringComments - True if the parser will ignore comments.public void setIgnoringExtraWhitespaces(boolean ignoringExtraWhitespaces)
setValidatingDtd(boolean) will be invoked
with 'true' if setting this property to 'true' as validation is needed
for it to work.ignoringExtraWhitespaces - True if the parser will ignore extra white spaces in element
content.public void setNamespaceAware(boolean namespaceAware)
namespaceAware - Indicates if processing is namespace aware.public void setNamespaces(Map<String,String> namespaces)
namespaces - The map of namespaces.public void setSchema(Schema schema)
Schema to use when parsing
and validating this type of XML representations.schema - The (compiled) Schema object to
set.public void setSchema(Representation schemaRepresentation)
schemaRepresentation - The schema representation to set.public void setValidatingDtd(boolean validating)
validating - The new validation flag to set.public void setXIncludeAware(boolean includeAware)
includeAware - The new value of the xIncludeAware flag.public void validate(Schema schema) throws Exception
schema - The XML schema to use.Exceptionpublic void validate(Schema schema, Result result) throws Exception
schema - The XML schema to use.result - The Result object that receives (possibly augmented) XML.Exceptionpublic void validate(Representation schemaRepresentation) throws Exception
schemaRepresentation - The XML schema representation to use.Exceptionpublic void validate(Representation schemaRepresentation, Result result) throws Exception
schemaRepresentation - The XML schema representation to use.result - The Result object that receives (possibly augmented) XML.ExceptionCopyright © 2005-2017 Restlet.