Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 10th, 2008, 01:44 AM
Authorized User
 
Join Date: Nov 2008
Posts: 12
Thanks: 2
Thanked 1 Time in 1 Post
Send a message via Yahoo to mail4kaja
Default Transforming XML From One Namespace to Another

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/
__________________
R Kaja Mohideen
http://www.vhost4all.com/
 
Old November 10th, 2008, 10:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I'm sorry, but this is quite a difficult transformation. There are several of us here who are prepared to give quick answers to specific technical questions, but I don't think there is anyone here who is prepared to offer free XSLT programming services. It would take some careful study before I were even able to suggest a general design approach.

If you have a budget to pay for XSLT consultancy help, it would be a different matter.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Transforming XML to XML using XSL sakreck XSLT 0 January 9th, 2007 11:48 AM
transforming a XML on the basis of another XML Diex75 XSLT 4 November 9th, 2006 09:11 AM
Transforming data in required XML Format pvasudevan XSLT 6 September 6th, 2006 02:34 AM
problem transforming XML using xslt micky3248 XSLT 7 August 18th, 2006 03:52 AM
Please help, xml transforming using xslt !!! daula7 XSLT 0 May 11th, 2006 01:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.