Hello everyone...
I'm trying to develop a system where all the configurations are saved as XML Files in Oracle XMLDB. We have own namespace for configuration. Oracle XMLDB provides a namespace XDIff through which I can specify what are the changes to be done in the XML, so that those changes will be updated in the database. But, the changes done in the configuration is coming as an Update XML file (in different namespace). I need to transform it to Oracle's XDiff namespace.
Example:
Configuration File:
<Configuration>
<Header>Some Info About Config</Header>
<ConfigItem1 attribute1="something">
<SubConfig11>1<SubConfig11>
<SubConfig12>2</SubConfig12>
</ConfigItem1>
<ConfigItem2 attribute2="something">1</ConfigItem2>
<ConfigItem3 attribute3="something">1</ConfigItem3>
</Configuration>
As you have seen, the configuration has some nested items too. The Update XML looks like:
<Configuration>
<ConfigItem1 attribute1="newthing" modifier="new">3</ConfigItem1>
<ConfigItem1 attribute1="something">
<SubConfig11 modifier="delete"/>
<SubConfig12 modifier="update">1</SubConfig12>
</ConfigItem1>
<ConfigItem2 attribute="something" modifier="update">
<SubConfig21>0</SubConfig21>
<SubConfig22>1</SubConfig21>
</ConfigItem2>
</Configuration>
The above Update XML means that
- A ConfigItem1 with attribute1 as "newthing" has to be created - Its text value is 3
- The SubConfig11 under ConfigItem1[@attribute1="something"] has to be deleted
- The SubConfig12 has to be updated with text value 1
- Update ConfigItem2 with 2 childs
The expected XDiff document for performing this update in Oracle is
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdiff.xsd">
<?oracle-xmldiff operations-in-docorder="false" output-model="current" diff-algorithm="global"?>
<xd:append-node xd:node-type="element" xd:xpath="/Configuration/ConfigItem1">
<xd:content>
<ConfigItem1 attribute1="newthing">3</ConfigItem1>
</xd:content>
</xd:append-node>
<xd:delete-node xd:node-type="element" xd:xpath="/Configuration/ConfigItem1[@attribute1=something]/SubConfig11"/>
<xd:update-node xd:node-type="text" xd:xpath="/Configuration/ConfigItem1[@attribute=something]/SubConfig12">
<xd:content>
1
</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="element" xd:xpath="/Configuration/ConfigItem2[@attribute2=something]">
<xd:content>
<SubConfig21>0</SubConfig21>
<SubConfig22>1</SubConfig21>
</xd:content>
</xd:update-node>
</xd:xdiff>
Please help me transforming the Update XML to XDiff Namespace.
I face difficulties in getting the XPath with predicates :-(
Also, I have to use xd:node-type as text when the text value of node is getting updated, or its value is element when it has child nodes.
Thanks in advance
R Kaja Mohideen
http://www.vhost4all.com/