This page last changed on Apr 07, 2008.
edocs Home > BEA AquaLogic Data Services Platform 3.0/3.2 Documentation > ALDSP 3.2 New Features Documentation Mutator FunctionsThis topic describes the built-in mutator functions available in ALDSP 3.2.
fn-bea:changed-elementThe fn-bea:changed-element() function allows you to promote an element to an unmodified changed-element. You can then modify the resulting changed-element using the built-in mutator functions. The fn-bea:changed-element() function has the following signature: fn-bea:changed-element($e as element()) as changed-element() ExampleThe following call declares $cc to be an unmodified changed-element of type customer for the element represented by $c. declare $cc as changed-element(customer) := fn-bea:changed-element($c); fn-bea:insert-intoThe fn-bea:insert-into() function enables you to insert a node into an XXDM instance at a specified XPath location. The fn-bea:insert-into() function has the following signature: fn-bea:insert-into($ce as changed-element(), $path as xs:string, $value as node()) as changed-element() where
ExamplesConsider the changed-element customer that has the following value bound to the variable $cc: <customer ssn="XXX-XX-XXX">
<name>
<first>Thomas</first>
<last>Smith</last>
</name>
<address>...</address>
<address>...</address>
<orders>
<order>...</order>
<order>...</order>
<orders>
<customer>
Example - Inserting a New ElementConsider the following call: set $cc := fn-bea:insert-into($cc, "name", <middle>Paul</middle>);
Assuming that the schema for customer permits an element for the middle name (middle) as a child of name and between the elements first and last, the call inserts the middle element as follows: <customer ssn="XXX-XX-XXX">
<name>
<first>Thomas</first>
<middle>Paul</middle>
<last>Smith</last>
</name>
...
<customer>
Example - Inserting an Additional ElementConsider the following call: set $cc := fn-bea:insert-into($cc, ".", <address>...<city>York</city></address>);
The call inserts an additional address element into the customer element, as follows: <customer ssn="XXX-XX-XXX">
<name>...</name>
<address>...</address>
<address>...<city>York</city></address>
<address>...</address>
<orders>...</orders>
<customer>
Example - Inserting an AttributeConsider the following call: set $cc := fn-bea:insert-into($cc, "orders/order[2]", attribute paid { fn:true() }); The call inserts the paid attribute into the second order, as shown by the following.
<customer ssn="XXX-XX-XXX"> ... <orders> <order>...</order> <order paid="true">...</order> <orders> <customer> fn-bea:deleteThe fn-bea:delete() function enables you to delete a node at a specified XPath location in an XXDM instance. The function returns a copy of the instance that does not contain the specified descendant. The fn-bea:delete() function has the following signature: fn-bea:delete($ce as changed-element(), $path as xs:string) as changed-element() where:
ExamplesAssume that the variable $cust is bound to the value presented in the earlier example. Example - Deleting an ElementConsider the following call: set $cc := fn-bea:delete($cc, "address[2]");
The call deletes the second address child element of $cust, resulting in the value shown in the following: <customer ssn="XXX-XX-XXX">
<name>...</name>
<address>...</address>
<orders>...<orders>
<customer>
Example - Deleting an AttributeConsider the following call: set $cc := fn-bea:delete($cc, "@ssn");
The call deletes the ssn attribute of $cust, resulting in the value shown in the following: <customer> <name>...</name> <address>...</address> <address>...</address> <orders>...<orders> <customer> fn-bea:replace-valueThe fn-bea:replace-value() function enables you to replace the value of a node in an XXDM instance at a specified XPath location. The function returns a copy of the instance containing the replaced value. The fn-bea:replace-value() function has the following signature: fn-bea:replace-value($ce as changed-element(), $path as xs:string, $value as xdt:anyAtomicType*) as changed-element() where:
ExamplesAssume that the variable $cc is bound to the value presented in the earlier example. Example - Replacing the Contents of an ElementConsider the following call: set $cc := fn-bea:replace-value($cc, "name/last", "Jones"); The call changes the content of the last child of name from Smith to Jones, as shown in the following: <customer ssn="XXX-XX-XXX">
<name>
<first>Thomas</first>
<last>Jones</last>
</name>
...
<customer>
Example - Replacing an Attribute ValueConsider the following call: set $cc := fn-bea:replace-value($cc, "@ssn", "YYY-YY-YYYY"); The call changes the content of the ssn attribute from XXX-XX-XXX to YYY-YY-YYYY, as shown in the following: <customer ssn="YYY-YY-YYYY">
<name>...</name>
<address>...</address>
<address>...</address>
<orders>...<orders>
<customer>
Example - Removing the Contents of an ElementConsider the following call: set $cc := fn-bea:replace-value($cc, "name/first", ());
The call removes the content of the first child element of name, as shown in the following: <customer ssn="XXX-XX-XXX">
<name>
<first/>
<last>Smith</last>
</name>
...
<customer>
If the element first is nillable, the result would be nilled, as shown in the following: <customer ssn="XXX-XX-XXX"> <name> <first xsi:nil="true"/> <last>Smith</last> </name> ... <customer> See AlsoConceptsHow TosReference |
![]() |
Document generated by Confluence on Apr 28, 2008 16:19 |