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 Dane Foster <df...@equitytg.com> on 2001/05/18 16:15:09 UTC

Why createElementNS?

If I want to create an element and it's attribute of a particular namespace,
Why should id use:

String namespaceURI = "http://someuri.something";
String elementName = "ns:someElement";
String attName = "ns:someAttribute";
String attValue = "someAttValue";


Element e = createElementNS( namespaceURI, elementName );
e.setAttributeNS( namespaceURI, attName, attValue );

instead of

Element e = createElement( elementName )
e.setAttribute( attName, attValue );

?


And finally, why doesn't Xerces' XML serializer print out the namespace
prefix if you use the first method?



Dane Foster


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


RE: Why createElementNS?

Posted by Julian Reschke <ju...@gmx.de>.
> From: Dane Foster [mailto:dfoster@equitytg.com]
> Sent: Friday, May 18, 2001 4:15 PM
> To: xerces-j-user@xml.apache.org
> Subject: Why createElementNS?
>
>
> If I want to create an element and it's attribute of a particular
> namespace,
> Why should id use:
>
> String namespaceURI = "http://someuri.something";
> String elementName = "ns:someElement";
> String attName = "ns:someAttribute";
> String attValue = "someAttValue";
>
>
> Element e = createElementNS( namespaceURI, elementName );
> e.setAttributeNS( namespaceURI, attName, attValue );
>
> instead of
>
> Element e = createElement( elementName )
> e.setAttribute( attName, attValue );

In the latter case, you aren't really placing the element into the intended
namespace, and other users of the DOM probably wouldn't recognize the
element.


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