Hi all, I've just started to use XMLBeans and I had some troubles to use XmlCursor to navigate through a document, update it and get back the updated version.
This is my xml document: <?xml version="1.0" encoding="UTF-8"?> <eda:quoteEvent xmlns:eda="http://www.bsource.ch/EDA"> <eda:security>CS GROUP N</eda:security> <eda:date>09-03-2007</eda:date> <eda:time/> <eda:national-nr>1213853</eda:national-nr> <eda:change>-0.2</eda:change> <eda:volume>5821192</eda:volume> <eda:currency transcoder="CURRENCY">CHF</eda:currency> <eda:prev-close>87.9</eda:prev-close> <eda:open>87.75</eda:open> <eda:last>87.7</eda:last> </eda:quoteEvent> I would like to retrieve all nodes with transcoder attribute (I've used the //@transcoder/.. expression), call another component (for transcodification) and get back the below new one: <?xml version="1.0" encoding="UTF-8"?> <eda:quoteEvent xmlns:eda="http://www.bsource.ch/EDA"> <eda:security>CS GROUP N</eda:security> <eda:date>09-03-2007</eda:date> <eda:time/> <eda:national-nr>1213853</eda:national-nr> <eda:change>-0.2</eda:change> <eda:volume>5821192</eda:volume> <eda:currency transcoder="CURRENCY">001</eda:currency> <eda:prev-close>87.9</eda:prev-close> <eda:open>87.75</eda:open> <eda:last>87.7</eda:last> </eda:quoteEvent> The code is: XmlObject xobj = XmlObject.Factory.parse(new ByteArrayInputStream(bodyEvent.getBytes())); XmlObject response = EDATool.transcodification (xobj, "SMI-EDA"); where public static XmlObject transcodification (XmlObject bodyEvent, String encoder) throws Exception { if ((bodyEvent == null) || (encoder == null)) throw new Exception("unexpected null object"); long start = System.currentTimeMillis(); XmlObject[] elems = bodyEvent.execQuery("//@transcoder/.."); System.out.println ("execQuery elapsed time msec: " + (System.currentTimeMillis() - start)); for (int i = 0; i < elems.length; i++) { XmlCursor cursor = elems[i].newCursor(); TokenType token = null; String value = cursor.getTextValue(); String table = null; while (cursor.hasNextToken()) { token = cursor.toNextToken(); if (token.isAttr() && "transcoder".equals(cursor.getName().toString())) { table = cursor.getTextValue(); break; } } if (table != null) { cursor.pop(); value = transcode(table, encoder, value); cursor.setTextValue(value); } cursor.dispose(); } return bodyEvent; } My doubts: 1) I noticed that the time for executing execQuery is not neglectable (msec: 3688 for a document of only 471 bytes). What is wrong in my code ? 2) after disposing the cursor the document is not updated, how could I write back my changes to the document ? Regards Patrizio IMPORTANT: This e-mail transmission is intended for the named addressee(s)only. Its contents are private, confidential and protected from disclosure and should not be read, copied or disclosed by any other person. If you are not the intended recipient, we kindly ask you to notify the sender immediately by telephone (+41 (0)58 806 50 00), to redirect the message to the account "[EMAIL PROTECTED]" and to delete this e-mail. E-mail transmissions may be intercepted, altered or read by unauthorized persons and may contain viruses. Therefore, it is recommended that you use regular mail or courier services for any information intended to be confidential. However, by sending us messages through e-mail, you authorize and instruct us to correspond by e-mail in the relevant matter. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

