Update help

I have an xml file like the following.I have to get the “text” of B element




text




so i query for /root/A/B to retrieve what i need.(response.getFirstXMLObject()) I do some operation on this node
(i.e. update) and at the end i have to commit these changes to the database.
But we all known that partial updates are not allowed in the current version of Tamino and
for this reason i would like to get the root element and then update can be possible.
I’m using JDOM and with a method recursive like this

public Element getRootElement(Element element){

if(element.isRootElement())
return element;
else{
Element newelement = element.getParent();
return (getRootElement(newelement));
}

}

i get the root element, but the root element obtined is…

<ino:response xmlns:ino=“http://namespaces.softwareag.com/tamino/response2” xmln
s:xql=“XQL FAQ (XML Query Language - Frequently Asked Questions)”>
xql:query/root/A/B</xql:query>
<ino:message ino:returnvalue=“0”>
ino:messagelineXQL Request processing</ino:messageline>
</ino:message>
xql:result
text

</xql:result>
<ino:message ino:returnvalue=“0”>
ino:messagelineXQL Request processed</ino:messageline>
</ino:message>
</ino:response>

how can i reach my real root element in a way that the accessor.update will be possible?
The solution i have implemented for the moment is querying /root and then i discend and navigate
the tree to the element B, but i’m looking for a smart and more elegant solution because in this
case if i change the name of one element or i change the schema i need to change also my java code
instead with the other solution only a changed query is required…
Hope someone help me.

BRGS
@nto

Hi,

I think you have three options. You can wait for Tamino 4 which has native support for update of XML subtrees. You could instead use the add-on NodeLevelUpdate supplied with Tamino currently (if you are using Microsoft IIS). Finally you could continue to use your method of querying /root and then navigating to the element but you could set the value of in a properties file for your application. Then if your schema changes you just change your properties file to reflect that change.

HTH

When will be relased T4?For NodeLevelUpdate i’m afraid but i’m using Apache …but i’m interested in your third solution…what do you mean with " you could set the value of in a properties file for your application."
How can realize it?

Thanks
@nto

Look at class “java.util.Properties” in your Java Documentation for a full description of Properties and their use.

For example, create a Properties file (just a text file called “myApp.properties” in this example) containing “parameter=value”.

Then in your code you can:

Define a Properties object:
Properties myProps = new Properties();

Load the Properties values from your file:
FileInputStream in = new FileInputStream(“myApp.properties”);
myProps.load(in);

Put the parameter value into a String:
String myParm = myProps.getProperty(“parameter”,“default value”);

At this point, myParm has the value “value”, and now you can process code depending on the value you found…

Tamino V4 is due quite soon!
HTH