|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.representation.CharacterRepresentation
org.restlet.representation.WriterRepresentation
org.restlet.ext.xml.XmlRepresentation
public abstract class XmlRepresentation
Representation based on an XML document. It knows how to evaluate XPath expressions and how to manage a namespace context. This class also offers convenient methods to validate the document against a specified XML scheme.
Field Summary |
---|
Fields inherited from class org.restlet.representation.Representation |
---|
UNKNOWN_SIZE |
Constructor Summary | |
---|---|
XmlRepresentation(MediaType mediaType)
Constructor. |
|
XmlRepresentation(MediaType mediaType,
long expectedSize)
Constructor. |
Method Summary | |
---|---|
java.lang.Object |
evaluate(java.lang.String expression,
javax.xml.namespace.QName returnType)
Deprecated. Use the getBoolean(String) ,
getNumber(String) , getText(String) ,
getNode(String) and getNodes(String)
methods instead. |
java.lang.Boolean |
getBoolean(java.lang.String expression)
Evaluates an XPath expression as a boolean. |
protected org.w3c.dom.Document |
getDocument()
Returns the XML representation as a DOM document. |
protected javax.xml.parsers.DocumentBuilder |
getDocumentBuilder()
Returns a document builder properly configured. |
javax.xml.transform.dom.DOMSource |
getDomSource()
Returns a DOM source. |
org.xml.sax.EntityResolver |
getEntityResolver()
Return the possibly null current SAX EntityResolver . |
org.xml.sax.ErrorHandler |
getErrorHandler()
Return the possibly null current SAX ErrorHandler . |
abstract org.xml.sax.InputSource |
getInputSource()
Returns the XML representation as a SAX input source. |
java.util.Map<java.lang.String,java.lang.String> |
getNamespaces()
Returns the map of namespaces. |
java.lang.String |
getNamespaceURI(java.lang.String prefix)
|
org.w3c.dom.Node |
getNode(java.lang.String expression)
Evaluates an XPath expression as a DOM Node. |
NodeList |
getNodes(java.lang.String expression)
Evaluates an XPath expression as a DOM NodeList. |
java.lang.Double |
getNumber(java.lang.String expression)
Evaluates an XPath expression as a number. |
java.lang.String |
getPrefix(java.lang.String namespaceURI)
|
java.util.Iterator<java.lang.String> |
getPrefixes(java.lang.String namespaceURI)
|
javax.xml.transform.sax.SAXSource |
getSaxSource()
Returns a SAX source. |
static javax.xml.transform.sax.SAXSource |
getSaxSource(Representation xmlRepresentation)
Returns a SAX source. |
javax.xml.validation.Schema |
getSchema()
Return the possibly null Schema to use for
this type of XML representations. |
javax.xml.transform.stream.StreamSource |
getStreamSource()
Returns a stream of XML markup. |
java.lang.String |
getText(java.lang.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 |
putNamespace(java.lang.String prefix,
java.lang.String namespaceURI)
Deprecated. Use the modifiable map returned by getNamespaces() |
void |
release()
Releases the namespaces map. |
void |
setCoalescing(boolean coalescing)
Indicates if the parser should be coalescing text. |
void |
setEntityResolver(org.xml.sax.EntityResolver entityResolver)
Set the EntityResolver to use when resolving external entity
references encountered in this type of XML representations. |
void |
setErrorHandler(org.xml.sax.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(java.util.Map<java.lang.String,java.lang.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(javax.xml.validation.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,
javax.xml.transform.Result result)
Validates the XML representation against a given schema. |
void |
validate(javax.xml.validation.Schema schema)
Validates the XML representation against a given schema. |
void |
validate(javax.xml.validation.Schema schema,
javax.xml.transform.Result result)
Validates the XML representation against a given schema. |
Methods inherited from class org.restlet.representation.WriterRepresentation |
---|
getReader, write |
Methods inherited from class org.restlet.representation.CharacterRepresentation |
---|
getChannel, getStream, write |
Methods inherited from class org.restlet.representation.Representation |
---|
checkDigest, checkDigest, computeDigest, createEmpty, exhaust, getAvailableSize, getDigest, getDisposition, getDownloadName, getExpirationDate, getRange, getSize, getText, isAvailable, isDownloadable, isTransient, setAvailable, setDigest, setDisposition, setDownloadable, setDownloadName, setExpirationDate, setRange, setSize, setTransient, write |
Methods inherited from class org.restlet.representation.RepresentationInfo |
---|
getModificationDate, getTag, setModificationDate, setTag |
Methods inherited from class org.restlet.representation.Variant |
---|
createClientInfo, equals, getCharacterSet, getEncodings, getIdentifier, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setIdentifier, setIdentifier, setLanguages, setLocationRef, setLocationRef, setMediaType, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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.Method Detail |
---|
public static javax.xml.transform.sax.SAXSource getSaxSource(Representation xmlRepresentation) throws java.io.IOException
xmlRepresentation
- The XML representation to wrap.
java.io.IOException
@Deprecated public java.lang.Object evaluate(java.lang.String expression, javax.xml.namespace.QName returnType) throws java.lang.Exception
getBoolean(String)
,
getNumber(String)
, getText(String)
,
getNode(String)
and getNodes(String)
methods instead.
returnType
- The qualified name of the return type.
java.lang.Exception
XPathException
,
XPathConstants
public java.lang.Boolean getBoolean(java.lang.String expression)
protected org.w3c.dom.Document getDocument() throws java.lang.Exception
java.lang.Exception
protected javax.xml.parsers.DocumentBuilder getDocumentBuilder() throws java.io.IOException
java.io.IOException
public javax.xml.transform.dom.DOMSource getDomSource() throws java.io.IOException
java.io.IOException
public org.xml.sax.EntityResolver getEntityResolver()
EntityResolver
.
EntityResolver
.public org.xml.sax.ErrorHandler getErrorHandler()
ErrorHandler
.
ErrorHandler
.public abstract org.xml.sax.InputSource getInputSource() throws java.io.IOException
java.io.IOException
public java.util.Map<java.lang.String,java.lang.String> getNamespaces()
public java.lang.String getNamespaceURI(java.lang.String prefix)
getNamespaceURI
in interface javax.xml.namespace.NamespaceContext
public org.w3c.dom.Node getNode(java.lang.String expression)
public NodeList getNodes(java.lang.String expression)
public java.lang.Double getNumber(java.lang.String expression)
public java.lang.String getPrefix(java.lang.String namespaceURI)
getPrefix
in interface javax.xml.namespace.NamespaceContext
public java.util.Iterator<java.lang.String> getPrefixes(java.lang.String namespaceURI)
getPrefixes
in interface javax.xml.namespace.NamespaceContext
public javax.xml.transform.sax.SAXSource getSaxSource() throws java.io.IOException
java.io.IOException
public javax.xml.validation.Schema getSchema()
Schema
to use for
this type of XML representations.
Schema
object of this type of
XML representations.public javax.xml.transform.stream.StreamSource getStreamSource() throws java.io.IOException
java.io.IOException
public java.lang.String getText(java.lang.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()
@Deprecated public void putNamespace(java.lang.String prefix, java.lang.String namespaceURI)
getNamespaces()
prefix
- The namespace prefix.namespaceURI
- The namespace URI.public void release()
release
in class WriterRepresentation
public void setCoalescing(boolean coalescing)
coalescing
- True if parser should be coalescing text.public void setEntityResolver(org.xml.sax.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(org.xml.sax.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(java.util.Map<java.lang.String,java.lang.String> namespaces)
namespaces
- The map of namespaces.public void setSchema(javax.xml.validation.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(javax.xml.validation.Schema schema) throws java.lang.Exception
schema
- The XML schema to use.
java.lang.Exception
public void validate(javax.xml.validation.Schema schema, javax.xml.transform.Result result) throws java.lang.Exception
schema
- The XML schema to use.result
- The Result object that receives (possibly augmented) XML.
java.lang.Exception
public void validate(Representation schemaRepresentation) throws java.lang.Exception
schemaRepresentation
- The XML schema representation to use.
java.lang.Exception
public void validate(Representation schemaRepresentation, javax.xml.transform.Result result) throws java.lang.Exception
schemaRepresentation
- The XML schema representation to use.result
- The Result object that receives (possibly augmented) XML.
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |