xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juho <j.houll...@gmail.com>
Subject Add namespaces declaration to parent element.
Date Thu, 20 Aug 2009 08:57:05 GMT

Hello,

I want to add namespaces declaration on parent if child and parent have
different namespaces.
My wish is to have output like that:

<balise1 xmlns:tec="http://test1">
  <tec:balise2 />
  <tec:balise3 />
</balise>

instead of what i have actually
<balise1>
  <tec:balise2 xmlns:tec="http://test1"/>
  <tec:balise3 xmlns:tec="http://test1"/>
</balise1>

I tried to obtain that with

parent.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,prefix,desc.getNamespaceURI());

but it generates exception :
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or
change an object in a way which is incorrect with regard to namespaces.
	at org.apache.xerces.dom.AttrNSImpl.setName(Unknown Source)
	at org.apache.xerces.dom.AttrNSImpl.<init>(Unknown Source)
	at org.apache.xerces.dom.PSVIAttrNSImpl.<init>(Unknown Source)
	at org.apache.xerces.dom.PSVIDocumentImpl.createAttributeNS(Unknown Source)
	at org.apache.xerces.dom.ElementImpl.setAttributeNS(Unknown Source)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.createElement(DocumentBuilderFromXSD.java:261)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.setMandatories(DocumentBuilderFromXSD.java:333)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.createElement(DocumentBuilderFromXSD.java:283)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.setMandatories(DocumentBuilderFromXSD.java:333)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.createElement(DocumentBuilderFromXSD.java:283)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.setMandatories(DocumentBuilderFromXSD.java:333)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.createElement(DocumentBuilderFromXSD.java:283)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.createRoot(DocumentBuilderFromXSD.java:130)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.<init>(DocumentBuilderFromXSD.java:81)
	at
org.tdf.tpegPlugin.parser.DocumentBuilderFromXSD.<init>(DocumentBuilderFromXSD.java:67)
	at org.tdf.tpegPlugin.Main.main(Main.java:52)
-- 
View this message in context: http://www.nabble.com/Add-namespaces-declaration-to-parent-element.-tp25058380p25058380.html
Sent from the Xerces - J - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Mime
View raw message