You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Soosai, Lourdhu Vasanth" <Lo...@aetna.com> on 2003/04/22 15:37:00 UTC
RE: namespace
i get a org.w3c.dom.DOMException: DOM003 Namespace error
when i try to set a name space prefix.
this is the snippet .
Document d ;//d is initialised
org.w3c.dom.Attr at
=d.createAttributeNS("http://mydomain","yyy");
org.w3c.dom.Element e =dm.createElement("name");
e.setAttributeNodeNS(at);
e.setPrefix("yyy");
dm.appendChild(e);
am i missing something here?
this is my expected xml
<yyy:name
xmlns:yyy="http://mydomain.com/xml/spec">
<add> some add</add>
<age>25</age>
thx
vasanth
This e-mail may contain confidential or privileged information. If you
think you have received this e-mail in error, please advise the sender by
reply e-mail and then delete this e-mail immediately. Thank you. Aetna
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: namespace
Posted by Simon Kitching <si...@ecnetwork.co.nz>.
Hi vasanth,
Are you aware that the "createAttributeNS" method does not create a
"namespace", but creates an attribute (a name/value pair that exists
within an element) that happens to *be* in a specific namespace? The
"NS" suffix is just to distinguish this method from the "old" DOM v1
method "createAttribute" which creates an attribute that is in no
namespace (or is it the default namespace; I can never remember..).
To create an element with name "name" in namespace "http://mydomain",
try
dm.createElementNS("http://mydomain", "name");
Regards,
Simon
On Wed, 2003-04-23 at 01:37, Soosai, Lourdhu Vasanth wrote:
> i get a org.w3c.dom.DOMException: DOM003 Namespace error
> when i try to set a name space prefix.
>
> this is the snippet .
> Document d ;//d is initialised
>
> org.w3c.dom.Attr at
> =d.createAttributeNS("http://mydomain","yyy");
> org.w3c.dom.Element e =dm.createElement("name");
> e.setAttributeNodeNS(at);
> e.setPrefix("yyy");
> dm.appendChild(e);
>
> am i missing something here?
>
> this is my expected xml
> <yyy:name
> xmlns:yyy="http://mydomain.com/xml/spec">
> <add> some add</add>
> <age>25</age>
>
> thx
> vasanth
>
>
> This e-mail may contain confidential or privileged information. If you
> think you have received this e-mail in error, please advise the sender by
> reply e-mail and then delete this e-mail immediately. Thank you. Aetna
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org