I have been working on this for at least 4 days now. Time to ask for help
I am working within an opensource application called open adaptor.
I receive an object which holds my xml. I convert this to a string, and then Parse the string using DOMParser, extract the document, and then call Transformer.transform(DOMSource(document),DOMResul t), where i get a DOM006 error.
NOw this works, the sax transformer.
Here is a partial representation of the xml file
<<?xml version="1.0" encoding="ISO-8859-1"?>
<Trades>
<Trade>
<H_AccruedAmount>35350.19</H_AccruedAmount>
<H_RecAmortisingFlag>NOT_AMORTIZED</H_RecAmortisingFlag>
<H_Buy>B</H_Buy>
<H_Company>BOSTS_LDN</H_Company>
<H_Counterparty>MIDL_L</H_Counterparty
.
.
</Trade>
<Trade>
<H_AccruedAmount>12165.1</H_AccruedAmount>
<H_RecAmortisingFlag>NOT_AMORTIZED</H_RecAmortisingFlag>
.
.
</Trade>
</Trades>
and here is the code that attempts to transform it
try
{
DOMResult domresult = new DOMResult();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = factory.newDocumentBuilder();
Document document = docBuilder.newDocument();
DOMParser domParser = new DOMParser();
GenericXMLWriter stringwriter = new GenericXMLWriter();
stringwriter.setAttributeValue("WriteAsXMLFragment s", "true");
stringwriter.setAttributeValue("ElideSingletonRoot ObjectTag", "true");
String s1 = stringwriter.toString(adataobject);
StringReader stringReader = new StringReader(s1);
InputSource inputSource = new InputSource(stringReader);
domParser.parse(inputSource);
transformer.transform(new DOMSource(domParser.getDocument()), domresult);
Document document1 = (Document)domresult.getNode();
DOMDataObject domdataobject1 = new DOMDataObject(document1);
DataObject adataobject1[] = new DataObject[1];
adataobject1[0] = domdataobject1;
return adataobject1;
}
catch(Exception exception)
{
throw new PipelineException(exception.getMessage(), 0);
}