Java produce xml version 1.1

.ryan

New Member
I have a xml file which has the following header: \[code\]<?xml version="1.1" encoding="UTF-8"?>\[/code\]. It is also mandatory, that this file is version 1.1 since there are some characters included, which are not allowed in version 1.1.My task is to extract some entities from the file and save it again as xml file. If I produce a new xml file, it will be in version 1.0. Since there are some encoding errors in the new file, I assume the problem is the wrong xml version. Is there a possibility to produce a xml file in version 1.1 (including the correct header)?Here is a snippet of my current code:\[code\]//read the fileSAXParserFactory factory = SAXParserFactory.newInstance();SAXParser saxParser = factory.newSAXParser();DefaultHandler handler = new DefaultHandler() {...}//write the output fileSAXTransformerFactory fac = (SAXTransformerFactory)TransformerFactory.newInstance();final TransformerHandler tfh = fac.newTransformerHandler();Transformer transformer = tfh.getTransformer();transformer.setOutputProperty(OutputKeys.METHOD, "xml");transformer.setOutputProperty(OutputKeys.INDENT, "yes");\[/code\]I hope somebody can help me.Best,Michael
 
Back
Top