Package org.xmldb.api.modules
Interface XMLResource
-
- All Superinterfaces:
Resource
- All Known Implementing Classes:
SimpleXMLResource,XMLResourceImpl
public interface XMLResource extends Resource
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 onStringcontent.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringRESOURCE_TYPE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.w3c.dom.NodegetContentAsDOM()Returns the content of theResourceas a DOM Node.voidgetContentAsSAX(org.xml.sax.ContentHandler handler)Allows you to use aContentHandlerto parse the XML data from the database for use in an application.java.lang.StringgetDocumentId()Returns the unique id for the parent document to thisResourceor null if theResourcedoes not have a parent document.booleangetSAXFeature(java.lang.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(org.w3c.dom.Node content)Sets the content of theResourceusing a DOM Node as the source.org.xml.sax.ContentHandlersetContentAsSAX()Sets the content of theResourceusing a SAXContentHandler.voidsetSAXFeature(java.lang.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 Detail
-
RESOURCE_TYPE
static final java.lang.String RESOURCE_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDocumentId
java.lang.String getDocumentId() throws XMLDBExceptionReturns 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
org.w3c.dom.Node getContentAsDOM() throws XMLDBExceptionReturns 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
void setContentAsDOM(org.w3c.dom.Node content) throws XMLDBExceptionSets 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
void getContentAsSAX(org.xml.sax.ContentHandler handler) throws XMLDBExceptionAllows 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
org.xml.sax.ContentHandler setContentAsSAX() throws XMLDBExceptionSets 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(java.lang.String feature, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSets 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:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
getSAXFeature
boolean getSAXFeature(java.lang.String feature) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionReturns 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:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
-