// if I need to insert a new element
apply.insertNewExpression(0);
newName = new QName(apply.getDomNode().getNamespaceURI(), "Apply");
applyDoc = ApplyDocument.Factory.newInstance();
newApply = applyDoc.addNewApply();
newApply.setFunctionId("this element should be first!!!");
apply.getExpressionArray(0).newCursor().setName(newName);
apply.setExpressionArray(0, newApply);
System.out.println(apply);
This shows that insert added an element to the end of the array.
(So, still a bug)
Vlad Mangeym <[EMAIL PROTECTED]> wrote:
Lawrence,
Thank you for the very detailed explanation/analysis.
I think I have figured out how to do it with setName() and not to have xsi:type:
// if I need to add a new element
apply.addNewExpression();
newName = new QName(apply.getDomNode().getNamespaceURI(), "Apply");
ApplyDocument applyDoc = ApplyDocument.Factory.newInstance();
ApplyType newApply = applyDoc.addNewApply();
newApply.setFunctionId("someFunction");
apply.getExpressionArray(2).newCursor().setName(newName);
apply.setExpressionArray(2, newApply);
System.out.println(apply);
Basically, I just switched two lines:
apply.getExpressionArray(2).newCursor().setName(newName);
apply.setExpressionArray(2, newApply);
I understand the benefits of using substitute instead, but unfortunately, the way I have it designed is that I only get one array element at a time with it's index, so replacing the whole array is not an option.
Also, I have found another bug:
// if I need to insert a new element
apply.insertNewExpression(0);
newName = new QName(apply.getDomNode().getNamespaceURI(), "Apply");
applyDoc = ApplyDocument.Factory.newInstance();
newApply = applyDoc.addNewApply();
newApply.setFunctionId("this element should be first!!!");
apply.getExpressionArray(2).newCursor().setName(newName);
apply.setExpressionArray(2, newApply);
System.out.println(apply);
apply.insertNewExpression(0); call is always inserting new element at the end, it seems to ignore the index completely.
Also, I am a bit confused about applyChild.getDomNode().getNamespaceURI() returning null - I have checked it aga in and it seems to be always returning the correct value for me.
Can it be a difference in versions? (I am using version 2.1.0-r330131)
Thanks,
Vlad
Yahoo! Mail - Helps protect you from nasty viruses.

