org.xmldb.api.modules
public interface XMLResource extends Resource
String
content.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
RESOURCE_TYPE |
Modifier and Type | Method and Description |
---|---|
org.w3c.dom.Node |
getContentAsDOM()
Returns the content of the
Resource as a DOM Node. |
void |
getContentAsSAX(org.xml.sax.ContentHandler handler)
Allows you to use a
ContentHandler to parse the XML data from
the database for use in an application. |
java.lang.String |
getDocumentId()
Returns the unique id for the parent document to this
Resource
or null if the Resource does not have a parent document. |
void |
setContentAsDOM(org.w3c.dom.Node content)
Sets the content of the
Resource using a DOM Node as the
source. |
org.xml.sax.ContentHandler |
setContentAsSAX()
Sets the content of the
Resource using a SAX
ContentHandler . |
getContent, getId, getParentCollection, getResourceType, setContent
static final java.lang.String RESOURCE_TYPE
java.lang.String getDocumentId() throws XMLDBException
Resource
or null if the Resource
does not have a parent document.
getDocumentId()
is typically used with Resource
instances retrieved using a query. It enables accessing the parent
document of the Resource
even if the Resource
is
a child node of the document. If the Resource
was not
obtained through a query then getId()
and
getDocumentId()
will return the same id.Resource
or
null if there is no parent document for this Resource
.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.org.w3c.dom.Node getContentAsDOM() throws XMLDBException
Resource
as a DOM Node.Node
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.void setContentAsDOM(org.w3c.dom.Node content) throws XMLDBException
Resource
using a DOM Node as the
source.content
- The new content valueXMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.ErrorCodes.INVALID_RESOURCE
if the content value provided is
null.ErrorCodes.WRONG_CONTENT_TYPE
if the content provided in not
a valid DOM Node
.void getContentAsSAX(org.xml.sax.ContentHandler handler) throws XMLDBException
ContentHandler
to parse the XML data from
the database for use in an application.handler
- the SAX ContentHandler
to use to handle the
Resource
content.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.ErrorCodes.INVALID_RESOURCE
if the
ContentHandler
provided is null.org.xml.sax.ContentHandler setContentAsSAX() throws XMLDBException
Resource
using a SAX
ContentHandler
.ContentHandler
that can be used to add content
into the Resource
.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.