From: Anil on 10 Mar 2010 14:28 Hi, I have a java class, which generates the XML file. I am using the same class in both Matlab session and in Eclipse. Following is the code I am using to genate the XML file public static void saveDocument(Document doc, File file) throws Exception { DOMSource source = new DOMSource(doc); OutputStream stream = new FileOutputStream(file); StreamResult result = new StreamResult(stream); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.transform(source, result); stream.flush(); stream.close(); } My problem is, when I use the class I wrote to generate the XML file in eclipse using the above code, the resulting XML file has attributes on separate lines, but when I use the same class in Matlab to generate the XML file, the attributes appear on one line. e.g from Eclipse, XML file looks like <?xml version="1.0" encoding="UTF-8"?> <ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="myID" model_file_name="myModel.mdl" model_type="Simulink"> <ELEMENT_1/> <ELEMENT_2> <VAL attrib1="value" attrib2="value" attrib3="value" attrib4="value" attrib5="value" attrib6="value" /> </ROOT> </ELEMENT_2> & from Matlab, XML file looks like <?xml version="1.0" encoding="UTF-8"?> <ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="myID" model_file_name="myModel.mdl" model_type="Simulink"> <ELEMENT_1/> <ELEMENT_2> <VAL attrib1="value" attrib2="value" attrib3="value" attrib4="value" attrib5="value" attrib6="value" /> </ROOT> </ELEMENT_2> Does anyone know why the generated XML files put attribute differently for Matlab & Eclipse. Although, XML Parser won't complain & parse both files successfuly. But i wanted to now why this behaviour exists. I tried Matlab 2007b & 2009a, got same results. I am using eclipse 3.3.2.
|
Pages: 1 Prev: Resample Data to Match X-values Next: Resample Data to Match X-values |