मैं उत्पादन धारा के लिए जेएक्सबी बीन्स marshalling (serializing) हूँ। मैं ouput के लिए DOCTYPE घोषणा और एक्सएमएल प्रसंस्करण निर्देश कैसे जोड़ सकता हूं?JAXB के साथ marshalling जब DOCTYPE और xml प्रसंस्करण निर्देश कैसे जोड़ें?
मैं वर्तमान में इस तरह वास्ते कर रहा हूँ:
JAXBContext jaxbContext = JAXBContext.newInstance("com.example.package");
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = schemaFactory.newSchema(schemaSource);
marshaller.setSchema(schema);
marshaller.marshal(object, output);
मैं चाहूँगा उत्पादन है कि कुछ इस तरह दिखता है:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Something SYSTEM "some.dtd">
<?xml-stylesheet type="text/xsl" href="some.xsl"?>
JAXB सेम कोड उत्पन्न कर रहे हैं तो मैं नहीं करना चाहते उन्हें बदलो।
xml processing instructions और doctype जोड़ने के लिए कुछ हैक्स और अनियंत्रित चालें (Making JAXB generate an XML processing instruction देखें) हैं। लेकिन ऐसा करने का पसंदीदा या सही तरीका क्या है?
क्या आपका मतलब सही तरीका था? यदि आप जेएक्सबी आरआई का उपयोग कर रहे हैं तो com.sun.xml.internal.bind.xml हेडर काम करेंगे, अगर जैक्सबी इंप्यू का उपयोग किया जाता है तो यह com.sun.xml.bind.xml हैडर सही है? – kalyan