Tut JAXB Unterstützung der änderung von bestehenden XML-Dokumenten ohne marshalling/unmarshalling?
Will ich weiterhin Kommentare, Bestellung, etc. in dem Dokument, und Bearbeiten Sie das Dokument in-place über eine Java-Schnittstelle.
Tut JAXB tun?
Andere tools wie XMLBeans das tun?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Können Sie die JAXB
Binder
für diesen Anwendungsfall:input.xml
Demo
Ausgabe
Weitere Informationen
File xmlFile = ... File xmlSchema = ... JAXBContext jaxbContext = JAXBContext.newInstance(Process.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(xmlSchema); Process process = (Process) unmarshaller.unmarshal(xmlFile);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(xmlFile); JAXBContext jaxbContext = JAXBContext.newInstance(Process.class); Binder<Node> binder = jaxbContext.createBinder(); binder.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(xmlSchema); Process process = (Process) binder.unmarshal(document);
javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'process'.]
Aber Sie sehen fast genau das gleiche zu mir. Irgendwelche Ideen, jedermann?