Package org.xmldb.api.modules
Interface XMLResource
- All Superinterfaces:
Resource
- All Known Implementing Classes:
SimpleXMLResource
,XMLResourceImpl
Provides access to XML resources stored in the database. An XMLResource can
be accessed either as text XML or via the DOM or SAX APIs.
The default behavior for getContent and setContent is to work with XML data
as text so these methods work on
String
content.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns the content of theResource
as a DOM Node.void
getContentAsSAX
(ContentHandler handler) Allows you to use aContentHandler
to parse the XML data from the database for use in an application.Returns the unique id for the parent document to thisResource
or null if theResource
does not have a parent document.boolean
getSAXFeature
(String feature) Returns current setting of a SAX feature that will be used when thisXMLResource
is used to produce SAX events (through the getContentAsSAX() method)void
setContentAsDOM
(Node content) Sets the content of theResource
using a DOM Node as the source.Sets the content of theResource
using a SAXContentHandler
.void
setSAXFeature
(String feature, boolean value) Sets a SAX feature that will be used when thisXMLResource
is used to produce SAX events (through the getContentAsSAX() method)Methods inherited from interface org.xmldb.api.base.Resource
getContent, getId, getParentCollection, getResourceType, setContent
-
Field Details
-
RESOURCE_TYPE
- See Also:
-
-
Method Details
-
getDocumentId
Returns the unique id for the parent document to thisResource
or null if theResource
does not have a parent document.getDocumentId()
is typically used withResource
instances retrieved using a query. It enables accessing the parent document of theResource
even if theResource
is a child node of the document. If theResource
was not obtained through a query thengetId()
andgetDocumentId()
will return the same id.- Returns:
- the id for the parent document of this
Resource
or null if there is no parent document for thisResource
. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
getContentAsDOM
Returns the content of theResource
as a DOM Node.- Returns:
- The XML content as a DOM
Node
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
setContentAsDOM
Sets the content of theResource
using a DOM Node as the source.- Parameters:
content
- The new content value- Throws:
XMLDBException
- 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 DOMNode
.
-
getContentAsSAX
Allows you to use aContentHandler
to parse the XML data from the database for use in an application.- Parameters:
handler
- the SAXContentHandler
to use to handle theResource
content.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE
if theContentHandler
provided is null.
-
setContentAsSAX
Sets the content of theResource
using a SAXContentHandler
.- Returns:
- a SAX
ContentHandler
that can be used to add content into theResource
. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
setSAXFeature
void setSAXFeature(String feature, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException Sets a SAX feature that will be used when thisXMLResource
is used to produce SAX events (through the getContentAsSAX() method)- Parameters:
feature
- Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.value
- Set or unset feature- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
getSAXFeature
Returns current setting of a SAX feature that will be used when thisXMLResource
is used to produce SAX events (through the getContentAsSAX() method)- Parameters:
feature
- Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.- Returns:
- whether the feature is set
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-