Skip to content

Commit e82d321

Browse files
jvpratgebhardt
authored andcommitted
Try different property names to be compatible with more JAXB implementations.
This hack is documented here: http://timepassguys.blogspot.com.es/2011/12/jaxb-exception-javaxxmlbindpropertyexce.html
1 parent b229b83 commit e82d321

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/jaxb/JAXBPlistParser.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import javax.xml.bind.JAXBContext;
3030
import javax.xml.bind.JAXBException;
3131
import javax.xml.bind.Marshaller;
32+
import javax.xml.bind.PropertyException;
3233
import javax.xml.bind.Unmarshaller;
3334
import javax.xml.bind.ValidationEvent;
3435
import javax.xml.bind.ValidationEventHandler;
@@ -45,6 +46,8 @@
4546

4647
public class JAXBPlistParser
4748
{
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+
4851
public Plist load(String projectFile) throws SAXException, ParserConfigurationException, FileNotFoundException,
4952
JAXBException
5053
{
@@ -129,10 +132,14 @@ private void marshallPlist(Plist plist, Writer projectFile) throws JAXBException
129132
JAXBContext ctx = JAXBContext.newInstance(com.sap.prd.mobile.ios.mios.xcodeprojreader.jaxb.JAXBPlist.class);
130133
Marshaller marshaller = ctx.createMarshaller();
131134
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+
}
136143
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
137144
marshaller.marshal(plist, projectFile);
138145
}

0 commit comments

Comments
 (0)