http://swpat.ffii.org/
Action against software patents
http://www.gnome.org/
Gnome2 Logo
http://www.w3.org/Status
W3C Logo
http://www.redhat.com/
Red Hat Logo
http://xmlsoft.org/
Made with Libxml2 Logo
The XML C parser and toolkit of Gnome
Namespaces
Main Menu
index.html
Home
http://xmlsoft.org/wiki
Wiki
html/index.html
Reference Manual
intro.html
Introduction
FAQ.html
FAQ
docs.html
Developer Menu
bugs.html
Reporting bugs and getting help
help.html
How to help
downloads.html
Downloads
news.html
Releases
XMLinfo.html
XML
XSLT.html
XSLT
xmldtd.html
Validation & DTDs
encoding.html
Encodings support
catalog.html
Catalog support
namespaces.html
Namespaces
contribs.html
Contributions
examples/index.html
Code Examples
html/index.html
API Menu
guidelines.html
XML Guidelines
ChangeLog.html
Recent Changes
Related links
http://mail.gnome.org/archives/xml/
Mail archive
http://xmlsoft.org/XSLT/
XSLT libxslt
http://phd.cs.unibo.it/gdome2/
DOM gdome2
http://www.aleksey.com/xmlsec/
XML-DSig xmlsec
ftp://xmlsoft.org/
FTP
http://www.zlatkovic.com/projects/libxml/
Windows binaries
http://www.blastwave.org/packages.php/libxml2
Solaris binaries
http://www.explain.com.au/oss/libxml2xslt.html
MacOsX binaries
http://libxmlplusplus.sourceforge.net/
C++ bindings
http://www.zend.com/php5/articles/php5-xmlphp.php#Heading4
PHP bindings
http://sourceforge.net/projects/libxml2-pas/
Pascal bindings
http://rubyforge.org/projects/xml-tools/
Ruby bindings
http://tclxml.sourceforge.net/
Tcl bindings
http://bugzilla.gnome.org/buglist.cgi?product=libxml2
Bug Tracker
The libxml2 library implements
http://www.w3.org/TR/REC-xml-names/
XML namespaces
support by
recognizing namespace constructs in the input, and does namespace lookup
automatically when building the DOM tree. A namespace declaration is
associated with an in-memory structure and all elements or attributes within
that namespace point to it. Hence testing the namespace is a simple and fast
equality operation at the user level.
I suggest that people using libxml2 use a namespace, and declare it in the
root element of their document as the default namespace. Then they don't need
to use the prefix in the content but we will have a basis for future semantic
refinement and  merging of data from different sources. This doesn't increase
the size of the XML output significantly, but significantly increases its
value in the long-term. Example:
<mydoc xmlns="http://mydoc.example.org/schemas/">
<elem1>...</elem1>
<elem2>...</elem2>
</mydoc>
The namespace value has to be an absolute URL, but the URL doesn't have to
point to any existing resource on the Web. It will bind all the element and
attributes with that URL. I suggest to use an URL within a domain you
control, and that the URL should contain some kind of version information if
possible. For example,
"http://www.gnome.org/gnumeric/1.0/"
is a
good namespace scheme.
Then when you load a file, make sure that a namespace carrying the
version-independent prefix is installed on the root element of your document,
and if the version information don't match something you know, warn the user
and be liberal in what you accept as the input. Also do *not* try to base
namespace checking on the prefix value. <foo:text> may be exactly the
same as <bar:text> in another document. What really matters is the URI
associated with the element or the attribute, not the prefix string (which is
just a shortcut for the full URI). In libxml, element and attributes have an
ns
field pointing to an xmlNs structure detailing the namespace
prefix and its URI.
@@Interfaces@@
xmlNodePtr node;
if(!strncmp(node->name,"mytag",5)
&& node->ns
&& !strcmp(node->ns->href,"http://www.mysite.com/myns/1.0")) {
...
}
Usually people object to using namespaces together with validity checking.
I will try to make sure that using namespaces won't break validity checking,
so even if you plan to use or currently are using validation I strongly
suggest adding namespaces to your document. A default namespace scheme
xmlns="http://...."
should not break validity even on less
flexible parsers. Using namespaces to mix and differentiate content coming
from multiple DTDs will certainly break current validation schemes. To check
such documents one needs to use schema-validation, which is supported in
libxml2 as well. See
http://www.relaxng.org/
relagx-ng
and
http://www.w3c.org/XML/Schema
w3c-schema
.
bugs.html
Daniel Veillard
