|
Berkeley DB XML version 2.3.10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.dbxml.XmlModify
public class XmlModify
The context within which a set of one or more documents specified by an XQuery query can be modified in place. The modification is performed using an XmlModify object, and a series of methods off that object that identify how the document is to be modified. Using these methods, the modification steps are identified. When the object is executed, these steps are performed in the order that they were specified.
XmlModify objects are created using XmlManager.createModify()
.
The modification steps are executed against one or more documents using
execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
. This method can operate on a single
document stored in an XmlValue
, or against multiple documents
stored in an XmlResults
set that was created as the result of a
container or document query.
By default, document modifications are written back to their respective
containers. It is possible to avoid this, in order to perform
temporary modifications, or group multiple modification sets. Use
XmlUpdateContext.setApplyChangesToContainers(boolean)
to control this
behavior.
Documents in containers using node storage are updated partially, and only affected nodes and indexes are modified, if possible. Documents in containers using whole-document storage are entirely rewritten and re-indexed.
During construction, XmlModify objects are not free-threaded. They must be constructed in a thread-safe manner. However, a single XmlModify object, once constructed, can be used simultaneously by multiple threads.
Field Summary | |
---|---|
static int |
Attribute
The information to be inserted is an attribute node. |
static int |
Comment
The information to be inserted is a comment node. |
static int |
Element
The information to be inserted is an element node. |
static int |
ProcessingInstruction
The information to be inserted is a processing instruction node. |
static int |
Text
The information to be inserted is a text node. |
Constructor Summary | |
---|---|
XmlModify(XmlModify o)
Copy constructor. |
Method Summary | |
---|---|
void |
addAppendStep(XmlQueryExpression selectionExpr,
int type,
String name,
String content)
Appends the provided data to the selected node's child nodes. |
void |
addAppendStep(XmlQueryExpression selectionExpr,
int type,
String name,
String content,
int location)
Appends the provided data to the selected node's child nodes. |
void |
addAppendStep(XmlQueryExpression selectionExpr,
int type,
String name,
XmlResults resultContent,
int location)
Appends the provided data to the selected node's child nodes, using an XmlResults object as content. |
void |
addInsertAfterStep(XmlQueryExpression selectionExpr,
int type,
String name,
String content)
Inserts the provided data into the document after the selected node. |
void |
addInsertAfterStep(XmlQueryExpression selectionExpr,
int type,
String name,
XmlResults resultContent)
Inserts the provided data into the document after the selected node using the specified XmlResults object as content. |
void |
addInsertBeforeStep(XmlQueryExpression selectionExpr,
int type,
String name,
String content)
Inserts the provided data into the document before the selected node, as a previous sibling. |
void |
addInsertBeforeStep(XmlQueryExpression selectionExpr,
int type,
String name,
XmlResults resultContent)
Inserts the provided data into the document before the selected node, as a previous sibling using an XmlResults object as content
If the operation's target is an attribute node or the document root
node, an exception is thrown at modification execution time. |
void |
addRemoveStep(XmlQueryExpression selectionExpr)
Removes the node targeted by the selection expression. |
void |
addRenameStep(XmlQueryExpression selectionExpr,
String newName)
Renames an element node, attribute node, or processing instruction. |
void |
addUpdateStep(XmlQueryExpression selectionExpr,
String content)
Replaces the targeted node's content with text. |
void |
delete()
Free the native resources associated with this object. |
long |
execute(XmlResults toModify,
XmlQueryContext context,
XmlUpdateContext uc)
Executes one or more document modification operations (or steps) against an XmlValue object. |
long |
execute(XmlTransaction txn,
XmlResults toModify,
XmlQueryContext context,
XmlUpdateContext uc)
Executes one or more document modification operations (or steps) against an XmlValue object. |
long |
execute(XmlTransaction txn,
XmlValue toModify,
XmlQueryContext context,
XmlUpdateContext uc)
Executes one or more document modification operations (or steps) against an XmlValue object. |
long |
execute(XmlValue toModify,
XmlQueryContext context,
XmlUpdateContext uc)
Executes one or more document modification operations (or steps) against an XmlValue object. |
void |
setNewEncoding(String newEncoding)
Sets a new character encoding to be used for documents modified by calls to execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext) . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int Element
name
parameter is specified, it represents the element's name. If it is not specified, the content must contain an element tag as content. If the content
parameter is specified, then it contains the content (that is, text or a XML document fragment) contained by the new document element.
public static final int Attribute
name
parameter is required, and it represents the attribute's name. If the content
parameter is specified, then it contains the attribute's value.
public static final int Text
content
parameter is required. The name
parameter is ignored.
public static final int ProcessingInstruction
name
and content
parameters are required. The name
is the processing instruction's name, and the content
contains the processing instruction's arguments.
public static final int Comment
content
parameter is required, and it contains the comment to be inserted. The name
parameter is ignored.
Constructor Detail |
---|
public XmlModify(XmlModify o) throws XmlException
XmlException
Method Detail |
---|
public void delete()
public void addInsertBeforeStep(XmlQueryExpression selectionExpr, int type, String name, String content) throws XmlException
If the content to be added is an attribute, the content is added to the targeted node's parent node. For any other type of content, the content is inserted into the document immediately before the targeted node's start tag.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the location in the document where the modification is to be performed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. The query that you provide must target zero or more nodes, or an exception is thrown. If zero nodes are selected,
no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.type
- The type of information to be inserted. The value provided here
determines whether the name
or content
parameter is
required. Valid values are: Element
, Attribute
, Text
, ProcessingInstruction
or Comment
.name
- The name of the node, attribute, or processing instruction to insert. This parameter is ignored if type
is XmlModify.Text or XmlModify.Comment.content
- The content to insert. See the type
parameter description for an explanation of what this parameter is meant to contain for each of the content types.
XmlException
public void addInsertBeforeStep(XmlQueryExpression selectionExpr, int type, String name, XmlResults resultContent) throws XmlException
XmlResults
object as content
If the operation's target is an attribute node or the document root
node, an exception is thrown at modification execution time.
If the content to be added is an attribute, the content is added to the targeted node's parent node. For any other type of content, the content is inserted into the document immediately before the targeted node's start tag.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the location in the document where the modification is to be performed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. The query that you provide must target zero or more nodes, or an exception is thrown. If zero nodes are selected,
no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.type
- The type of information to be inserted. The value provided here
determines whether the name
or content
parameter is
required. Valid values are: Element
, Attribute
, Text
, ProcessingInstruction
or Comment
.name
- The name of the node, attribute, or processing instruction to insert. This parameter is ignored if type
is XmlModify.Text or XmlModify.Comment.resultContent
- The XmlResults
object containing the content to insert. See the type
parameter description for an explanation of what this parameter is meant to contain for each of the content types.
XmlException
public void addInsertAfterStep(XmlQueryExpression selectionExpr, int type, String name, String content) throws XmlException
If the content to be added is an attribute, the content is added to the targeted node's parent node. For any other type of content, the content is inserted into the document immediately after the targeted node's end tag, as its next sibling.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the location in the document where the modification is to be performed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. The query that you provide must target zero or more nodes, or an exception is thrown. If zero nodes are selected,
no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.type
- The type of information to be inserted. The value provided here
determines whether the name
or content
parameter is
required. Valid values are: Element
, Attribute
, Text
, ProcessingInstruction
or Comment
.name
- The name of the node, attribute, or processing instruction to insert. This parameter is ignored if type
is XmlModify.Text or XmlModify.Comment.content
- The content to insert. See the type
parameter description for an explanation of what this parameter is meant to contain for each of the content types.
XmlException
public void addInsertAfterStep(XmlQueryExpression selectionExpr, int type, String name, XmlResults resultContent) throws XmlException
XmlResults
object as content.
If the operation's target is an attribute node or the document root
node, an exception is thrown at modification execution time.
If the content to be added is an attribute, the content is added to the targeted node's parent node. For any other type of content, the content is inserted into the document immediately after the targeted node's end tag, as its next sibling.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the location in the document where the modification is to be performed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. The query that you provide must target zero or more nodes, or an exception is thrown. If zero nodes are selected,
no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.type
- The type of information to be inserted. The value provided here
determines whether the name
or content
parameter is
required. Valid values are: Element
, Attribute
, Text
, ProcessingInstruction
or Comment
.name
- The name of the node, attribute, or processing instruction to insert. This parameter is ignored if type
is XmlModify.Text or XmlModify.Comment.resultContent
- The XmlResults
object containing the content to insert. See the type
parameter description for an explanation of what this parameter is meant to contain for each of the content types.
XmlException
public void addAppendStep(XmlQueryExpression selectionExpr, int type, String name, String content, int location) throws XmlException
If the content to be added is an attribute, the content is added to the targeted node's attribute list. If the content to add is an element node, text, comment or processing instruction, its content is added immediately after the targeted node's last child node, unless the location parameter is specified.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the location in the document where the modification is to be performed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. The query that you provide must target zero or more nodes, or an exception is thrown. If zero nodes are selected,
no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.type
- The type of information to be inserted. The value provided here
determines whether the name
or content
parameter is
required. Valid values are: Element
, Attribute
, Text
, ProcessingInstruction
or Comment
.name
- The name of the node, attribute, or processing instruction to insert. This parameter is ignored if type
is XmlModify.Text or XmlModify.Comment.content
- The content to insert. See the type
parameter description for an explanation of what this parameter is meant to contain for each of the content types.location
- Identifies the position in the child node list where the
provided content is to be inserted. For example, if location is 3, and the
target element has at least 3 child nodes, the new content will become the 3rd
child of the target node. If this parameter is a negative number, or if this
parameter contains a value that is larger than the number of child nodes, then
the new node will be the last child node.
XmlException
public void addAppendStep(XmlQueryExpression selectionExpr, int type, String name, String content) throws XmlException
If the content to be added is an attribute, the content is added to the targeted node's attribute list. If the content to add is an element node, text, comment or processing instruction, its content is added immediately after the targeted node's last child node, unless the location parameter is specified.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the location in the document where the modification is to be performed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. The query that you provide must target zero or more nodes, or an exception is thrown. If zero nodes are selected,
no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.type
- The type of information to be inserted. The value provided here
determines whether the name
or content
parameter is
required. Valid values are: Element
, Attribute
, Text
, ProcessingInstruction
or Comment
.name
- The name of the node, attribute, or processing instruction to insert. This parameter is ignored if type
is XmlModify.Text or XmlModify.Comment.content
- The content to insert. See the type
parameter description for an explanation of what this parameter is meant to contain for each of the content types.
XmlException
public void addAppendStep(XmlQueryExpression selectionExpr, int type, String name, XmlResults resultContent, int location) throws XmlException
XmlResults
object as content.
If the operation's target is an attribute node or the document root
node, an exception is thrown at modification execution time.
If the content to be added is an attribute, the content is added to the targeted node's attribute list. If the content to add is an element node, text, comment or processing instruction, its content is added immediately after the targeted node's last child node, unless the location parameter is specified.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the location in the document where the modification is to be performed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. The query that you provide must target zero or more nodes, or an exception is thrown. If zero nodes are selected,
no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.type
- The type of information to be inserted. The value provided here
determines whether the name
or content
parameter is
required. Valid values are: Element
, Attribute
, Text
, ProcessingInstruction
or Comment
.name
- The name of the node, attribute, or processing instruction to insert. This parameter is ignored if type
is XmlModify.Text or XmlModify.Comment.resultContent
- The XmlResults
object containing the content to insert. See the type
parameter description for an explanation of what this parameter is meant to contain for each of the content types.location
- Identifies the position in the child node list where the
provided content is to be inserted. For example, if location is 3, and the
target element has at least 3 child nodes, the new content will become the 3rd
child of the target node. If this parameter is a negative number, or if this
parameter contains a value that is larger than the number of child nodes, then
the new node will be the last child node.
XmlException
public void addUpdateStep(XmlQueryExpression selectionExpr, String content) throws XmlException
text
. If the targeted node is an attribute node, the
attribute's value is replaced by text
. The purpose
of this interface is primarily to replace text content. Note that
text
is treated as a text node. If it contains
mark-up, that mark-up is escaped to make it legal text.
Documents resulting from this modification must be well-formed XML or an exception is thrown at modification execution time, if the documents affected are written back to their respective containers.
selectionExpr
- The XQuery expression used to target the node to be updated. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the
XmlQueryExpression
. If zero nodes are targeted by this
expression, no modifications are performed when
execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.content
- The content to use as the targeted node's content.
XmlException
public void addRemoveStep(XmlQueryExpression selectionExpr) throws XmlException
selectionExpr
- The XQuery expression used to target the node to be removed.
Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the
XmlQueryExpression
. If zero nodes are targeted by this
expression, no modifications are performed when
execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.
XmlException
public void addRenameStep(XmlQueryExpression selectionExpr, String newName) throws XmlException
selectionExpr
is any other type of content, an exception is thrown at modification execution time.
selectionExpr
- The XQuery expression used to target the node to be renamed. Use XmlManager.prepare(java.lang.String, com.sleepycat.dbxml.XmlQueryContext)
to create the XmlQueryExpression
. If zero nodes are targeted by this expression, no modifications are performed when execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
is called.newName
- The new name to give the targeted node.
XmlException
public void setNewEncoding(String newEncoding) throws XmlException
execute(com.sleepycat.dbxml.XmlValue, com.sleepycat.dbxml.XmlQueryContext, com.sleepycat.dbxml.XmlUpdateContext)
. The encoding must be a valid encoding for an XML document, such as "UTF-8" or "ISO-8859-1". Errors or invalid encodings may not be detected until the modification operation is performed.
newEncoding
- Specifies the encoding to use. This string must be encoded as UTF-8.
XmlException
public long execute(XmlValue toModify, XmlQueryContext context, XmlUpdateContext uc) throws XmlException
XmlValue
object. Upon completing the
modification, the modified document is automatically updated in the
backing XmlContainer
for you.
Note that the modification steps are executed in the order that they
were specified to this object. Modification steps are specified using
addAppendStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String, int)
,
addInsertAfterStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addInsertBeforeStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addRemoveStep(com.sleepycat.dbxml.XmlQueryExpression)
,
addRenameStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
, and
addUpdateStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
.
This method can thrown an exception for any number of reasons; the most common being that an illegal modification was requested. In addition, if a resulting document is not well-formed XML, this method will throw a parsing exception if that document is written to its container.
toModify
- The XmlValue
to modify using this collection of modification steps.context
- The XmlQueryContext
to use for this modification.uc
- The XmlUpdateContext
to use for this modification.
XmlException
public long execute(XmlResults toModify, XmlQueryContext context, XmlUpdateContext uc) throws XmlException
XmlValue
object. Upon completing the
modification, the modified document is automatically updated in the
backing XmlContainer
for you.
Note that the modification steps are executed in the order that they
were specified to this object. Modification steps are specified using
addAppendStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String, int)
,
addInsertAfterStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addInsertBeforeStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addRemoveStep(com.sleepycat.dbxml.XmlQueryExpression)
,
addRenameStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
, and
addUpdateStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
.
This method can thrown an exception for any number of reasons; the most common being that an illegal modification was requested. In addition, if a resulting document is not well-formed XML, this method will throw a parsing exception if that document is written to its container.
toModify
- The XmlResults
object containing the result set to modify. Note that the modification occurs from the current position in the results set and proceeds until the end of the results set is reached. This means that if you iterated over the results set prior to passing the XmlResults object to this method, you must call XmlResults.reset()
or no modifications will occur.context
- The XmlQueryContext
to use for this modification.uc
- The XmlUpdateContext
to use for this modification.
XmlException
public long execute(XmlTransaction txn, XmlValue toModify, XmlQueryContext context, XmlUpdateContext uc) throws XmlException
XmlValue
object. Upon completing the
modification, the modified document is automatically updated in the
backing XmlContainer
for you.
Note that the modification steps are executed in the order that they
were specified to this object. Modification steps are specified using
addAppendStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String, int)
,
addInsertAfterStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addInsertBeforeStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addRemoveStep(com.sleepycat.dbxml.XmlQueryExpression)
,
addRenameStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
, and
addUpdateStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
.
This method can thrown an exception for any number of reasons; the most common being that an illegal modification was requested. In addition, if a resulting document is not well-formed XML, this method will throw a parsing exception if that document is written to its container.
txn
- If the operation is to be transaction-protected, the txn
parameter is an XmlTransaction
handle returned from XmlManager.createTransaction()
.toModify
- The XmlValue
to modify using this collection of modification steps.context
- The XmlQueryContext
to use for this modification.uc
- The XmlUpdateContext
to use for this modification.
XmlException
public long execute(XmlTransaction txn, XmlResults toModify, XmlQueryContext context, XmlUpdateContext uc) throws XmlException
XmlValue
object. Upon completing the
modification, the modified document is automatically updated in the
backing XmlContainer
for you.
Note that the modification steps are executed in the order that they
were specified to this object. Modification steps are specified using
addAppendStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String, int)
,
addInsertAfterStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addInsertBeforeStep(com.sleepycat.dbxml.XmlQueryExpression, int, java.lang.String, java.lang.String)
,
addRemoveStep(com.sleepycat.dbxml.XmlQueryExpression)
,
addRenameStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
, and
addUpdateStep(com.sleepycat.dbxml.XmlQueryExpression, java.lang.String)
.
This method can thrown an exception for any number of reasons; the most common being that an illegal modification was requested. In addition, if a resulting document is not well-formed XML, this method will throw a parsing exception if that document is written to its container.
txn
- If the operation is to be transaction-protected, the txn
parameter is an XmlTransaction
handle returned from XmlManager.createTransaction()
.toModify
- The XmlResults
object containing the result set to modify. Note that the modification occurs from the current position in the results set and proceeds until the end of the results set is reached. This means that if you iterated over the results set prior to passing the XmlResults object to this method, you must call XmlResults.reset()
or no modifications will occur.context
- The XmlQueryContext
to use for this modification.uc
- The XmlUpdateContext
to use for this modification.
XmlException
|
Berkeley DB XML version 2.3.10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |