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 onString
content.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
RESOURCE_TYPE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.w3c.dom.Node
getContentAsDOM()
Returns the content of theResource
as a DOM Node.void
getContentAsSAX(org.xml.sax.ContentHandler handler)
Allows you to use aContentHandler
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 thisResource
or null if theResource
does not have a parent document.boolean
getSAXFeature(java.lang.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(org.w3c.dom.Node content)
Sets the content of theResource
using a DOM Node as the source.org.xml.sax.ContentHandler
setContentAsSAX()
Sets the content of theResource
using a SAXContentHandler
.void
setSAXFeature(java.lang.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 Detail
-
RESOURCE_TYPE
static final java.lang.String RESOURCE_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDocumentId
java.lang.String getDocumentId() throws XMLDBException
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
org.w3c.dom.Node getContentAsDOM() throws XMLDBException
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
void setContentAsDOM(org.w3c.dom.Node content) throws XMLDBException
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
void getContentAsSAX(org.xml.sax.ContentHandler handler) throws XMLDBException
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
org.xml.sax.ContentHandler setContentAsSAX() throws XMLDBException
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(java.lang.String feature, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.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:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
-
getSAXFeature
boolean getSAXFeature(java.lang.String feature) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
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:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
-
-