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 theResourceas a DOM Node.voidgetContentAsSAX(ContentHandler handler) Allows you to use aContentHandlerto parse the XML data from the database for use in an application.Returns the unique id for the parent document to thisResourceor null if theResourcedoes not have a parent document.booleangetSAXFeature(String feature) Returns current setting of a SAX feature that will be used when thisXMLResourceis used to produce SAX events (through the getContentAsSAX() method)voidsetContentAsDOM(Node content) Sets the content of theResourceusing a DOM Node as the source.Sets the content of theResourceusing a SAXContentHandler.voidsetSAXFeature(String feature, boolean value) Sets a SAX feature that will be used when thisXMLResourceis 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 thisResourceor null if theResourcedoes not have a parent document.getDocumentId()is typically used withResourceinstances retrieved using a query. It enables accessing the parent document of theResourceeven if theResourceis a child node of the document. If theResourcewas not obtained through a query thengetId()andgetDocumentId()will return the same id.- Returns:
- the id for the parent document of this
Resourceor null if there is no parent document for thisResource. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getContentAsDOM
Returns the content of theResourceas a DOM Node.- Returns:
- The XML content as a DOM
Node - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
setContentAsDOM
Sets the content of theResourceusing a DOM Node as the source.- Parameters:
content- The new content value- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCEif the content value provided is null.
ErrorCodes.WRONG_CONTENT_TYPEif the content provided in not a valid DOMNode.
-
getContentAsSAX
Allows you to use aContentHandlerto parse the XML data from the database for use in an application.- Parameters:
handler- the SAXContentHandlerto use to handle theResourcecontent.- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCEif theContentHandlerprovided is null.
-
setContentAsSAX
Sets the content of theResourceusing a SAXContentHandler.- Returns:
- a SAX
ContentHandlerthat can be used to add content into theResource. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor 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 thisXMLResourceis 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:
SAXNotRecognizedExceptionSAXNotSupportedException
-
getSAXFeature
Returns current setting of a SAX feature that will be used when thisXMLResourceis 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:
SAXNotRecognizedExceptionSAXNotSupportedException
-