|
View:
New views
15 Messages
—
Rating Filter:
Alert me
|
|
|
Duplicated namespace declaration from output xmlHi,
I have this problem when I use jaxb to create output xml. My output xml looks like this: <data> <instanceData> <individual> <homeAddress> <LocalAddress xsi:type="ns3:CompoundLocalAddress" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common"> <positionNr xsi:type="xs:int" xmlns:xs="http://www.w3.org/2001/XMLSchema">1</positionNr> <fullAddress xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">7783 SOUTH 73 RD STREET</fullAddress> </LocalAddress> <LocalAddress xsi:type="ns3:CompoundLocalAddress" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common"> <positionNr xsi:type="xs:int" xmlns:xs="http://www.w3.org/2001/XMLSchema">2</positionNr> <fullAddress xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"></fullAddress> </LocalAddress> </homeAddress> </individual> </instanceData> </data> There are duplicate namespace declaration on the output. How can I set it to be delcared only one time? Thanks, |
|
|
Re: Duplicated namespace declaration from output xmlHere is a partial information of my xsd for the address type:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SIDBusCm="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common" xmlns:SIDBusCu="http://www.tmforum.org/NGOSS/SID/Business/7.0/Customer"> <xs:import namespace="http://www.tmforum.org/NGOSS/SID/Business/7.0/Customer" schemaLocation="SIDBusinessViewCustomer.xsd"/> <xs:import namespace="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common" schemaLocation="SIDBusinessViewCommon.xsd"/> <xs:complexType name="InitiateAddress"> <xs:complexContent> <xs:extension base="SIDBusCm:GeographicAddress"> <xs:sequence> <xs:element name="locality" type="xs:anySimpleType" minOccurs="0"/> <xs:element name="postcode" type="xs:anySimpleType" minOccurs="0"/> <xs:element name="geoText1" type="xs:anySimpleType" minOccurs="0"/> <xs:element name="GeoCode1" type="xs:anySimpleType" minOccurs="0"/> <xs:element name="GeoCode2" type="xs:anySimpleType" minOccurs="0"/> <xs:element name="addressLine" type="SIDBusCm:CompoundLocalAddress" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> </xs:schema> Thanks,
|
|
|
Re: Duplicated namespace declaration from output xmlThat's not quite the schema definitions Ipertaining to the XML
snippet. We'd need to see the schema type definition for element <homeAddress>, containing a (repeating) element with name="LocalAddress". And I'd like to see the definition of that element's type CompoundLocalAddress from SIDBusinessViewCommon.xsd. But here's a couple of pointers. Similar explicit inclusion of a schema type in an instance document's element occurs if you instantiate a JAXB element using an object of some (abstract) XML schema base type so that the element would have the element tag of the base type. Second, avoid xs:anySimpleType since this will also create multiple references to the namespaces bound to xsi and xs, and type attributes containing the actual type. And you lose JAXB's advantage of having typed fields in your Java classes so that you lose all the checks the Java compiler might do, and for unmarshalling you'll have to handle all the conversions yourself. On Mon, Oct 20, 2008 at 8:13 PM, Son Nguyen <sontrang91@...> wrote: > > Here is a partial information of my xsd for the address type: > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:SIDBusCm="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common" > xmlns:SIDBusCu="http://www.tmforum.org/NGOSS/SID/Business/7.0/Customer"> > <xs:import > namespace="http://www.tmforum.org/NGOSS/SID/Business/7.0/Customer" > schemaLocation="SIDBusinessViewCustomer.xsd"/> > <xs:import > namespace="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common" > schemaLocation="SIDBusinessViewCommon.xsd"/> > > > <xs:complexType name="InitiateAddress"> > <xs:complexContent> > <xs:extension base="SIDBusCm:GeographicAddress"> > <xs:sequence> > <xs:element name="locality" type="xs:anySimpleType" > minOccurs="0"/> > <xs:element name="postcode" type="xs:anySimpleType" > minOccurs="0"/> > <xs:element name="geoText1" type="xs:anySimpleType" > minOccurs="0"/> > <xs:element name="GeoCode1" type="xs:anySimpleType" > minOccurs="0"/> > <xs:element name="GeoCode2" type="xs:anySimpleType" > minOccurs="0"/> > <xs:element name="addressLine" > type="SIDBusCm:CompoundLocalAddress" minOccurs="0" maxOccurs="unbounded"/> > </xs:sequence> > </xs:extension> > </xs:complexContent> > </xs:complexType> > > </xs:schema> > > Thanks, > > > > Son Nguyen wrote: >> >> Hi, >> I have this problem when I use jaxb to create output xml. My output xml >> looks like this: >> >> <data> >> <instanceData> >> <individual> >> <homeAddress> >> <LocalAddress xsi:type="ns3:CompoundLocalAddress" >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> xmlns:ns3="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common"> >> <positionNr xsi:type="xs:int" >> xmlns:xs="http://www.w3.org/2001/XMLSchema">1</positionNr> >> <fullAddress xsi:type="xs:string" >> xmlns:xs="http://www.w3.org/2001/XMLSchema">7783 SOUTH 73 RD >> STREET</fullAddress> >> </LocalAddress> >> <LocalAddress xsi:type="ns3:CompoundLocalAddress" >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> xmlns:ns3="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common"> >> <positionNr xsi:type="xs:int" >> xmlns:xs="http://www.w3.org/2001/XMLSchema">2</positionNr> >> <fullAddress xsi:type="xs:string" >> xmlns:xs="http://www.w3.org/2001/XMLSchema"></fullAddress> >> </LocalAddress> >> </homeAddress> >> </individual> >> </instanceData> >> </data> >> >> There are duplicate namespace declaration on the output. How can I set it >> to be delcared only one time? >> >> Thanks, >> > > -- > View this message in context: http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml-tp20069914p20075599.html > Sent from the java.net - jaxb users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Duplicated namespace declaration from output xmlI was able to create a similar situation using a smaller schema so that it is to reproduce.
Here is the schema: Book.xsd <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Collection"> <xs:complexType> <xs:sequence> <xs:element name ="books"> <xs:complexType> <xs:sequence> <xs:element name="book" type="bookType" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="bookType"> <xs:sequence> <xs:element name="name" type="xs:anySimpleType" minOccurs="0"/> <xs:element name="ISBN" type="xs:anySimpleType" minOccurs="0"/> <xs:element name="price" type="xs:anySimpleType" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:schema> The output: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Collection> <books> <book> <name xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">ABC</name> </book> </books> </Collection> I think the problem comes from the xs:anySimpleType. If I change it to string, it will works as normal. It also make sense that jaxb create output with types for anySimpleType element. However, it will be a lot nicer if jaxb can group all the xml declaration on the top and just use the nametag for it. Do you know a way to tell jaxb to do that? Attachment is the complete project for you to run. Thanks, |
|
|
Re: Duplicated namespace declaration from output xmlI'm aware that I'm suggesting a terrible hack, wrought with ifs and buts, so don't tell me.
To effect certain local modifications on the marshalled text you could do the following: Call marshal with a PipedOutputStream pos as its second parameter. Connect a PipedInputStream pis to that and start a thread reading from pis, accumulating characters into a StringBuffer. At certain positions (e.g.at line ends, after requesting JAXB_FORMATTED_OUTPUT) delete strings such as xmlns:xs="..." from the StringBuffer and emit the StringBuffer to the ultimate destination for your marhalled text. Insert is, of course, possible as well, assuming you can identify the position. On Tue, Oct 21, 2008 at 6:25 PM, Son Nguyen <sontrang91@...> wrote:
|
|
|
Re: Duplicated namespace declaration from output xmlHi all,
Sorry for the late response, I just saw this. For a slightly less foul solution, consider marshalling through a TransformerHandler, and using SAX to filter the namespace events you don't want. It's still pretty ugly, but it works for us. Cheers, Colin 2008/10/22 Wolfgang Laun <wolfgang.laun@...> I'm aware that I'm suggesting a terrible hack, wrought with ifs and buts, so don't tell me. |
|
|
AW: Duplicated namespace declaration from output xmlHi all -
From the responses in this thread I understand that having control over the namespace declarations produced by the Marshaller is an issue for many people which is not addressed by the JAXB API so far. Currently I have also implemented a SAX filter for this purpose. However, I would really prefer a simple way to customize the marshalling process. Is there any chance that this will be a feature of upcoming JAXB versions? Cheers, Claus ________________________________________ Von: Colin Fleming [mailto:colin.mailinglist@...] Gesendet: Dienstag, 18. November 2008 13:01 An: users@... Cc: claus.nagel@... Betreff: Re: Duplicated namespace declaration from output xml Hi all, Sorry for the late response, I just saw this. For a slightly less foul solution, consider marshalling through a TransformerHandler, and using SAX to filter the namespace events you don't want. It's still pretty ugly, but it works for us. Cheers, Colin 2008/10/22 Wolfgang Laun <wolfgang.laun@...> I'm aware that I'm suggesting a terrible hack, wrought with ifs and buts, so don't tell me. To effect certain local modifications on the marshalled text you could do the following: Call marshal with a PipedOutputStream pos as its second parameter. Connect a PipedInputStream pis to that and start a thread reading from pis, accumulating characters into a StringBuffer. At certain positions (e.g.at line ends, after requesting JAXB_FORMATTED_OUTPUT) delete strings such as xmlns:xs="..." from the StringBuffer and emit the StringBuffer to the ultimate destination for your marhalled text. Insert is, of course, possible as well, assuming you can identify the position. On Tue, Oct 21, 2008 at 6:25 PM, Son Nguyen <sontrang91@...> wrote: I think the problem comes from the xs:anySimpleType. If I change it to string, it will works as normal. It also make sense that jaxb create output with types for anySimpleType element. However, it will be a lot nicer if jaxb can group all the xml declaration on the top and just use the nametag for it. Do you know a way to tell jaxb to do that? Attachment is the complete project for you to run. Thanks, -- View this message in context: http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml-tp200 69914p20094153.html Sent from the java.net - jaxb users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: Duplicated namespace declaration from output xmlHi,
I think providing a prefix mapper: http://java.sun.com/webservices/docs/2.0/jaxb/vendorProperties.html#prefixmapper shall solve most of your issues. MartinG Claus Nagel wrote: > Hi all - > > From the responses in this thread I understand that having control over the > namespace declarations produced by the Marshaller is an issue for many > people which is not addressed by the JAXB API so far. > > Currently I have also implemented a SAX filter for this purpose. However, I > would really prefer a simple way to customize the marshalling process. Is > there any chance that this will be a feature of upcoming JAXB versions? > > Cheers, > Claus > > ________________________________________ > Von: Colin Fleming [mailto:colin.mailinglist@...] > Gesendet: Dienstag, 18. November 2008 13:01 > An: users@... > Cc: claus.nagel@... > Betreff: Re: Duplicated namespace declaration from output xml > > Hi all, > > Sorry for the late response, I just saw this. > > For a slightly less foul solution, consider marshalling through a > TransformerHandler, and using SAX to filter the namespace events you don't > want. It's still pretty ugly, but it works for us. > > Cheers, > Colin > 2008/10/22 Wolfgang Laun <wolfgang.laun@...> > I'm aware that I'm suggesting a terrible hack, wrought with ifs and buts, so > don't tell me. > > To effect certain local modifications on the marshalled text you could do > the following: > > Call marshal with a PipedOutputStream pos as its second parameter. Connect a > PipedInputStream pis to that and start a thread reading from pis, > accumulating characters into a StringBuffer. At certain positions (e.g.at > line ends, after requesting JAXB_FORMATTED_OUTPUT) delete strings such as > xmlns:xs="..." from the StringBuffer and emit the StringBuffer to the > ultimate destination for your marhalled text. Insert is, of course, possible > as well, assuming you can identify the position. > > > On Tue, Oct 21, 2008 at 6:25 PM, Son Nguyen <sontrang91@...> wrote: > > > I think the problem comes from the xs:anySimpleType. If I change it to > string, it will works as normal. It also make sense that jaxb create output > with types for anySimpleType element. However, it will be a lot nicer if > jaxb can group all the xml declaration on the top and just use the nametag > for it. Do you know a way to tell jaxb to do that? > > Attachment is the complete project for you to run. > > Thanks, > > > -- > View this message in context: > http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml-tp200 > 69914p20094153.html > Sent from the java.net - jaxb users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > -- Martin Grebac, http://blogs.sun.com/mgrebac Web Technologies & Standards Sun Microsystems Czech ICQ: 93478885 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
AW: AW: Duplicated namespace declaration from output xmlHi,
As the tutorial says, a namespace prefix mapper answers the question: "What prefix do you want for this namespace URI?". However, I want the question "Do you want this namespace URI to be automatically declared on the root element?" to be raised. And I want to tell the Marshaller "No, skip this namespace declaration!". Nevertheless, I think the NamespacePrefixMapper class could be enhanced with that functionality?! Cheers, Claus > -----Ursprüngliche Nachricht----- > Von: Martin.Grebac@... [mailto:Martin.Grebac@...] > Gesendet: Dienstag, 18. November 2008 16:36 > An: users@... > Betreff: Re: AW: Duplicated namespace declaration from output xml > > Hi, > I think providing a prefix mapper: > http://java.sun.com/webservices/docs/2.0/jaxb/vendorProperties.html#prefix > mapper > shall solve most of your issues. > MartinG > > > Claus Nagel wrote: > > Hi all - > > > > From the responses in this thread I understand that having control over > the > > namespace declarations produced by the Marshaller is an issue for many > > people which is not addressed by the JAXB API so far. > > > > Currently I have also implemented a SAX filter for this purpose. > However, I > > would really prefer a simple way to customize the marshalling process. > Is > > there any chance that this will be a feature of upcoming JAXB versions? > > > > Cheers, > > Claus > > > > ________________________________________ > > Von: Colin Fleming [mailto:colin.mailinglist@...] > > Gesendet: Dienstag, 18. November 2008 13:01 > > An: users@... > > Cc: claus.nagel@... > > Betreff: Re: Duplicated namespace declaration from output xml > > > > Hi all, > > > > Sorry for the late response, I just saw this. > > > > For a slightly less foul solution, consider marshalling through a > > TransformerHandler, and using SAX to filter the namespace events you > don't > > want. It's still pretty ugly, but it works for us. > > > > Cheers, > > Colin > > 2008/10/22 Wolfgang Laun <wolfgang.laun@...> > > I'm aware that I'm suggesting a terrible hack, wrought with ifs and > buts, so > > don't tell me. > > > > To effect certain local modifications on the marshalled text you could > do > > the following: > > > > Call marshal with a PipedOutputStream pos as its second parameter. > Connect a > > PipedInputStream pis to that and start a thread reading from pis, > > accumulating characters into a StringBuffer. At certain positions > (e.g.at > > line ends, after requesting JAXB_FORMATTED_OUTPUT) delete strings such > as > > xmlns:xs="..." from the StringBuffer and emit the StringBuffer to the > > ultimate destination for your marhalled text. Insert is, of course, > possible > > as well, assuming you can identify the position. > > > > > > On Tue, Oct 21, 2008 at 6:25 PM, Son Nguyen <sontrang91@...> > wrote: > > > > > > I think the problem comes from the xs:anySimpleType. If I change it to > > string, it will works as normal. It also make sense that jaxb create > output > > with types for anySimpleType element. However, it will be a lot nicer if > > jaxb can group all the xml declaration on the top and just use the > nametag > > for it. Do you know a way to tell jaxb to do that? > > > > Attachment is the complete project for you to run. > > > > Thanks, > > > > > > -- > > View this message in context: > > http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml- > tp200 > > 69914p20094153.html > > Sent from the java.net - jaxb users mailing list archive at Nabble.com. > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > > -- > Martin Grebac, http://blogs.sun.com/mgrebac > > Web Technologies & Standards > Sun Microsystems Czech > > ICQ: 93478885 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: AW: Duplicated namespace declaration from output xmlHi,
please give it a try first. Once you provide the namespace mapping, all the namespaces shall be declared at the top, and you shall not see the declaration inside the xml. If it doesn't solve your problem, please file an issue with testcase - that's the best way to make sure the problem has exact description. Thanks in advance, MartinG --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: AW: Duplicated namespace declaration from output xmlHi all,
The problem that we had with the prefix mapper was that it doesn't allow you to remove the namespaces that JAXB declares automatically (i.e. the ones statically known by the JAXBContext). For performance (and convenience) reasons we create a single JAXBContext that's aware of many different document types, and JAXB ends up adding about 60 namespace declarations to each document. The prefix mapper doesn't help with that. Cheers, Colin |
|
|
AW: AW: AW: Duplicated namespace declaration from output xmlThat's also the issue I am facing. Thanks Colin for this brief and precise
summary. I just want to add that in my project it is not just for convenience or performance reasons. I have a schema A which imports schema B and extends type definitions from B. Even if I set up the JAXBContext just with schema A (by passing only its package name to the newInstance method), also the namespace of B is automatically declared on every instance document that I unmarshal. However, if there is no content of B in my document I would like the namespace declaration to be skipped. Regards, Claus ________________________________________ Von: Colin Fleming [mailto:colin.mailinglist@...] Gesendet: Mittwoch, 19. November 2008 09:28 An: users@... Betreff: Re: AW: AW: Duplicated namespace declaration from output xml Hi all, The problem that we had with the prefix mapper was that it doesn't allow you to remove the namespaces that JAXB declares automatically (i.e. the ones statically known by the JAXBContext). For performance (and convenience) reasons we create a single JAXBContext that's aware of many different document types, and JAXB ends up adding about 60 namespace declarations to each document. The prefix mapper doesn't help with that. Cheers, Colin --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: AW: Duplicated namespace declaration from output xmlIn case anyone is interested, I've posted the code we're using below in case it's useful:
public class JAXBUtil { private JAXBUtil() { } public static void filterNamespaces(ByteArrayInputStream inputStream, OutputStream outputStream) throws SAXException, IOException, TransformerConfigurationException { // Parsing, removing the uris that haven't been declared SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance(); TransformerHandler transformerHandler = factory.newTransformerHandler(); transformerHandler.setResult(new StreamResult(outputStream)); transformerHandler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes"); transformerHandler.getTransformer().setOutputProperty(OutputKeys.ENCODING, "utf-8"); XMLReader xmlReader = XMLReaderFactory.createXMLReader(); FilterNamespaces filterNamespaces = new FilterNamespaces(transformerHandler); xmlReader.setContentHandler(filterNamespaces); xmlReader.parse(new InputSource(inputStream)); } private static class FilterNamespaces extends DefaultHandler { private static final String SCHEMA_INSTANCE_URI = "http://www.w3.org/2001/XMLSchema-instance"; private final ContentHandler nextHandler; private final Map<String, String> uriByPrefix = new HashMap<String, String>(); private final Map<String, String> prefixByUri = new HashMap<String, String>(); private final Set<String> registeredUris = new HashSet<String>(); private int depth = 0; private final List<Set<String>> registeredByDepth = new ArrayList<Set<String>>(); private FilterNamespaces(ContentHandler nextHandler) { this.nextHandler = nextHandler; } @Override public void setDocumentLocator(Locator locator) { nextHandler.setDocumentLocator(locator); } @Override public void startDocument() throws SAXException { nextHandler.startDocument(); } @Override public void endDocument() throws SAXException { nextHandler.endDocument(); } @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { uriByPrefix.put(prefix, uri); prefixByUri.put(uri, prefix); } @Override public void endPrefixMapping(String prefix) throws SAXException { String uri = uriByPrefix.get(prefix); uriByPrefix.remove(prefix); prefixByUri.remove(uri); } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { registeredByDepth.add(new HashSet<String>()); registerNamespace(uri); for (int i = 0 ; i < attributes.getLength(); i++) { String attributeUri = attributes.getURI(i); registerNamespace(attributeUri); if (SCHEMA_INSTANCE_URI.equals(attributeUri) && "type".equals(attributes.getLocalName(i))) { String value = attributes.getValue(i); int index = value.indexOf(':'); if (index != -1) { String prefix = value.substring(0, index); registerNamespace(uriByPrefix.get(prefix)); } } } nextHandler.startElement(uri, localName, qName, attributes); depth++; } @Override public void endElement(String uri, String localName, String qName) throws SAXException { nextHandler.endElement(uri, localName, qName); depth--; Set<String> registered = registeredByDepth.remove(depth); for (String namespace : registered) { nextHandler.endPrefixMapping(prefixByUri.get(namespace)); registeredUris.remove(namespace); } } @Override public void characters(char ch[], int start, int length) throws SAXException { nextHandler.characters(ch, start, length); } @Override public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { nextHandler.ignorableWhitespace(ch, start, length); } @Override public void processingInstruction(String target, String data) throws SAXException { nextHandler.processingInstruction(target, data); } @Override public void skippedEntity(String name) throws SAXException { nextHandler.skippedEntity(name); } private void registerNamespace(String uri) throws SAXException { if ((uri.length() > 0) && !registeredUris.contains(uri)) { String prefix = prefixByUri.get(uri); nextHandler.startPrefixMapping(prefix, uri); registeredUris.add(uri); registeredByDepth.get(depth).add(uri); } } } } |
|
|
Re: AW: AW: Duplicated namespace declaration from output xmlWould you please file an issue against JAXB and attach the schema you're
using best with a simple testcase? Thanks, MartinG Colin Fleming wrote: > Hi all, > > The problem that we had with the prefix mapper was that it doesn't > allow you to remove the namespaces that JAXB declares automatically > (i.e. the ones statically known by the JAXBContext). For performance > (and convenience) reasons we create a single JAXBContext that's aware > of many different document types, and JAXB ends up adding about 60 > namespace declarations to each document. The prefix mapper doesn't > help with that. > > Cheers, > Colin > -- Martin Grebac, http://blogs.sun.com/mgrebac Web Technologies & Standards Sun Microsystems Czech ICQ: 93478885 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: AW: Duplicated namespace declaration from output xmlSorry, this should have gone to a different thread ;O)
As fot this thread, people already found different techniques to avoid the namespace declarations, but I understand it's cumbersome. I'll try to find out how we could improve NamespacePrefixMapper to allow rejection of namespace declaration as well. MartinG Martin Grebac wrote: > Would you please file an issue against JAXB and attach the schema > you're using best with a simple testcase? > Thanks, > MartinG > > Colin Fleming wrote: >> Hi all, >> >> The problem that we had with the prefix mapper was that it doesn't >> allow you to remove the namespaces that JAXB declares automatically >> (i.e. the ones statically known by the JAXBContext). For performance >> (and convenience) reasons we create a single JAXBContext that's aware >> of many different document types, and JAXB ends up adding about 60 >> namespace declarations to each document. The prefix mapper doesn't >> help with that. >> >> Cheers, >> Colin >> > -- Martin Grebac, http://blogs.sun.com/mgrebac Web Technologies & Standards Sun Microsystems Czech ICQ: 93478885 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |