From a7e9d3f37d5e9fba4b9acaa43e7c12b6d9a669ae Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 8 Jun 2006 10:59:26 +0200 Subject: Load /tmp/libxml2-2.6.26 into libxml2/branches/upstream/current. --- doc/namespaces.html | 70 ++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'doc/namespaces.html') diff --git a/doc/namespaces.html b/doc/namespaces.html index 32c7787..a4d6ace 100644 --- a/doc/namespaces.html +++ b/doc/namespaces.html @@ -7,44 +7,44 @@ H1 {font-family: Verdana,Arial,Helvetica} H2 {font-family: Verdana,Arial,Helvetica} H3 {font-family: Verdana,Arial,Helvetica} A:link, A:visited, A:active { text-decoration: underline } -Namespaces
Action against software patentsGnome2 LogoW3C LogoRed Hat Logo
Made with Libxml2 Logo

The XML C parser and toolkit of Gnome

Namespaces

Main Menu
Related links

The libxml2 library implements 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/">
+Namespaces
Action against software patentsGnome2 LogoW3C LogoRed Hat Logo
Made with Libxml2 Logo

The XML C parser and toolkit of Gnome

Namespaces

Main Menu
Related links

The libxml2 library implements XML +namespacessupportbyrecognizing namespace constructs in the input, and +does namespacelookupautomatically when building the DOM tree. A namespace +declarationisassociated with an in-memory structure and all elements or +attributeswithinthat namespace point to it. Hence testing the namespace is a +simple andfastequality operation at the user level.

I suggest that people using libxml2 use a namespace, and declare it +intheroot element of their document as the default namespace. Then they +don'tneedto use the prefix in the content but we will have a basis for +futuresemanticrefinement and merging of data from different sources. This +doesn'tincreasethe size of the XML output significantly, but significantly +increasesitsvalue 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;
+</mydoc>

The namespace value has to be an absolute URL, but the URL doesn't +havetopoint to any existing resource on the Web. It will bind all the +elementandattributes with that URL. I suggest to use an URL within a +domainyoucontrol, and that the URL should contain some kind of version +informationifpossible. For example, +"http://www.gnome.org/gnumeric/1.0/"isagood namespace scheme.

Then when you load a file, make sure that a namespace +carryingtheversion-independent prefix is installed on the root element of +yourdocument,and if the version information don't match something you know, +warnthe userand be liberal in what you accept as the input. Also do *not* try +tobasenamespace checking on the prefix value. <foo:text> may be +exactlythesame as <bar:text> in another document. What really matters +is theURIassociated with the element or the attribute, not the prefix string +(whichisjust a shortcut for the full URI). In libxml, element and attributes +haveannsfield pointing to an xmlNs structure detailing +thenamespaceprefix 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 relagx-ng and w3c-schema.

Daniel Veillard

+}

Usually people object to using namespaces together with validitychecking.I +will try to make sure that using namespaces won't break validitychecking,so +even if you plan to use or currently are using validation Istronglysuggest +adding namespaces to your document. A default +namespaceschemexmlns="http://...."should not break validity even +onlessflexible parsers. Using namespaces to mix and differentiate +contentcomingfrom multiple DTDs will certainly break current validation +schemes. Tochecksuch documents one needs to use schema-validation, which is +supportedinlibxml2 as well. See relagx-ngand w3c-schema.

Daniel Veillard

-- cgit v1.2.3