|
29 | 29 | import javax.xml.bind.JAXBContext; |
30 | 30 | import javax.xml.bind.JAXBException; |
31 | 31 | import javax.xml.bind.Marshaller; |
| 32 | +import javax.xml.bind.PropertyException; |
32 | 33 | import javax.xml.bind.Unmarshaller; |
33 | 34 | import javax.xml.bind.ValidationEvent; |
34 | 35 | import javax.xml.bind.ValidationEventHandler; |
|
45 | 46 |
|
46 | 47 | public class JAXBPlistParser |
47 | 48 | { |
| 49 | + private static final String xmlHeaders = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"; |
| 50 | + |
48 | 51 | public Plist load(String projectFile) throws SAXException, ParserConfigurationException, FileNotFoundException, |
49 | 52 | JAXBException |
50 | 53 | { |
@@ -129,10 +132,14 @@ private void marshallPlist(Plist plist, Writer projectFile) throws JAXBException |
129 | 132 | JAXBContext ctx = JAXBContext.newInstance(com.sap.prd.mobile.ios.mios.xcodeprojreader.jaxb.JAXBPlist.class); |
130 | 133 | Marshaller marshaller = ctx.createMarshaller(); |
131 | 134 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
132 | | - marshaller |
133 | | - .setProperty( |
134 | | - "com.sun.xml.internal.bind.xmlHeaders", |
135 | | - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"); |
| 135 | + try |
| 136 | + { |
| 137 | + marshaller.setProperty("com.sun.xml.internal.bind.xmlHeaders", xmlHeaders); |
| 138 | + } |
| 139 | + catch(PropertyException ex) |
| 140 | + { |
| 141 | + marshaller.setProperty("com.sun.xml.bind.xmlHeaders", xmlHeaders); |
| 142 | + } |
136 | 143 | marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); |
137 | 144 | marshaller.marshal(plist, projectFile); |
138 | 145 | } |
|
0 commit comments