मैं वर्तमान में एक xml स्ट्रिंगXml शीर्ष JAXB marshaller द्वारा उत्पादित
JAXBContext context;
try {
context = JAXBContext.newInstance(heartbeat.getClass());
StringWriter writer = new StringWriter();
Marshaller marshaller = context.createMarshaller();
heartbeat.setHeader(header);
heartbeat.setHeartbeatEvent(event);
marshaller.marshal(heartbeat, writer);
String stringXML = writer.toString();
return stringXML;
} catch (JAXBException e) {
throw new RuntimeException("Problems generating XML in specified "
+ "encoding, underlying problem is " + e.getMessage(),
e);
}
निम्नलिखित में से कौन हैडर
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
मेरे वांछित आउटपुट है पैदा करता है में एक वस्तु मार्शल करने के लिए निम्नलिखित कोड का उपयोग कर रहा फेरबदल निम्नलिखित
<?xml version=\"1.0\"?>
marshaller को यह जोड़ कर
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
marshaller.setProperty("com.sun.xml.bind.xmlHeaders", "<?xml version=\"1.0\"?>");
मैं
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><?xml version="1.0"?>
प्राप्त करते हैं और सही पर JAXB_FRAGMENT संपत्ति को बदलने हैडर पूरी तरह से निकाल देता है। मैं JAXB - Remove 'standalone="yes"' from generated XML धागे को हल करने का प्रयास कर रहा हूं, लेकिन अब तक मुझे कोई भाग्य नहीं मिला है। क्या कोई मुझे जेएक्सबी मार्शलर से अपना वांछित हेडर प्राप्त करने के बारे में कुछ अंतर्दृष्टि दे सकता है?
मैं एक 'PropertyException' जब' sun' संपत्ति की स्थापना । –
मोक्सी पर? आपके द्वारा कौन सा संस्करण उपयोग किया जा रहा है? –
कोई मोक्सी नहीं। मैंने माना कि संपत्ति जावा कार्यान्वयन के साथ प्रयोग किया गया था। –