Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.3.0
-
None
Description
If there is a descendant processing instruction within an element and the processing has any "psuedo" attributes then calling OMElement.cloneOMElement after OMElement.toString will cause an UnsupportedOperationException exeption. Example code:
String inputFile = "test-resources\\XMLStaxUtils
ComplexPITest.xml"; OMDocument inputDoc = XMLStaxUtils.readDocument(inputFile);
OMElement rootElement = inputDoc.getOMDocumentElement();
// This is the call that causes PIs to get trashed and will cause an UnsupportedOperationException to be thrown when cloning.
rootElement.toString();
try
catch (UnsupportedOperationException ex)
We got around it by creating a helper method that resets the text:
List<OMNode> piNodes = getNodesWithDescendantPI(srcElement);
for (OMNode piNode : piNodes)
return srcElement.cloneOMElement();