xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gareth Reakes <gar...@parthenoncomputing.com>
Subject Re: Writing documents with schemas and namespaces...
Date Thu, 22 Apr 2004 09:50:18 GMT
Hi,

> So I noticed this, but I don't *quite* understand it.  You still have
> to put a fully-qualified name in createElementNS, so what's the point
> of calling it all the time?  Obviously you need to call it once, so
> that you get the xmlns:ndr="foo" attribute on the correct node, but
> every child of that node should probably, for efficiency, be called
> using createElement().  Or am I missing something?  I.e., if I create
> my document node with the right namespace (presuming it is used in the
> entire document), is there any reason to call createElementNS for the
> child nodes?  It seems that it would save both memory and time to just
> call createElement(), but I may not have a full understanding of the
> side-effects.

As a general rule, you should not use the level 1 API any more unless you
really know what you are doing. There are some DOM level 3 methods (unless
the recs changed it - I have not read them yet) that can't cope with level
1 nodes.

Namespace attributes such as xmlns:foo only have an effect at parse time.
You can manipulate them as much as you want after this an it will have no
effect what so ever on the namespace of any elements or attributes. The
only difference will occur during serialization. Then, if an element is
found that is in a namespace, an algorithm is used to see what prefix
should be used and if a namespace attr should be created.

If you created a document element in the correct namespace (say,
http://foo.com) and then used createElement then the child nodes would be
in no namespace. You should use createElementNS("http//foo.com", "myEle").
Note there is no need to put a prefix. If you do, when you serialize it
may stay the same.


Gareth

-- 
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                  http://www.parthcomp.com

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


Mime
View raw message