Updating variables in one XML doc from variable values from another XML doc

  • Hi,

    I have read through the XML data type methods nodes(), values(), exist() and modify() to shred, read, check for existence, and manilpulte XML doc stored as XML data type respectively.

    I have not being able to get much information on the extensibility/flexibility of the above methods.

    I need to be able to compare the attribute values in the first XML defined as variable to the attribute values in the second XML and then replace the attribute variable values of the first XML using the values defined for the variables from the second XML.The first XML can have several nodes with child node and its attributes.

    Any feedback or link to documentation on the extensibility of the methods would be helpful.

    Thanks

  • Following I am including my sample XML files that I am trying to do variable replacement on.I am attaching them as this does not allow me to paste the xml files. There are three XML files in the attachments.

    1. First XML ( the XMl that needs to be updated using the variable values defined in the 2nd XML),

    the values inside the {} are variables that needs to be replaced using the values in the 2nd XML

    2. Second XML ( the variable XML which has the values for the variables defined in the first xml)

    3. Final First XML after variable have been replaced with values from 2nd XML

    Both these XML will be defined as XML data types.

    I am trying to use exist() method to check if there are variables in the first XML that are not defined in the 2nd XML. This is an error, vice-versa is Ok.

    I am trying to use modify() method to do the replacement of the variables in the first XML using the values in the 2nd XML thus producing the final XML.I will then be using nodes() and value() method to shred the XML and import them to my table, which I have no problem doing.

    I am however seeing limitation for exist() and modify() methods where they require the values to be explicity defined in the query to do variable validation or modification. Any feedback on the extensibility of these methods on acheiving this would be great.

  • Any feeback on this anybody?

    Thanks

  • I'm not exactly an expert on XQuery, but I might be able to help.

    First, though, does the XML that needs to be updated, need to be updated, or generated?

    It would be relatively easy to build a definition for the second one that would allow you to query it as the first one. Won't be an update, but would get you the desired end result, which could be used for an insert or replacement type operation.

    Would that get you the end result you need?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • i would say that you schred or do a decomposition wich means you put them both in a database or in a database variable. Update whatever you wanna update and publish the result to your xml again.

    Sjaak

    :hehe:

  • GSquared,

    I don't have to update the existing Main XMl, generting a new one as a final XML fine as well.

    I am not understanding the following statement of yours.

    "It would be relatively easy to build a definition for the second one that would allow you to query it as the first one. Won't be an update, but would get you the desired end result, which could be used for an insert or replacement type operation."

    Jacobus,

    Sheredding/decomposing both XML doc, importing them to temp table(s),do column by column

    comparison/replacement, then re-generate the final XML from the replaced values is the option that came to my mind first. However, I started thinking of making the uses of the XML data type methods such as exist() and modify() to be able to do this hence avoiding any table level comparison and/or string relacement. I might end up doing the first way, as it does seem that XML data type methods could get very complicated to accomplish this.I will do some more experimentation today to see if I can get some promishing results.

    Thanks all for your feedback.Appreciate that.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply