|
Berkeley DbXML version 1.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.dbxml.XmlDocument
An XmlDocument is the unit of storage within an XmlContainer. A document consists of content, a name, an ID, and a set of metadata attributes.
The document content is a byte stream. It must be well formed XML, but need not be valid.
The document name is a user-provided identifier for the document. The user can retrieve the document by name through the container query interface. The document name can be referenced in an XPath expression as "dbxml:name". For example, the XPath expression:
/*[@dbxml:name='abc123']
would retrieve the document with the name "abc123".
The Berkeley DB XML system assigns each document a unique ID when it is inserted into a container. The document ID uniquely identifies the document within a container, and can be used to retrieve the document from its container.
The metadata attributes provide a means of associating information with a document, without having to store it within the document itself. Example metadata attributes might be: document owner, creation time, receipt time, originating source, final destination, and next processing phase. They are analogous to the attributes of a file in a file system. Each metadata attribute consists of a name-value pair.
The copy constructor and assignment operator are provided for this class. The class is implemented using a handle-body idiom. When a handle is copied both handles maintain a reference to the same body.
Constructor Summary | |
XmlDocument()
|
Method Summary | |
void |
delete()
|
byte[] |
getContent()
The XmlDocument.getContent method returns a pointer to the document content. |
String |
getContentAsString()
The getContentAsString() method copies the content of the document into a string . |
int |
getID()
The XmlDocument.getID method returns the XmlDocument ID. |
boolean |
getMetaData(String uri,
String name,
XmlValue value)
The XmlDocument.getMetaData method returns the value of the specified metadata attribute. |
String |
getName()
The XmlDocument.getName method returns the XmlDocument name. |
void |
modifyDocument(XmlModify modify)
The XmlDocument.modifyDocument method modifies the XmlDocument contents based on the information contained in the XmlModify object. |
XmlResults |
queryWithXPath(String query,
XmlQueryContext context)
The XmlDocument.queryWithXPath method executes an XPath expression against the XmlDocument, and returns the results. |
XmlResults |
queryWithXPath(XmlQueryExpression query)
The XmlDocument.queryWithXPath method executes an XPath expression against the XmlDocument, and returns the results. |
void |
setContent(byte[] content)
The XmlDocument.setContent method sets the XmlDocument content. |
void |
setContent(String content)
The XmlDocument.setContent method sets the XmlDocument content. |
void |
setMetaData(String uri,
String prefix,
String name,
XmlValue value)
The XmlDocument.setMetaData method sets the value of the specified metadata attribute. |
void |
setName(String name)
The XmlDocument.setName method sets the name of the document. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XmlDocument() throws XmlException
XmlException
Method Detail |
public void delete()
public int getID()
XmlException
public void setName(String name) throws XmlException
name
- A string containing the name to be assigned to the XmlDocument.
XmlException
public String getName() throws XmlException
XmlException
public void setContent(byte[] content) throws XmlException
content
- A byte array containing the document content.
XmlException
public byte[] getContent()
XmlException
public void setContent(String content) throws XmlException
content
- A string containing the document content.
XmlException
public void modifyDocument(XmlModify modify) throws XmlException
XmlModify
object. In order to determine how many modification operations were performed, the XmlModify.getNumModifications
method should be used.
modify
- The XmlModify
object describing how to change the document. It encapsulates the XPath query, which specifies the target nodes in the document, as well as the modification operation to perform, with associated arguments.
XmlException
- The XmlDocument.modifyDocument method may fail and throw XmlException
, encapsulating one of the following non-zero errors: public String getContentAsString() throws XmlException
XmlException
public void setMetaData(String uri, String prefix, String name, XmlValue value) throws XmlException
A metadata attribute name consists of three parts; a namespace URI, a namespace prefix, and a local name. The namespace URI and prefix are optional, but should be used to avoid naming collisions.
Typed values are passed to the API as an instance of XmlValue
, and may be of type Number, String, or Boolean. The system reflects each typed metadata attribute into the document by adding a namespace declaration attribute and metadata attribute to the document root element. The following example associates a metadata attribute with a document:
XmlDocument document; document.setContent("<x/>"); document.setMetaData("http://acme.com/", "acme", "received", new XmlValue("1-Jan-2002"));
The system reflects the metadata attribute into the document as follows:
<x xmlns:acme= 'http://acme.com/' acme:received= '1-Jan-2002'/>
The metadata attribute can be queried using the XPath expression:
/*[@acme:received= '1-Jan-2002'].
uri
- The namespace within which the name resides. The empty string refers to the default namespace.prefix
- The prefix for the namespace.name
- The name of the metadata attribute.value
- A Number, String, or Boolean value.
XmlException
public boolean getMetaData(String uri, String name, XmlValue value) throws XmlException
uri
- The namespace within which the name resides. The empty string refers to the default namespace.name
- The name of the metadata attribute.value
- A Number, String, or Boolean value.
XmlException
public XmlResults queryWithXPath(String query, XmlQueryContext context) throws XmlException
The query may optionally be executed within an XmlQueryContext
, which describes how the query is to be performed. If no context is specified the default context is used. The default query context defines the namespace prefix "dbxml", contains no variable bindings, and specifies that the method should return the set of values selected by the XPath expression.
query
- The XPath expression provided as a string, conforming to the syntax defined in the W3C XPath 1.0 specification.context
- The context within which the query is to be performed. The context contains the variable bindings, the namespace prefix to URI mapping, and the query processing flags.
XmlException
- The XmlDocument.queryWithXPath method may fail and throw XmlException
, encapsulating one of the following non-zero errors: public XmlResults queryWithXPath(XmlQueryExpression query) throws XmlException
query
- The XPath expression as an XmlQueryExpression
.
XmlException
- The XmlDocument.queryWithXPath method may fail and throw XmlException
, encapsulating one of the following non-zero errors:
|
Berkeley DbXML version 1.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |