XML Namespaces and How They Affect XPath and XSLT
This article explores the ins and outs of XML namespaces and their ramifications on a number of XML technologies that support namespaces. What follows is a shortened version of my first Extreme XML column.
Overview of XML NamespacesAs XML usage on the Internet became more widespread, the benefits of being able to create markup vocabularies that could be combined and reused similarly to how software modules are combined and reused became increasingly important. If a well defined markup vocabulary for describing coin collections, program configuration files, or fast food restaurant menus already existed, then reusing it made more sense than designing one from scratch. Combining multiple existing vocabularies to create new vocabularies whose whole was greater than the sum of its parts also became a feature that users of XML began to require.
However, the likelihood of identical markup, specifically XML elements and attributes, from different vocabularies with different semantics ending up in the same document became a problem. The very extensibility of XML and the fact that its usage had already become widespread across the Internet precluded simply specifying reserved elements or attribute names as the solution to this problem.
The goal of the W3C XML
namespaces recommendation was to create a
mechanism in which elements and attributes within an
XML document that were from different markup
vocabularies could be unambiguously identified and
combined without processing problems ensuing. The XML
namespaces recommendation provided a method for
partitioning various items within an XML document
based on processing requirements without placing undue
restrictions on how these items should be named. For
instance, elements named <template>, <output>, and <stylesheet> can occur in an
XSLT stylesheet without there being ambiguity as to
whether they are transformation directives or
potential output of the transformation.
An XML namespace is a collection of names, identified by a Uniform Resource Identifier (URI) reference, which are used in XML documents as element and attribute names.
Namespace DeclarationsA namespace declaration is typically used to map a namespace URI to a specific prefix. The scope of the
prefix-namespace mapping is that of the element that
the namespace declaration occurs on as well as all its
children. An attribute declaration that begins with
the prefix xmlns: is a
namespace declaration. The value of such an attribute
declaration should be a namespace URI which is the namespace
name.
Here is an example of an XML document where the
root element contains a namespace declaration that
maps the prefix bk to the
namespace name urn:xmlns:25hoursaday-com:bookstore
and its child element contains an inventory element that contains a
namespace declaration that maps the prefix inv to the namespace name urn:xmlns:25hoursaday-com:inventory-tracking.
<bk:book>
<bk:title>Lord of the Rings</bk:title>
<bk:author>J.R.R. Tolkien</bk:author>
<inv:inventory status="in-stock" isbn="0345340426"
xmlns:inv="urn:xmlns:25hoursaday-com:inventory-tracking" />
</bk:book>
</bk:bookstore>
In the above example, the scope of the namespace
declaration for the urn:xmlns:25hoursaday-com:bookstore
namespace name is the entire bk:bookstore element, while that of
the urn:xmlns:25hoursaday-com:inventory-tracking
is the inv:inventory element.
Namespace aware processors can process items from both
namespaces independently of each other, which leads to
the ability to do multi-layered processing of XML
documents. For instance, RDDL
documents are valid XHTML documents
that can be rendered by a Web browser but also contain
information using elements from the http://www.rddl.org namespace that
can be used to locate machine readable resources about
the members of an XML namespace.
It should be noted that by definition the prefix
xml is bound to the XML namespace
name and this special namespace is automatically
predeclared with document scope in every well-formed
XML document.
The previous section on namespace declarations is
not entirely complete because it leaves out default
namespaces. A default namespace declaration is an
attribute declaration that has the name xmlns and its value is the namespace
URI that is the namespace name.
A default namespace declaration specifies that every unprefixed element name in its scope be from the declaring namespace. Below is the bookstore example utilizing a default namespace instead of a prefix-namespace mapping.
<bookstore xmlns="urn:xmlns:25hoursaday-com:bookstore"><book>
<title>Lord of the Rings</bk:title>
<author>J.R.R. Tolkien</bk:author>
<inv:inventory status="in-stock" isbn="0345340426"
xmlns:inv="urn:xmlns:25hoursaday-com:inventory-tracking" />
</book>
</bookstore>
All the elements in the above example except for
the inv:inventory element
belong to the urn:xmlns:25hoursaday-com:bookstore
namespace. The primary purpose of default namespaces
is to reduce the verbosity of XML documents that
utilize namespaces. However, using default namespaces
instead of utilizing explicitly mapped prefixes for
element names can be confusing because it is not
obvious that the elements in the document are
namespace scoped.
Also, unlike regular namespace declarations,
default namespace declarations can be undeclared by
setting the value of the xmlns attribute to the
empty string. Undeclaring default namespace
declarations is a practice that should be avoided
because it may lead to a document that has unprefixed
names that belong to a namespace in one part of the
document, but don't in another. For example, in the
document below only the bookstore element is from the urn:xmlns:25hoursaday-com:bookstore while the other unprefixed elements have no namespace name.
<book xmlns="">
<title>Lord of the Rings</bk:title>
<author>J.R.R. Tolkien</bk:author>
<inv:inventory status="in-stock" isbn="0345340426"
xmlns:inv="urn:xmlns:25hoursaday-com:inventory-tracking" />
</book>
</bookstore>
This practice should be avoided because it leads to extremely confusing situations for readers of the XML document. For more information on undeclaring namespace declarations, see the section on Namespaces Future.
Qualified and Expanded NamesA qualified name, also known as a QName, is an XML name called the local name optionally preceded by another XML name called the prefix and a colon (':') character. The XML names used as the prefix and the local name must match the NCName production, which means that they must not contain a colon character. The prefix of a qualified name must have been mapped to a namespace URI through an in-scope namespace declaration mapping the prefix to the namespace URI. A qualified name can be used as either an attribute or element name.
Although QNames are important mnemonic guides to determining what namespace the elements and attributes within a document are derived from, they are rarely important to XML aware processors. For example, the following three XML documents would be treated identically by a range of XML technologies including, of course, XML schema validators.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:complexType id="123" name="fooType"/>
</xs:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType id="123" name="fooType"/>
</xsd:schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<complexType id="123" name="fooType"/>
</schema>
The W3C XML Path Language recommendation describes an expanded name as a pair consisting of a namespace name and a local name. A universal name is an alternate term coined by James Clark to describe the same concept. A universal name consists of a namespace name in curly braces and a local name. Namespaces tend to make more sense to people when viewed through the lens of universal names. Here are the three XML documents from the previous example with the QNames replaced by universal names. Note that the syntax below is not valid XML syntax.
<{http://www.w3.org/2001/XMLSchema}schema><{http://www.w3.org/2001/XMLSchema}complexType id="123" name="fooType"/>
</{http://www.w3.org/2001/XMLSchema}schema>
<{http://www.w3.org/2001/XMLSchema}schema>
<{http://www.w3.org/2001/XMLSchema}complexType id="123" name="fooType"/>
</{http://www.w3.org/2001/XMLSchema}schema>
<{http://www.w3.org/2001/XMLSchema}schema>
<{http://www.w3.org/2001/XMLSchema}complexType id="123" name="fooType"/>
</{http://www.w3.org/2001/XMLSchema}schema>
To many XML applications, the universal name of the elements and attributes in an XML document are what is important, and not the values of the prefixes used in specific QNames. The primary reason the Namespaces in XML recommendation does not take the expanded name approach to specifying namespaces is due to its verbosity. Instead, prefix mappings and default namespaces are provided to save us all from developing carpal tunnel syndrome from typing namespace URIs endlessly.
Namespaces and AttributesNamespace declarations do not apply to attributes
unless the attribute's name is prefixed. In the XML
document shown below the title
attribute belongs to the bk:book element and has no namespace
while the bk:title attribute
has urn:xmlns:25hoursaday-com:bookstore
as its namespace name. Note that even though both
attributes have the same local name the document is
well formed.
<bk:bookstore
xmlns:bk="urn:xmlns:25hoursaday-com:bookstore">
<bk:book title="Lord of the Rings,
Book 3" bk:title="Return of the King"/>
</bk:bookstore> In the following example, the title attribute still has no
namespace and belongs the book
element even though there is a default namespace
specified. In other words, attributes cannot inherit the default namespace.
<bookstore
xmlns="urn:xmlns:25hoursaday-com:bookstore">
<book title="Lord of the Rings, Book
3" />
</bookstore> Namespace URIs
A namespace name is a Uniform Resource Identifier (URI) as specified in RFC 2396. A URI is either a Uniform Resource Locators (URLs) or a Uniform Resource Names (URNs). URLs are used to specify the location of resources on the Internet, while URNs are supposed to be persistent, location-independent identifiers for information resources. Namespace names are considered to be identical only if they are the same character for character (case-sensitive). The primary justification for using URIs as namespace names is that they already provide a mechanism for specifying globally unique identities.
The XML namespaces recommendation states that namespace names are only to act as unique identifiers and do not have to actually identify network retrievable resources. This has led to much confusion amongst authors and users of XML documents, especially since the usage of HTTP based URLs as namespace names has grown in popularity. Because many applications convert such URIs to hyperlinks, it is irritating to many users that these "links" do not lead to Web pages or other network retrievable resource. I remember one user who likened it to being given a fake phone number in a social situation.
One solution to avoid confusing users is to use a
namespace-naming schema that does not imply network
retrievability of the resource. I personally use the
urn:xmlns: scheme for this
purpose and create namespace names similar to urn:xmlns:25hoursaday-com when
authoring XML documents for personal use. The problem
with homegrown namespace URIs is that they may run
counter to the intent of the Names in XML
recommendation by not being globally unique. I get
around the globally unique requirement by using my
personal domain name http://www.25hoursaday.com
as part of the namespace URI.
Another solution is to leave a network retrievable resource at the URI that is the namespace name, such as is done with the XSLT and RDDL namespaces. Typically, such URIs are actually HTTP URLs. A good way to name such URLs is by using the format favored by the W3C, which is as follows:
http://my.domain.example.org/product/[year/month][/area]See the section on Namespaces and Versioning for more information on using similarly structured namespace names as a versioning mechanism.
DOM, XPath, and the XML Information Set on NamespacesThe W3C has defined a number of technologies that provide a data model for XML documents. These data models are generally in agreement, but sometimes differ in how they treat various edge cases due to historic reasons. Treatment of XML namespaces and namespace declarations is an example of an edge case that is treated differently in the three primary data models that exist as W3C recommendations. The three data models are the XPath data model, the Document Object Model (DOM), and the XML information set.
The XML information set (XML infoset) is an abstract description of the data in an XML document and can be considered to be the primary data model for an XML document. The XPath data model is a tree-based model that is traversed when querying an XML document and is similar to the XML information set. The DOM precedes both data models but is also similar to both data models in a number of ways. Both the DOM and the XPath data model can be considered to be interpretations of the XML infoset.
Namespaces in the Document Object Model (DOM)The XML
namespace section of the DOM Level 3 specification
considers namespace declarations to be regular
attribute nodes that have
http://www.w3.org/2000/xmlns/ as their namespace name
and xmlns as their prefix or
qualified name.
Elements and attributes in the DOM have a namespace name that cannot be altered after they have been created regardless of whether their location within the document changes or not.
Namespaces in the XPath Data ModelThe W3C XPath recommendation does not consider namespace declarations to be attribute nodes and does not provide access to them in that capacity. Instead, in XPath every element in an XML document has a number of namespace nodes that can be retrieved using the XPath namespace navigation axis.
Each element in the document has a unique set of namespace nodes for each namespace declaration in scope for that particular element. Namespace nodes are unique to each element in that namespace. Thus namespace nodes for two different elements that represent the same namespace declaration are not identical.
Namespaces in the XML Information SetThe XML infoset recommendation considers namespace declarations to be attribute information items.
In addition, similar to the XPath data model, each element information item in an XML document's information set has a namespace information item for each namespace that is in scope for the element.
XPath, XSLT and NamespacesThe W3C XML Path Language also known as XPath is used to address parts of an XML document and is used in a number of W3C XML technologies including XSLT, XPointer, XML Schema, and DOM Level 3. XPath uses a hierarchical addressing mechanism similar to that used in file systems and URLs to retrieve pieces of an XML document. XPath supports rudimentary manipulation of strings, numbers, and Booleans.
XPath and NamespacesThe XPath data model treats an XML document as a tree of nodes, such as element, attribute, and text nodes, where the name of each node is a combination of its local name and its namespace name (that is, its universal or expanded name).
For element and attribute nodes without namespaces, performing XPath queries is fairly straightforward. The following program, which can be used to query XML documents using the command line, shall be used to demonstrate the impact of namespaces on XPath queries.
using System.Xml.XPath;using System.Xml;
using System;
using System.IO;
class XPathQuery{
public static string PrintError(Exception e, string errStr){
if(e == null)
return errStr;
else
return PrintError(e.InnerException, errStr + e.Message );
}
public static void Main(string[] args){
if((args.Length == 0) || (args.Length % 2)!= 0){
Console.WriteLine("Usage: xpathquery source query <zero or more
prefix and namespace pairs>");
return;
}
try{
//Load the file.
XmlDocument doc = new XmlDocument();
doc.Load(args[0]);
//create prefix<->namespace mappings (if any)
XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);
for(int i=2; i < args.Length; i+= 2)
nsMgr.AddNamespace(args[i], args[i + 1]);
//Query the document
XmlNodeList nodes = doc.SelectNodes(args[1], nsMgr);
//print output
foreach(XmlNode node in nodes)
Console.WriteLine(node.OuterXml + "\n\n");
}catch(XmlException xmle){
Console.WriteLine("ERROR: XML Parse error occured because " +
PrintError(xmle, null));
}catch(FileNotFoundException fnfe){
Console.WriteLine("ERROR: " + PrintError(fnfe, null));
}catch(XPathException xpath){
Console.WriteLine("ERROR: The following error occured while querying
the document: "
+ PrintError(xpath, null));
}catch(Exception e){
Console.WriteLine("UNEXPECTED ERROR" + PrintError(e, null));
}
}
}
Given the following XML document that does not declare any namespaces, queries are fairly straightforward as seen in the examples following the code.
<?xml version="1.0" encoding="utf-8" ?><bookstore>
<book genre="autobiography">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
</bookstore>
Example 1
-
xpathquery.exe bookstore.xml /bookstore/book/titleSelects all the title elements that are children of the
bookelement whose parent is thebookstoreelement, which returns:
<title>The Autobiography of Benjamin Franklin</title>
<title>The Confidence Man</title> -
xpathquery.exe bookstore.xml //@genreSelect all the
genreattributes in the document and returns:
genre="autobiography"
genre="novel" -
xpathquery.exe bookstore.xml //title[(../author/first-name = 'Herman')]Selects all the titles where the author's first name is "Herman" and returns:
<title>The Confidence Man</title>
However, once namespaces are added to the mix, things are no longer as simple. The file below is identical to the original file except for the addition of namespaces and one attribute to one of the
<bookstore xmlns="urn:xmlns:25hoursaday-com:bookstore">bookelements.
<book genre="autobiography">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<bk:book genre="novel" bk:genre="fiction"
xmlns:bk="urn:xmlns:25hoursaday-com:bookstore">
<bk:title>The Confidence Man</bk:title>
<bk:author>
<bk:first-name>Herman</bk:first-name>
<bk:last-name>Melville</bk:last-name>
</bk:author>
<bk:price>11.99</bk:price>
</bk:book>
</bookstore>
Note that the default namespace is in scope for the whole XML document, while the namespace declaration that maps the prefix
bkto the namespace nameurn:xmlns:25hoursaday-com:bookstoreis in scope for the second book element only.
-
xpathquery.exe bookstore.xml /bookstore/book/title
Selects all the title elements that are children of the
bookelement whose parent is thebookstoreelement, which returns NO RESULTS. -
xpathquery.exe bookstore.xml //@genreSelects all the
genreattributes in the document and returns:
genre="autobiography"
genre="novel" -
xpathquery.exe bookstore.xml //title[(../author/first-name = 'Herman')]Selects all the titles where the author's first name is "Herman," which returns NO RESULTS.
The first query returns no results because unprefixed names in an XPath query apply to elements or attributes with no namespace. There are no
bookstore,book, ortitleelements in the target document that have no namespace. The second query returns all attribute nodes that have no namespace. Although namespace declarations are in scope for both attribute nodes returned by the query, they have no namespace because namespace declarations do not apply to attributes with unprefixed names. The third query returns no results for the same reasons the first query returns no results.The way to perform namespace-aware XPath queries is to provide a prefix to namespace mapping to the XPath engine, then use those prefixes in the query. The prefixes provided do not need to be the same as the namespace to prefix mappings in the target document, and they must be non-empty prefixes.
-
xpathquery.exe bookstore.xml /b:bookstore/b:book/b:title b urn:xmlns:25hoursaday-com:bookstoreSelect all the title elements that are children of the
bookelement whose parent is thebookstoreelement and returns the following:
<title xmlns="urn:xmlns:25hoursaday-com:bookstore">The Autobiography of Benjamin Franklin</title>
<bk:title xmlns:bk="urn:xmlns:25hoursaday-com:bookstore">The Confidence Man</bk:title> -
xpathquery.exe bookstore.xml //@b:genre b urn:xmlns:25hoursaday-com:bookstoreSelects all thegenreattributes from the "urn:xmlns:25hoursaday-com:bookstore" namespace in the document that returns:
bk:genre="fiction" -
xpathquery.exe bookstore.xml //bk:title[(../bk:author/bk:first-name = 'Herman')] bk urn:xmlns:25hoursaday-com:bookstore
Selects all the titles where the author's first name is "Herman" and returns:
<bk:title xmlns:bk="urn:xmlns:25hoursaday-com:bookstore">The Confidence Man</bk:title>
Note This last example is the same as the previous examples but rewritten to be namespace aware.
For more information on using XPath, read Aaron Skonnard's article Addressing Infosets with XPath and view the examples at the ZVON.org XPath tutorial.
XSLT and NamespacesThe W3C XSL transformations (XSLT) recommendation describes an XML-based language for transforming XML documents into other XML documents. XSLT transformations, also known as XML style sheets, utilize patterns (XPath) to match aspects of the target document. Upon matching nodes in the target document, templates that specify the output of a successful match can be instantiated and used to transform the document.
Support for namespaces is tightly integrated into XSLT, especially since XPath is used for matching nodes in the source document. Using namespaces in your XPath expressions inside XSLT is much easier than using the DOM.
The example that follows contains:
- A program for use in executing transforms from the command line.
- An XSLT stylesheet that prints
all the
titleelements from theurn:xmlns:25hoursaday-com:bookstorenamespace in the source XML document when run against thebookstoredocument from theurn:xmlns:25hoursaday-com:bookstorenamespace. - The resulting output.
Imports System.Xml
Imports System
Imports System.IO
Class Transformer
Public Shared Function PrintError(e As Exception, errStr As String) As String
If e Is Nothing Then
Return errStr
Else
Return PrintError(e.InnerException, errStr + e.Message)
End If
End Function 'PrintError
'Entry point which delegates to C-style main Private Function
Public Overloads Shared Sub Main()
Run(System.Environment.GetCommandLineArgs())
End Sub 'Main
Overloads Public Shared Sub Run(args() As String)
If args.Length <> 2 Then
Console.WriteLine("Usage: xslt source stylesheet")
Return
End If
Try
'Create the XslTransform object.
Dim xslt As New XslTransform()
'Load the stylesheet.
xslt.Load(args(1))
'Transform the file.
Dim doc As New XmlDocument()
doc.Load(args(0))
xslt.Transform(doc, Nothing, Console.Out)
Catch xmle As XmlException
Console.WriteLine(("ERROR: XML Parse error occured because " +
PrintError(xmle, Nothing)))
Catch fnfe As FileNotFoundException
Console.WriteLine(("ERROR: " + PrintError(fnfe, Nothing)))
Catch xslte As XsltException
Console.WriteLine(("ERROR: The following error occured while
transforming the document: " + PrintError(xslte, Nothing)))
Catch e As Exception
Console.WriteLine(("UNEXPECTED ERROR" + PrintError(e, Nothing)))
End Try
End Sub
End Class 'Transformer
XSLT stylesheet <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:b="urn:xmlns:25hoursaday-com:bookstore">
<xsl:template match="b:bookstore">
<book-titles>
<xsl:apply-templates select="b:book/b:title"/>
</book-titles>
</xsl:template>
<xsl:template match="b:title">
<xsl:copy-of select="." />
</xsl:template>
</xsl:stylesheet>
Output <?xml version="1.0" ?>
<book-titles xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:ext="urn:my_extensions" xmlns:b="urn:xmlns:25hoursaday-com:bookstore">
<title xmlns="urn:xmlns:25hoursaday-com:bookstore">The Autobiography of
Benjamin Franklin</title>
<bk:title xmlns="urn:xmlns:25hoursaday-com:bookstore"
xmlns:bk="urn:xmlns:25hoursaday-com:bookstore">The Confidence
Man</bk:title>
</book-titles>
Note that the namespace declarations from the stylesheet end up on the root node of the output XML document. Also to note is the fact that the XSLT namespace is not included in the output XML document.
Generating XSLT stylesheets from the output of your XSLT transforms is slightly cumbersome because the processor has to be able to determine the output elements from the actual stylesheet directives. There are two ways I have found to deal with this issue, both of which I'll illustrate by showing stylesheets that generate the following XMLT stylesheet as output.
<xslt:stylesheet version="1.0"xmlns:xslt="http://www.w3.org/1999/XSL/Transform">
<xslt:output method="text"/>
<xslt:template match="/"><xslt:text>HELLO WORLD</xslt:text></xslt:template>
</xslt:stylesheet>
The first method involves creating a variable
containing the stylesheet to be created, and then
using value-of in combination
with the disable-output-escaping attribute to create the stylesheet.
<xsl:output method="xml" encoding="utf-8"/>
<xsl:variable name="stylesheet">
<xslt:stylesheet version="1.0"
xmlns:xslt="http://www.w3.org/1999/XSL/Transform">
<xslt:output method="text"/>
<xslt:template match="/"><xslt:text>HELLO
WORLD</xslt:text></xslt:template>
</xslt:stylesheet>
</xsl:variable>
<xsl:template match="/">
<xsl:value-of select="$stylesheet" disable-output-escaping="yes" />
</xsl:template>
</xsl:stylesheet>
This first method works best if the stylesheet being created can be easily partitioned so that it can be placed in variables. While this technique is quick and easy, it also falls into the category of gross hack, which typically tend to become unmanageable when faced with any situation requiring flexibility. For instance, when creation of the new stylesheet involves lots of dynamic creation of text and is intertwined with the stylesheet directives, the following method is preferable to the aforementioned gross hack.
<xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"xmlns:alias="http://www.w3.org/1999/XSL/Transform-alias">
<xslt:output method="xml" encoding="utf-8"/>
<xslt:namespace-alias stylesheet-prefix="alias" result-prefix="xslt"/>
<xslt:template match="/">
<alias:stylesheet version="1.0">
<alias:output method="text"/>
<alias:template match="/"><alias:text>HELLO
WORLD</alias:text></alias:template>
</alias:stylesheet>
</xslt:template>
</xslt:stylesheet>
The above document uses the namespace-alias directive to
substitute the alias prefix
and namespace name it is bound to with the xslt prefix and the namespace name
to which it is bound.
Namespaces are also used to specify mechanisms for
the extension of XSLT. Namespace prefixed functions
can be created that are executed in the same manner as
XSLT functions. Similarly, elements from certain
namespaces can be treated as extensions to XSLT and
executed as if they were transformation directives
like template, copy, value-of, and so on. Below is an
example of a Hello World program that uses
namespace-based extension functions to print the
signature greeting.
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:newfunc="urn:my-newfunc">
<output method="text"/>
<template match="/">
<value-of select="newfunc:SayHello()" />
</template>
<msxsl:script language="JavaScript" implements-prefix="newfunc">
function SayHello() {
return "Hello World";
}
</msxsl:script>
</stylesheet>
XML Namespace Caveats
Namespaces in XML, like any useful tool, can be used improperly and have various subtleties that may cause problems if users are unaware of them. This section focuses on areas where users of XML namespaces typically have problems or face misconceptions.
Versioning and NamespacesThere are two primary mechanisms used in practice to create different versions of an XML instance document. One method is to use a version attribute on the root element as is done in XSLT, while the other method is to use the namespace name of the elements as the versioning mechanism. Versioning based on namespaces is currently very popular, especially with the W3C, who have used this mechanism for various XML technologies including SOAP, XHTML, XML Schema, and RDF. The namespace URI for documents that are versioned using the namespace is typically in the following format:
http://my.domain.example.org/product/[year/month][/area]The primary problem with versioning XML documents by altering the namespace name in subsequent versions is that it means XML namespace-aware applications that process the documents will no longer work with the documents, and will have to be upgraded. This is primarily beneficial with document formats whose versions change infrequently, but upon changing alter the semantics of elements and attributes, thus requiring that all processors no longer work with the newer versions for fear of misinterpreting them.
On the other hand, there are a number of scenarios
where an XML document versioning mechanism based on a
version attribute on the root element is
sufficient. A version attribute is primarily
beneficial when changes in the document's structure
are backwards compatible. The following situations are
all areas where using a version attribute is a
wise choice:
- Semantics of elements and attributes will not be altered.
- Changes to the document involves the addition of elements and attributes, but rarely removal.
- Interoperability between applications with various versions of the processing software is necessary.
Both versioning techniques are not mutually exclusive and can be used simultaneously. For instance, XSLT uses both a version attribute on the root element, as well as a versioned namespace URI. The version attribute is used for incremental, backwards-compatible changes to the XML document's format, while altering the namespace name is done for significant changes in the semantics of the document.
Document TypesThe term document type is misleading as discussed in several philosophical debates on various XML related mailing lists . In many cases, the namespace name of the root element can be used to determine how to process the document, however, this is hardly a general rule and stating it as such violates the spirit of XML namespaces as they were designed exactly so that developers could mix and match XML vocabularies.
A succinct post that captures the essence of why thinking that root element namespace URI are equivalent to a notion of document type is this post by Rick Jelliffe on XML-DEV. The essence of the post is that there are many different types that an XML document could have, including its document type as specified by its Document Type Definition (DTD), its MIME media type, its schema definition as specified by the xsi:schemaLocation attribute, its file extension, as well as the namespace name of its root element. Thus it is quite likely that in many cases a document will have many different types depending on what perspective one decides to take when examining the document.
Two examples of XML documents in which actual document types can be misconstrued by simply looking at the namespace URI of the root element are RDDL documents (sample, notice that its root element is from the XHTML namespace) and annotated mapping schemas, which have their root element is from the W3C XML Schema namespace.
In a nutshell, the type of a document cannot conclusively be determined by looking at the namespace URI of its root element. Thinking otherwise is folly.
Namespaces FutureThere are a number of developments in the XML world focused on tackling some of the issues that have developed around XML namespaces. Firstly, the current draft of the W3C XML namespaces recommendation does not provide a mechanism for undeclaring namespaces that have been mapped to a prefix. The W3C XML namespaces v1.1 working draft is intended to rectify this oversight by providing a mechanism for undeclaring prefix namespace mappings in an instance document.
The debate on what should be returned on an attempt to dereference the contents of a namespace URI has lead to contentious debate in the XML world and is currently the focus of deliberations by the W3C's Technical Architecture Group. The current version of the XML namespaces recommendation does not require the namespace URI to actually be resolvable because a namespace URI is supposed to merely be a namespace name that is used as a unique identifier, and not the location of a resource on the Internet.
Tim Bray (one of the original editors of both the XML Language and XML namespaces recommendations) has written an exhaustive treatise on the issues around namespace URIs and the namespace documents that may or may not be retrieved from them. This document contains much of the reasoning that was behind his creation of the Resource Directory Description Language (RDDL), which is designed to be used for creating namespace documents.
Time for closin'
The
/. is becoming k5 now?
Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
i missed FP because the page took so long to render. fuck you all, esp, the ACs
10 just in the front page blurb! :)
FP ! Logged in trolls, you suck ass! We shell rule the world! LOLOLOLOLOLOLOLOL
Finally, a clear, consise tutorial on XML namespaces. Just goes to show what a simple, easily understood, efficient and applicable technology XML is...
"In a 32-bit world, you're a 2-bit user. You've got your own newsgroup, alt.total.loser." -Weird Al
What is this?
It's not knew, it's somewhat informative. It's very, very basic.
So what is the point?
If this is some kind of new thing then cool. I'm looking forward to the VB tutorial on ADO.
.
It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
Couldn't this be linked instead of transcribing the whole shebang here?
My proxy server filtered this entire story out due to pornographical content.
Karma: Good (despite my invention of the Karma: sig)
If slashdot posted more stuff like this, I would almost be persuaded to subscribe
.almost.
You defeated me, the (not so) great AC, therefore i kneel before you.
I'll try to improve.
Jees... one of the longest pieces of text i read on slashdot.. Someone forgot the web could be used to hyperlink to such information and let it be viewable for a larger public..
/. crowd.. i know...
Okay.. there is no larger public as the
I like K5 pretty much. -> Therefore i like slashdot? nahh..
It has come to my attention that the entire Linux community is a hotbed of so called 'alternative sexuality,' which includes anything from hedonistic orgies to homosexuality to pedophilia.
What better way of demonstrating this than by looking at the hidden messages contained within the names of some of Linux's most outspoken advocates:
Linus Torvalds is an anagram of SLIT ANUS OR VD 'L,' clearly referring to himself by the first initial.
Richard M. Stallman , spokespervert for the Gaysex is Not Unusual 'movement' is an anagram of MANS CRAM THRILL AD.
Alan Cox is barely an anagram of ANAL COX which is just so filthy and unchristian it unnerves me.
I'm sure that Eric S. Raymond, composer of the satanic homosexual propaganda diatribe The Cathedral and the Bizarre, [Buy At Amazon] is probably an anagram of something queer, but we don't need to look that far as we know he's always shoving a gun up some poor little boy's rectum. Update: Eric S. Raymond is actually an anagram for SECONDARY RIM and CORD IN MY ARSE. It just goes to show you that he is indeed queer.
Update the Second: It is also documented that Evil Sicko Gaymond is responsible for a nauseating piece of code called Fetchmail, which is obviously sinister sodomite slang for "Felch Male" - a disgusting practise. For those not in the know, "felching" is the act performed by two perverts wherein one sucks their own post-coital ejaculate out of the other's rectum. In fact, it appears that the dirty Linux faggots set out to undermine the good Republican institution of e-mail, turning it into "e-male."
As far as Richard "(cock)Master" Stallman goes, that filthy fudge-packer was actually quoted on leftist commie propaganda site Salon.com as saying the following:
And this isn't a made up troll bullshit either! He actually stated this tripe, which makes it obvious that he is trying to politely say that he's a flaming homo slut!
Speaking about "flaming," who better to point out as a filthy chutney ferret than Slashdot's very own self-confessed pederast Jon Katz. Although an obvious deviant anagram cannot be found from his name, he has already confessed, nay boasted of the homosexual perversion of corrupting the innocence of young children. To quote from the article linked:
Is this why you were touching your penis in the cinema, Jon? And letting the other boys touch it too?
We should also point out that Jon Katz refers to himself as "Slashdot's resident Gasbag." Is there any more doubt? For those fortunate few who aren't aware of the list of homosexual terminology found inside the Linux "Sauce Code," a "Gasbag" is a pervert who gains sexual gratification from having a thin straw inserted into his urethra (or to use the common parlance, "piss-pipe"), then his homosexual lover blows firmly down the straw to inflate his scrotum. This is, of course, when he's not busy violating the dignity and copyright of posters to Slashdot by gathering together their postings and publishing them en masse to further his twisted and manipulative journalistic agenda.
Sick, disgusting antichristian perverts, the lot of them.
In addition, many of the Linux distributions (a 'distribution' is the most common way to spread the faggots' wares) are run by faggot groups. The Slackware distro is named after the Slack-wear fags wear to allow easy access to the anus for sexual purposes. Furthermore, Slackware is a close anagram of CLAW ARSE, a reference to the homosexual practise of anal fisting. The Mandrake product is run by a group of French faggot satanists, and is named after the faggot nickname for the vibrator. It was also chosen because it is an anagram for DARK AMEN and RAM NAKED, which is what they do.
Another "distro," (abbrieviated as such because it sounds a bit like "Disco," which is where homosexuals preyed on young boys in the 1970s), is Debian, an anagram of IN A BED, which could be considered innocent enough (after all, a bed is both where we sleep and pray), until we realise what other names Debian uses to describe their foul wares. "Woody" is obvious enough, being a term for the erect male penis, glistening with pre-cum. But far sicker is the phrase "Frozen Potato" that they use. This filthy term, again found in the secret homosexual "Sauce Code," refers to the solo homosexual practice of defecating into a clear polythene bag, shaping the turd into a crude approximation of the male phallus, then leaving it in the freezer overnight until it becomes solid. The practitioner then proceeds to push the frozen 'potato' up his own rectum, squeezing it in and out until his tight young balls erupt in a screaming orgasm.
And Red Hat is secret homo slang for the tip of a penis that is soaked in blood from a freshly violated underage ringpiece.
The fags have even invented special tools to aid their faggotry! For example, the "supermount" tool was devised to allow deeper penetration, which is good for fags because it gives more pressure on the prostate gland. "Automount" is used, on the other hand, because Linux users are all fat and gay, and need to mount each other automatically.
The depths of their depravity can be seen in their use of "mount points." These are, plainly speaking, the different points of penetration. The main one is obviously /anus, but there are others. Militant fags even say "There is no /opt mount point" because for these dirty perverts faggotry is not optional but a way of life.
More evidence is in the fact that Linux users say how much they love 'man', even going so far as to say that all new Linux users (who are in fact just innocent heterosexuals indoctrinated by the gay propaganda) should try out 'man'. In no other system do users boast of their frequent recourse to a man.
Other areas of the system also show Linux's inherit gayness. For example, people are often told of the "FAQ," but how many innocent heterosexual Windows users know what this actually means. The answer is shocking: Faggot Anal Quest: the voyage of discovery for newly converted fags!
Even the title "Slashdot" originally referred to a homosexual practice. Slashdot of course refers to the popular gay practice of blood-letting. The Slashbots, of course are those super-zealous homosexuals who take this perversion to its extreme by ripping open their anuses, as seen on the site most popular with Slashdot users, the depraved work of Satan, http://www.goatse.cx/.
The editors of Slashdot also have homosexual names: "Hemos" is obvious in itself, being one vowel away from "Homos." But even more sickening is "Commander Taco" which sounds a bit like "Commode in Taco," filthy gay slang for a pair of spreadeagled buttocks that are caked with excrement. (The best form of lubrication, they insist.) Sometimes, these "Taco Commodes" have special "Salsa Sauce" (blood from a ruptured rectum) and "Cheese" (rancid flakes of penis discharge) toppings. And to make it even worse, Slashdot runs on Apache!
The Apache server, whose use among fags is as prevalent as AIDS, is named after homosexual activity -- as everyone knows, popular faggot band, The Village People, featured an Apache Indian, and it is for him that this gay program is named.
And that's not forgetting the use of patches in the Linux fag world -- patches are used to make the anus accessible for repeated anal sex even after its rupture by a session of fisting.
To summarise: Linux is gay. "Slash - Dot" is the graphical description of the space between a young boy's scrotum and anus. And BeOS is for hermaphrodites and disabled "stumpers."
FEEDBACK
Well, the only reason I know all about this is because I had the misfortune to read the Linux "Sauce code" once. Although publicised as the computer code needed to get Linux up and running on a computer (and haven't you always been worried about the phrase "Monolithic Kernel"?), this foul document is actually a detailed and graphic description of every conceivable degrading perversion known to the human race, as well as a few of the major animal species. It has shocked and disturbed me, to the point of needing to shock and disturb the common man to warn them of the impending homo-calypse which threatens to engulf our planet.
Doesn't it give you a hard-on to imagine your thick strong poker ramming it's way up my most sacred of sphincters? You're beyond help, my friend, as the only thing you can imagine is the foul penetrative violation of another man. Are you sure you're not Eric Raymond? The government, being populated by limp-wristed liberals, could never stem the sickening tide of homosexual child molesting Linux advocacy. Hell, they've given NAMBLA free reign for years!
Thank you for your kind words of support. However, this document shall only ever be posted anonymously. This is because the "Open Sauce" movement is a sham, proposing homoerotic cults of hero worshipping in the name of freedom. I speak for the common man. For any man who prefers the warm, enveloping velvet folds of a woman's vagina to the tight puckered ringpiece of a child. These men, being common, decent folk, don't have a say in the political hypocrisy that is Slashdot culture. I am the unknown liberator.
We shouldn't hate them, we should pity them for the misguided fools they are... Fanatical Linux zeal-outs need to be herded into camps for re-education and subsequent rehabilitation into normal heterosexual society. This re-education shall be achieved by forcing them to watch repeats of Baywatch until the very mention of Pamela Anderson causes them to fill their pants with healthy heterosexual jism.
Well, it just goes to show that even the holy Linux "sauce code" is riddled with bugs that need fixing. (The irony of Jon Katz not even being able to inflate his scrotum correctly has not been lost on me.) The Linux pervert elite already acknowledge this, with their queer slogan: "Given enough arms, all rectums are shallow." And anyway, the PS2 sucks major cock and isn't worth the money. Intellivision forever!
For one thing, whilst Linux is a cavalcade of queer propaganda masquerading as the future of computing, NT is used by people who think nothing better of encasing their genitals in quick setting plaster then going to see a really dirty porno film, enjoying the restriction enforced onto them. Remember, a wasted arousal is a sin in the eyes of the Catholic church. Clearly, the only god-fearing Christian operating system in existence is CP/M -- The Christian Program Monitor. All computer users should immediately ask their local pastor to install this fine OS onto their systems. It is the only route to salvation.
Secondly, this message is for every man. Computers know no colour. Not only that, but one of the finest websites in the world is maintained by A Black Man . Now fuck off you racist donkey felcher.
Although there is nothing unholy about the fine heterosexual act of ejaculating between a woman's breasts, squirting one's load up towards her neck and chin area, it should be noted that Perl (standing for Pansies Entering Rectums Locally) is also close to "Pearl Monocle", "Pearl Nosering", and the ubiquitous "Pearl Enema".
One scary thing about Perl is that it contains hidden homosexual messages. Take the following code: LWP::Simple -- It looks innocuous enough, doesn't it? But look at the line closely: There are two colons next to each other! As Larry "Balls to the" Wall would openly admit in the Perl Documentation, Perl was designed from the ground up to indoctrinate it's programmers into performing unnatural sexual acts -- having two colons so closely together is clearly a reference to the perverse sickening act of "colon kissing," whereby two homosexual queers spread their buttocks wide, pressing their filthy torn sphincters together. They then share small round objects like marbles or golfballs by passing them from one rectum to another using muscle contraction alone. This is also referred to in programming 'circles' as "Parameter Passing".
And PHP stands for Perverted Homosexual Penetration. Didn't you know?
Well, I don't know about terraforming Mars, but I DO know that homosexual Linux Advocates have been probing Uranus for years.
*sniff* That brings a tear to my eye. Thank you once more for your kind support. I have taken faith in the knowledge that I am doing the Good Lord's work, but it is encouraging to know that I am helping out the common man here.
However, I should be cautious about revealing your name 'Cerberus' on such a filthy den of depravity as Slashdot. It is a well known fact that the 'Kerberos' documentation from Microsoft is a detailed manual describing, in intimate, exacting detail, how to sexually penetrate a variety of unwilling canine animals; be they domesticated, wild, or mythical. Slashdot posters have taken great pleasure in illegally spreading this documentation far and wide, treating it as an "extension" to the Linux "Sauce Code," for the sake of "interoperability." (The slang term they use for non-consensual intercourse - their favourite kind.)
In fact, sick twisted Linux deviants are known to have LAN parties, (Love of Anal Naughtiness, needless to say.), wherein they entice a stray dog, known as the "Samba Mount," into their homes. Up to four of these filth-sodden blasphemers against nature take turns to plunge their erect, throbbing, uncircumcised members, conkers-deep, into the rectum, mouth, and other fleshy orifices of the poor animal. Eventually, the "Samba Mount" collapses due to "overload," and needs to be "rebooted." (i.e., kicked out into the street, and left to fend for itself.) Many Linux users boast about their "uptime" in such situations.
If only indeed. You can help our brave cause by moderating this message up as often as possible. I recommend +1, Underrated, as that will protect your precious Karma in Metamoderation. Only then can we break through the glass ceiling of Homosexual Slashdot Culture. Is it any wonder that the new version of Slashcode has been christened "Bender"???
If we can get just one of these postings up to at least '+1,' then it will be archived forever! Others will learn of our struggle, and join with us in our battle for freedom!
I am compelled to document the foulness and carnal depravity that is Linux, in order that we may prepare ourselves for the great holy war that is to follow. It is my solemn duty to peel back the foreskin of ignorance and apply the wire brush of enlightenment.
I could make an arrogant, childish comment along the lines of "Every time someone asks for 2.0, I won't release it for another 24 hours," but the truth of the matter is that I'm quite nervous of releasing a "number two," as I can guarantee some filthy shit-slurping Linux pervert would want to suck it straight out of my anus before I've even had chance to wipe.
I sincerely hope you're Natalie Portman.
What the fuck?
Well bugger me!
Fuck right off!
IMPORTANT: This message needs to be heard (Not HURD, which is an acronym for Huge Unclean Rectal Dilator) across the whole community, so it has been released into the Public Domain. You know, that licence that we all had before those homoerotic crypto-fascists came out with the GPL (Gay Penetration License, according to geekacronyms.org) that is no more than an excuse to see who's got the biggest feces-encrusted cock. I would have put this up on Freshmeat, but that name is KNOWN to be a euphemism for the tight rump of a young boy.
Come to think of it, the whole concept of "Source Control" unnerves me, because it sounds a bit like "Sauce Control," which is a description of the homosexual practice of holding the base of the cock shaft tightly upon the point of ejaculation, thus causing a build up of semenal fluid that is only released upon entry into an incision made into the base of the receiver's scrotum. And "Open Sauce" is the act of ejaculating into another mans face or perhaps a biscuit to be shared later. Obviously, "Closed Sauce" is the only Christian thing to do, as evidenced by the fact that it is what Cathedrals are all about.
Contributors: (although not to the eternal game of "soggy biscuit" that open "sauce" development has become) Anonymous Coward, Anonymous Coward, phee, Anonymous Coward, mighty jebus, Anonymous Coward, Anonymous Coward, double_h, Anonymous Coward, Eimernase, Anonymous Coward, Anonymous Coward, Anonymous Coward, Anonymous Coward, Anonymous Coward, Anonymous Coward, Anonymous Coward, Anonymous Coward, The WIPO Troll, FreeWIPO, Bring BackATV. Further contributions are welcome.
Current changes: This version is based on the all-too-rare backup copy sent to FreeWIPO by 'Bring BackATV' as plain text. Re-reformatted everything, added all links back in (that we could match from the previous version), many new ones (Slashbot bait links). Even more spelling fixed. Additional stuff done in preparation for the future.
Previous changes: Yet more changes added. Spelling fixed. Feedback added. Explanation of 'distro' system. 'Mount Point' syntax described. More filth regarding 'man' and Slashdot. Yet more fucking spelling fixed. 'Fetchmail' uncovered further. More Slashbot baiting. Apache exposed. Distribution licence at foot of document.
ANUX -- A full Linux distribution... Up your ass!
--Metrollica
One point he makes towards the bottom is the controversy behind actually de-referencing the namespace URIs. Right now as far as I can tell, namespaces do you no good by themselves. You still have to embed any outside XML into your application or write code to dereference the URI anyhow.
Once de-referencing URIs is built into parsers I think namespaces (and XML in general) will be much more useful.
Mark
punk rock has fucking died.
move along. nothing to see.
Could you explain me what a C.L.I.T. is? I am a stinky linux geek user and therefore i have no experience with every other things around me.
You and your overrated lifestyle suck ass!!!!
I wonder how long it will take before Java fans and anti-.NET crusaders realize that VB.NET and C#.NET are used in the above examples?
XML namespaces are touted as a wonderful new invention. Unfortunately they're just a non backwards compatible copy of what SGML could already do with the CONCUR declaration.
SGML already had: <(p.anthology)page> long before XML was even dreamed of.
*yawn*
--Azaroth
Some good stuff in here. A good read for anyone using serious XML.
/. front page.
I kindof see the point of it being a bit longish for the
How 'bout a link to a more permanant article source/website?
My $0.02 will always be worth more than your â0.02, so
lol, my previous post was just rated flamebait Eat that, logged-in-trolls!
n/m
"It's not knew"
No, but apparently english is to you.
I suggest refraining from talking about teknikul stuf until you can communicate via a means other than pigeon english.
Thanks, and have a great day.
Linux Planet has a great tutorial section if you're interested.
--Metrollica
Nah....
(n/m)
I hope people will look past the C# code in the write up and look at the useful information. Now if some one would post a good article detailing the ins and outs of XSL and XPath, that would be good. If I wasn't lazy, I'd write one. But I'm way too lazy and have real work to do.
A /. troll population divided will fall. Repent.
Namespaces and all that are nice, but surly they should make XSL more functional first.
,but XSL provides no weasy way of formatting this data into somthing usefull.
,counter );
If the initial idea of XML/XSL was to make data protable and transformable they should have been designed with more functionality to do this.
1 good example is Binary operations, all kinds of data is store like this especially in legacy or the mainframe systems i've been working with
You can script a # to binary function but you have to use nasty itterative functions instead of loops
e.g. in sudo stuff
myfunction(somthingusefull,counter,limit){
if(counter limit){
bytepos = bytepos *2;
counter = counter +1;
dosomthingwith(somthingusefull);
myfunction(bytepos
}
}
Well i'm sure you get my drift so I'll leave it there for now.
thank God the internet isn't a human right.
XML was intended to be a simple and actually useful subset of SGML. and it was in the beginning. then we got namespaces and the long slide into overdesigned bloated academic hell began. the same thing has happened to everything XML touches. look at web services (shudders). or maybe it's just the W3C. all nice in theory but it's turned into a three-ringed circus for people with way too much time on their hands and brains too big to grasp the pragmatic, useful, elegant or simple aspects of technology implementations.
nm
Oh, wait. Here is some sample XML.
Lord Of The Rings? That's better. All is well.
An intelligent, well-written technical article?? Here?? I thought I was at K5 for a minute!
...this nice little, uncomplicated language? xml parsers were supposed to be so simple to write that any junio compsci student could write one. But that's before xpath, etc, jumped on the bandwagon. I agree xml is great. It beats the shit out of reading flat files from some EBCDIC-dumpy-ass os390 mainframe. Christ, even Natural has an xml parser.
XML is a becoming a very powerful, indeed, magical language. Perhaps one day before long, it'll have forloops and a query language (oops, xpath, already exists). Why before long, we might just have a reference counting garbage collector for those XML namespaces. Then maybe a cyclicle garbage collector.
</wheelrant>
-- Ken Kinder ken@_nospam_kenkinder.com http://kenkinder.com/
This article explores the ins and outs of XML namespaces and their ramifications on a number of XML technologies that support namespaces. What follows is a shortened version of my first Extreme XML column.
Overview of XML NamespacesAs XML usage on the Internet became more widespread, the benefits of being able to create markup vocabularies that could be combined and reused similarly to how software modules are combined and reused became increasingly important. If a well defined markup vocabulary for describing coin collections, program configuration files, or fast food restaurant menus already existed, then reusing it made more sense than designing one from scratch. Combining multiple existing vocabularies to create new vocabularies whose whole was greater than the sum of its parts also became a feature that users of XML began to require.
However, the likelihood of identical markup, specifically XML elements and attributes, from different vocabularies with different semantics ending up in the same document became a problem. The very extensibility of XML and the fact that its usage had already become widespread across the Internet precluded simply specifying reserved elements or attribute names as the solution to this problem.
The goal of the W3C XML namespaces recommendation was to create a mechanism in which elements and attributes within an XML document that were from different markup vocabularies could be unambiguously identified and combined without processing problems ensuing. The XML namespaces recommendation provided a method for partitioning various items within an XML document based on processing requirements without placing undue restrictions on how these items should be named. For instance, elements named <template>, <output>, and <stylesheet> can occur in an XSLT stylesheet without there being ambiguity as to whether they are transformation directives or potential output of the transformation.
An XML namespace is a collection of names, identified by a Uniform Resource Identifier (URI) reference, which are used in XML documents as element and attribute names.
Namespace DeclarationsA namespace declaration is typically used to map a namespace URI to a specific prefix. The scope of the prefix-namespace mapping is that of the element that the namespace declaration occurs on as well as all its children. An attribute declaration that begins with the prefix xmlns: is a namespace declaration. The value of such an attribute declaration should be a namespace URI which is the namespace name.
Here is an example of an XML document where the root element contains a namespace declaration that maps the prefix bk to the namespace name urn:xmlns:25hoursaday-com:bookstore and its child element contains an inventory element that contains a namespace declaration that maps the prefix inv to the namespace name urn:xmlns:25hoursaday-com:inventory-tracking.
<bk:bookstore xmlns:bk="urn:xmlns:25hoursaday-com:bookstore"><bk:book>
<bk:title>Lord of the Rings</bk:title>
<bk:author>J.R.R. Tolkien</bk:author>
<inv:inventory status="in-stock" isbn="0345340426"
xmlns:inv="urn:xmlns:25hoursaday-com:inventory-tr
</bk:book>
</bk:bookstore>
In the above example, the scope of the namespace declaration for the urn:xmlns:25hoursaday-com:bookstore namespace name is the entire bk:bookstore element, while that of the urn:xmlns:25hoursaday-com:inventory-tracking is the inv:inventory element. Namespace aware processors can process items from both namespaces independently of each other, which leads to the ability to do multi-layered processing of XML documents. For instance, RDDL documents are valid XHTML documents that can be rendered by a Web browser but also contain information using elements from the http://www.rddl.org namespace that can be used to locate machine readable resources about the members of an XML namespace.
It should be noted that by definition the prefix xml is bound to the XML namespace name and this special namespace is automatically predeclared with document scope in every well-formed XML document.
Default NamespacesThe previous section on namespace declarations is not entirely complete because it leaves out default namespaces. A default namespace declaration is an attribute declaration that has the name xmlns and its value is the namespace URI that is the namespace name.
A default namespace declaration specifies that every unprefixed element name in its scope be from the declaring namespace. Below is the bookstore example utilizing a default namespace instead of a prefix-namespace mapping.
<bookstore xmlns="urn:xmlns:25hoursaday-com:bookstore"><book>
<title>Lord of the Rings</bk:title>
<author>J.R.R. Tolkien</bk:author>
<inv:inventory status="in-stock" isbn="0345340426"
xmlns:inv="urn:xmlns:25hoursaday-com:inventory-tr
</book>
</bookstore>
All the elements in the above example except for the inv:inventory element belong to the urn:xmlns:25hoursaday-com:bookstore namespace. The primary purpose of default namespaces is to reduce the verbosity of XML documents that utilize namespaces. However, using default namespaces instead of utilizing explicitly mapped prefixes for element names can be confusing because it is not obvious that the elements in the document are namespace scoped.
Also, unlike regular namespace declarations, default namespace declarations can be undeclared by setting the value of the xmlns attribute to the empty string. Undeclaring default namespace declarations is a practice that should be avoided because it may lead to a document that has unprefixed names that belong to a namespace in one part of the document, but don't in another. For example, in the document below only the bookstore element is from the urn:xmlns:25hoursaday-com:bookstore while the other unprefixed elements have no namespace name.
<bookstore xmlns="urn:xmlns:25hoursaday-com:bookstore"><book xmlns="">
<title>Lord of the Rings</bk:title>
<author>J.R.R. Tolkien</bk:author>
<inv:inventory status="in-stock" isbn="0345340426"
xmlns:inv="urn:xmlns:25hoursaday-com:inventory-tr
</book>
</bookstore>
This practice should be avoided because it leads to extremely confusing situations for readers of the XML document. For more information on undeclaring namespace declarations, see the section on Namespaces Future.
Qualified and Expanded NamesA qualified name, also known as a QName, is an XML name called the local name optionally preceded by another XML name called the prefix and a colon (':') character. The XML names used as the prefix and the local name must match the NCName production, which means that they must not contain a colon character. The prefix of a qualified name must have been mapped to a namespace URI through an in-scope namespace declaration mapping the prefix to the namespace URI. A qualified name can be used as either an attribute or element name.
Although QNames are important mnemonic guides to determining what namespace the elements and attributes within a document are derived from, they are rarely important to XML aware processors. For example, the following three XML documents would be treated identically by a range of XML technologies including, of course, XML schema validators.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:complexType id="123" name="fooType"/>
</xs:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType id="123" name="fooType"/>
</xsd:schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<complexType id="123" name="fooType"/>
</schema>
The W3C XML Path Language recommendation describes an expanded name as a pair consisting of a namespace name and a local name. A universal name is an alternate term coined by James Clark to describe the same concept. A universal name consists of a namespace name in curly braces and a local name. Namespaces tend to make more sense to people when viewed through the lens of universal names. Here are the three XML documents from the previous example with the QNames replaced by universal names. Note that the syntax below is not valid XML syntax.
<{http://www.w3.org/2001/XMLSchema}schema>&n bsp;<{http://www.w3.org/2001/XMLSchema}complexType id="123" name="fooType"/>
</{http://www.w3.org/2001/XMLSchema}schema>
<{http://www.w3.org/2001/XMLSchema}schema>&n bsp;
<{http://www.w3.org/2001/XMLSchema}complexType id="123" name="fooType"/>
</{http://www.w3.org/2001/XMLSchema}schema>
<{http://www.w3.org/2001/XMLSchema}schema>&n bsp;
<{http://www.w3.org/2001/XMLSchema}complexType id="123" name="fooType"/>
</{http://www.w3.org/2001/XMLSchema}schema>
To many XML applications, the universal name of the elements and attributes in an XML document are what is important, and not the values of the prefixes used in specific QNames. The primary reason the Namespaces in XML recommendation does not take the expanded name approach to specifying namespaces is due to its verbosity. Instead, prefix mappings and default namespaces are provided to save us all from developing carpal tunnel syndrome from typing namespace URIs endlessly.
Namespaces and AttributesNamespace declarations do not apply to attributes unless the attribute's name is prefixed. In the XML document shown below the title attribute belongs to the bk:book element and has no namespace while the bk:title attribute has urn:xmlns:25hoursaday-com:bookstore as its namespace name. Note that even though both attributes have the same local name the document is well formed.
<bk:bookstore xmlns:bk="urn:xmlns:25hoursaday-com:bookstore"><bk:book title="Lord of the Rings, Book 3" bk:title="Return of the King"/>
</bk:bookstore>
In the following example, the title attribute still has no namespace and belongs the book element even though there is a default namespace specified. In other words, attributes cannot inherit the default namespace.
<bookstore xmlns="urn:xmlns:25hoursaday-com:bookstore"><book title="Lord of the Rings, Book 3"
</bookstore>
Namespace URIs
A namespace name is a Uniform Resource Identifier (URI) as specified in RFC 2396. A URI is either a Uniform Resource Locators (URLs) or a Uniform Resource Names (URNs). URLs are used to specify the location of resources on the Internet, while URNs are supposed to be persistent, location-independent identifiers for information resources. Namespace names are considered to be identical only if they are the same character for character (case-sensitive). The primary justification for using URIs as namespace names is that they already provide a mechanism for specifying globally unique identities.
The XML namespaces recommendation states that namespace names are only to act as unique identifiers and do not have to actually identify network retrievable resources. This has led to much confusion amongst authors and users of XML documents, especially since the usage of HTTP based URLs as namespace names has grown in popularity. Because many applications convert such URIs to hyperlinks, it is irritating to many users that these "links" do not lead to Web pages or other network retrievable resource. I remember one user who likened it to being given a fake phone number in a social situation.
One solution to avoid confusing users is to use a namespace-naming schema that does not imply network retrievability of the resource. I personally use the urn:xmlns: scheme for this purpose and create namespace names similar to urn:xmlns:25hoursaday-com when authoring XML documents for personal use. The problem with homegrown namespace URIs is that they may run counter to the intent of the Names in XML recommendation by not being globally unique. I get around the globally unique requirement by using my personal domain name http://www.25hoursaday.com as part of the namespace URI.
Another solution is to leave a network retrievable resource at the URI that is the namespace name, such as is done with the XSLT and RDDL namespaces. Typically, such URIs are actually HTTP URLs. A good way to name such URLs is by using the format favored by the W3C, which is as follows:
http://my.domain.example.org/product/[year/month]See the section on Namespaces and Versioning for more information on using similarly structured namespace names as a versioning mechanism.
DOM, XPath, and the XML Information Set on NamespacesThe W3C has defined a number of technologies that provide a data model for XML documents. These data models are generally in agreement, but sometimes differ in how they treat various edge cases due to historic reasons. Treatment of XML namespaces and namespace declarations is an example of an edge case that is treated differently in the three primary data models that exist as W3C recommendations. The three data models are the XPath data model, the Document Object Model (DOM), and the XML information set.
The XML information set (XML infoset) is an abstract description of the data in an XML document and can be considered to be the primary data model for an XML document. The XPath data model is a tree-based model that is traversed when querying an XML document and is similar to the XML information set. The DOM precedes both data models but is also similar to both data models in a number of ways. Both the DOM and the XPath data model can be considered to be interpretations of the XML infoset.
Namespaces in the Document Object Model (DOM)The XML namespace section of the DOM Level 3 specification considers namespace declarations to be regular attribute nodes that have http://www.w3.org/2000/xmlns/ as their namespace name and xmlns as their prefix or qualified name.
Elements and attributes in the DOM have a namespace name that cannot be altered after they have been created regardless of whether their location within the document changes or not.
Namespaces in the XPath Data ModelThe W3C XPath recommendation does not consider namespace declarations to be attribute nodes and does not provide access to them in that capacity. Instead, in XPath every element in an XML document has a number of namespace nodes that can be retrieved using the XPath namespace navigation axis.
Each element in the document has a unique set of namespace nodes for each namespace declaration in scope for that particular element. Namespace nodes are unique to each element in that namespace. Thus namespace nodes for two different elements that represent the same namespace declaration are not identical.
Namespaces in the XML Information SetThe XML infoset recommendation considers namespace declarations to be attribute information items.
In addition, similar to the XPath data model, each element information item in an XML document's information set has a namespace information item for each namespace that is in scope for the element.
XPath, XSLT and NamespacesThe W3C XML Path Language also known as XPath is used to address parts of an XML document and is used in a number of W3C XML technologies including XSLT, XPointer, XML Schema, and DOM Level 3. XPath uses a hierarchical addressing mechanism similar to that used in file systems and URLs to retrieve pieces of an XML document. XPath supports rudimentary manipulation of strings, numbers, and Booleans.
XPath and NamespacesThe XPath data model treats an XML document as a tree of nodes, such as element, attribute, and text nodes, where the name of each node is a combination of its local name and its namespace name (that is, its universal or expanded name).
For element and attribute nodes without namespaces, performing XPath queries is fairly straightforward. The following program, which can be used to query XML documents using the command line, shall be used to demonstrate the impact of namespaces on XPath queries.
using System.Xml.XPath;using System.Xml;
using System;
using System.IO;
class XPathQuery{
public static string PrintError(Exception e, string errStr){
if(e == null)
return errStr;
else
return PrintError(e.InnerException, errStr + e.Message );
}
public static void Main(string[] args){
if((args.Length == 0) || (args.Length % 2)!= 0){
Console.WriteLine("Usage: xpathquery source query <zero or more
prefix and namespace pairs>");
return;
}
try{
XmlDocument doc = new XmlDocument();
doc.Load(args[0]);
XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);
for(int i=2; i < args.Length; i+= 2)
nsMgr.AddNamespace(args[i], args[i + 1]);
XmlNodeList nodes = doc.SelectNodes(args[1], nsMgr);
foreach(XmlNode node in nodes)
Console.WriteLine(node.OuterXml + "\n\n");
}catch(XmlException xmle){
Console.WriteLine("ERROR: XML Parse error occured because " +
PrintError(xmle, null));
}catch(FileNotFoundException fnfe){
Console.WriteLine("ERROR: " + PrintError(fnfe, null));
}catch(XPathException xpath){
Console.WriteLine("ERROR: The following error occured while querying
the document: "
&n bsp; + PrintError(xpath, null));
}catch(Exception e){
Console.WriteLine("UNEXPECTED ERROR" + PrintError(e, null));
}
}
}
Given the following XML document that does not declare any namespaces, queries are fairly straightforward as seen in the examples following the code.
<?xml version="1.0" encoding="utf-8" ?><bookstore>
<book genre="autobiography">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
</bookstore>
Example 1
xpathquery.exe bookstore.xml /bookstore/book/title
Selects all the title elements that are children of the book element whose parent is the bookstore element, which returns:
<title>The Autobiography of Benjamin Franklin</title>
<title>The Confidence Man</title>
xpathquery.exe bookstore.xml //@genre
Select all the genre attributes in the document and returns:
genre="autobiography"
genre="novel"
xpathquery.exe bookstore.xml //title[(../author/first-name = 'Herman')]
Selects all the titles where the author's first name is "Herman" and returns:
<title>The Confidence Man</title>
However, once namespaces are added to the mix, things are no longer as simple. The file below is identical to the original file except for the addition of namespaces and one attribute to one of the book elements.
<bookstore xmlns="urn:xmlns:25hoursaday-com:bookstore"><book genre="autobiography">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<bk:book genre="novel" bk:genre="fiction"
xmlns:bk="urn:xmlns:25hoursaday-com:bookstore">
<bk:title>The Confidence Man</bk:title>
<bk:author>
<bk:first-name>Herman</bk:first-name>
<bk:last-name>Melville</bk:last-name>
</bk:author>
<bk:price>11.99</bk:price>
</bk:book>
</bookstore>
Note that the default namespace is in scope for the whole XML document, while the namespace declaration that maps the prefix bk to the namespace name urn:xmlns:25hoursaday-com:bookstore is in scope for the second book element only. Example 2
xpathquery.exe bookstore.xml /bookstore/book/title
Selects all the title elements that are children of the book element whose parent is the bookstore element, which returns NO RESULTS.
xpathquery.exe bookstore.xml //@genre
Selects all the genre attributes in the document and returns:
genre="autobiography"
genre="novel"
xpathquery.exe bookstore.xml //title[(../author/first-name = 'Herman')]
Selects all the titles where the author's first name is "Herman," which returns NO RESULTS.
The first query returns no results because unprefixed names in an XPath query apply to elements or attributes with no namespace. There are no bookstore, book, or title elements in the target document that have no namespace. The second query returns all attribute nodes that have no namespace. Although namespace declarations are in scope for both attribute nodes returned by the query, they have no namespace because namespace declarations do not apply to attributes with unprefixed names. The third query returns no results for the same reasons the first query returns no results.
The way to perform namespace-aware XPath queries is to provide a prefix to namespace mapping to the XPath engine, then use those prefixes in the query. The prefixes provided do not need to be the same as the namespace to prefix mappings in the target document, and they must be non-empty prefixes. Example 3
xpathquery.exe bookstore.xml /b:bookstore/b:book/b:title b urn:xmlns:25hoursaday-com:bookstore
Select all the title elements that are children of the book element whose parent is the bookstore element and returns the following:
<title xmlns="urn:xmlns:25hoursaday-com:bookstore">The Autobiography of Benjamin Franklin</title>
<bk:title xmlns:bk="urn:xmlns:25hoursaday-com:bookstore"> The Confidence Man</bk:title>
xpathquery.exe bookstore.xml //@b:genre b urn:xmlns:25hoursaday-com:bookstore
Selects all the genre attributes from the "urn:xmlns:25hoursaday-com:bookstore" namespace in the document that returns:
bk:genre="fiction"
xpathquery.exe bookstore.xml //bk:title[(../bk:author/bk:first-na me = 'Herman')] bk urn:xmlns:25hoursaday-com:bookstore
Selects all the titles where the author's first name is "Herman" and returns:
<bk:title xmlns:bk="urn:xmlns:25hoursaday-com:bookstore"> The Confidence Man</bk:title>
For more information on using XPath, read Aaron Skonnard's article Addressing Infosets with XPath and view the examples at the ZVON.org XPath tutorial.
XSLT and NamespacesThe W3C XSL transformations (XSLT) recommendation describes an XML-based language for transforming XML documents into other XML documents. XSLT transformations, also known as XML style sheets, utilize patterns (XPath) to match aspects of the target document. Upon matching nodes in the target document, templates that specify the output of a successful match can be instantiated and used to transform the document.
Support for namespaces is tightly integrated into XSLT, especially since XPath is used for matching nodes in the source document. Using namespaces in your XPath expressions inside XSLT is much easier than using the DOM.
The example that follows contains:
A program for use in executing transforms from the command line.
An XSLT stylesheet that prints all the title elements from the urn:xmlns:25hoursaday-com:bookstore namespace in the source XML document when run against the bookstore document from the urn:xmlns:25hoursaday-com:bookstore namespace.
The resulting output. Program Imports System.Xml.Xsl
--Metrollica
okay, im at a loss for words.
That was WAY too informative for Slashdot. Can we please get some more stories by Katz telling us about the sociological ramifications of evil corporations oppressing the geek youth of america?
And your proud to admit u read k5, u pansy french jew?
He is from K5. He posted the link to MSDN article yesterday in the diary section. So it is really a Microsoft article. And a good one at that.
This is the first time I've seen an article on /., as opposed to comments on one written somewhere else.
It's against Slashdot's norm -- a news site -- but I think it makes for a great idea. It lets me read a single source for both tech news and a little bleeding-edge knowledge. Although I dislike the karma whore article posting phenomenon, I love reading those articles inline.
Truth be told, this also helps flesh out a university education. Although I learned a lot in my specialist degree, I became a well-rounded and knowledgable geek only through outside interests: clicking on Slashdot links, messing with Linux, etc. Until now, I didn't think about "XML Namespaces and how they affect XPath and XSLT," but now I can discuss it with a clue.
Keep it up guys -- this improves the value of Slashdot immensely. At the very least, give this concept a section of its own (articles.slashdot.org?) with links from the main page.
P.S: Why not post some articles on argument fallacies and how to answer lame questions yourself.
It all goes downhill from first post
You and your over-used mother suck ass
to reunite all trolls of slashdot! Then we should call us "United Trolls"! From now on i will claim first posts in the name of United Trolls! Lets do it together!
You and your inbreb, cum-guzzling family suck ass!!
Just as interesting and informative and with just a link to the information (sorry no copy-paste karma net). Here Paul Cornell shows you how to create COM add-ins for Microsoft Office using Visual Basic .NET.
.mda, .pwz, .wll, and .xla; some examples of Office application-specific add-ins are the Analysis ToolPak and the Solver Add-In for Microsoft Excel. Starting with Microsoft Office 2000, COM add-ins allow you to create add-ins that span multiple Office applications. This allows you to write code that is common across many applications, yet at the same time allows you to write code specific to each application that hosts the COM add-in."
From the Article:"Before COM add-ins were invented, you could only create Office application-specific add-ins (except Microsoft Outlook® and Microsoft FrontPage®). These application-specific add-ins have file extensions such as
If we don't fight for ourselves no one will.
i read this entire slashdot posting in under 3 minutes. Now i'm making a smartass comment about shit i dont understand. woo woo - im not doing the work i am overpaid for; But i'll whine and cry i dont get paid enough come pay day! woo woo - monkey piss mofo's!!
DinK the DumBAsS
moderated. (You can read everything, even moderated posts, by adjusting your
threshold on the User Preferences Page)
Problems regarding accounts or comment posting should be sent to
CowboyNeal.
You will win success in whatever calling you adopt.
All trademarks and copyrights on this
page are owned by their respective owners. Comments
are owned by the Poster.
The Rest © 1997-2002 OSDN.
[
home |
awards |
contribute story |
older articles |
OSDN |
advertise |
self serve ad system |
about |
terms of service |
privacy |
faq ]
Word Viewer 97
.rtf file extension, Windows uses the default application to open the file.
You can use Microsoft Word Viewer 97 to open and view Word documents. Word Viewer 97 includes the following features:
Online Layout View for easy reading of online documents, including those with background colors and textures
Document Map for point-and-click navigation through longer documents
Hyperlink navigation to open any hyperlink in a document with your installed browser
Although you cannot edit files in Word Viewer 97, you can copy information from a document to other applications.
Microsoft Word Viewer 97 follows hyperlinks located in Word documents. Word Viewer 97 automatically configures itself as a helper application for Netscape Navigator and Microsoft Internet Explorer. This allows users to automatically view Word documents that are linked to HTML pages on a LAN or on the Web in the user's default Web browser.
This product is freeware. You can copy and distribute Word Viewer to your friends and co-workers or post it on public electronic bulletin boards. Word Viewer 97 is also available from the Microsoft Download Service at (425) 936-6735.
System Requirements
A personal computer with a 486 or later processor
Microsoft Windows 95 or later operating system or Microsoft Windows NT® 3.51 Workstation or later operating system
4 MB of RAM for Windows 95 (8 MB recommended)
12 MB of RAM for Windows NT Workstation
7 MB of hard disk space (9 MB free for installation only)
VGA or higher-resolution video adapter
Microsoft Mouse or compatible pointing device
To install Word Viewer 97:
You can print this page to use as a reference when you are offline.
Open the \Docs directory on the Exchange 2000 Server CD and double-click wd97vwr32.exe.
During installation, Word Viewer 97 Setup prompts you for a folder in which to install Word Viewer. Click Change Folder and select the path for installing Word Viewer 97 or click OK to accept the default folder.
Click Install.
If Word Viewer Setup detects Word version 6.x or later on your system, Setup prompts you to choose which application opens Word documents by default. When you double-click on a file with a
Choosing Open with Word causes Windows to use Word to open Word files.
Choosing Open with Viewer causes Word Viewer 97 to open Word files.
Note: If you select Open with Viewer and you want to restore Word as the default Word document handler, you may have to uninstall Word Viewer and then start Word so that it can restore its Registry information. For more information see "Installation and Maintenance" in the Word Viewer 97 Readme.doc installed with the viewer.
To use Word Viewer 97:
On the Start menu, point to Programs, and then click Word Viewer 97.
On the File menu, click Open and then double-click the file you want to open.
To uninstall Word Viewer 97:
On the Start menu, point to Settings and click Control Panel. Double-click Add/Remove Programs.
In the list on the Install/Uninstall tab, select Microsoft Word Viewer 97, and click Add/Remove.
To remove the application, click Yes.
To finish removing the program, click OK.
News for Turds
Word Viewer 97 You can use Microsoft Word Viewer 97 to open and view Word documents. Word Viewer 97 includes the following features: Online Layout View for easy reading of online documents, including those with background colors and textures Document Map for point-and-click navigation through longer documents Hyperlink navigation to open any hyperlink in a document with your installed browser Although you cannot edit files in Word Viewer 97, you can copy information from a document to other applications.
Microsoft Word Viewer 97 follows hyperlinks located in Word documents. Word Viewer 97 automatically configures itself as a helper application for Netscape Navigator and Microsoft Internet Explorer. This allows users to automatically view Word documents that are linked to HTML pages on a LAN or on the Web in the user's default Web browser.
This product is freeware. You can copy and distribute Word Viewer to your friends and co-workers or post it on public electronic bulletin boards. Word Viewer 97 is also available from the Microsoft Download Service at (425) 936-6735.
System Requirements A personal computer with a 486 or later processor Microsoft Windows 95 or later operating system or Microsoft Windows NT® 3.51 Workstation or later operating system 4 MB of RAM for Windows 95 (8 MB recommended) 12 MB of RAM for Windows NT Workstation 7 MB of hard disk space (9 MB free for installation only) VGA or higher-resolution video adapter Microsoft Mouse or compatible pointing device
To install Word Viewer 97: You can print this page to use as a reference when you are offline.
Open the \Docs directory on the Exchange 2000 Server CD and double-click wd97vwr32.exe. During installation, Word Viewer 97 Setup prompts you for a folder in which to install Word Viewer. Click Change Folder and select the path for installing Word Viewer 97 or click OK to accept the default folder. Click Install. If Word Viewer Setup detects Word version 6.x or later on your system, Setup prompts you to choose which application opens Word documents by default. When you double-click on a file with a .rtf file extension, Windows uses the default application to open the file.
Choosing Open with Word causes Windows to use Word to open Word files.
Choosing Open with Viewer causes Word Viewer 97 to open Word files.
Note: If you select Open with Viewer and you want to restore Word as the default Word document handler, you may have to uninstall Word Viewer and then start Word so that it can restore its Registry information. For more information see "Installation and Maintenance" in the Word Viewer 97 Readme.doc installed with the viewer.
To use Word Viewer 97: On the Start menu, point to Programs, and then click Word Viewer 97. On the File menu, click Open and then double-click the file you want to open.
To uninstall Word Viewer 97: On the Start menu, point to Settings and click Control Panel. Double-click Add/Remove Programs. In the list on the Install/Uninstall tab, select Microsoft Word Viewer 97, and click Add/Remove. To remove the application, click Yes. To finish removing the program, click OK.
-- You are such a fucking fag
What is this?
It's not knew, it's somewhat informative. It's very, very basic.
So what is the point?
I may be biased being the author of the article but don't think the article is pointless. As you point out XML namespaces are a basic aspect of XML yet their ramifications are not understood by many users of XML especially when it comes to interactions with other XML related technologies. My motivation for writing the article was because I kept seeing people (including supposed experts) show a fundamental lack of understanding of how XML namespaces work especially default namespaces and how the different XML data models interact and cohabit. For example the differences between the XML infoset, XPath data model and DOM are little known by many users of XML and in fact many people do not know about all 3.
Secondly, the section on namespace caveats highlight errors in thinking I've seen many experienced users of XML not just novices.
However, many people who implement XML technologies and W3C members thought that the article was worthwhile. Now it may be that you are an experienced user of XML and this article is a waste of your time and if so I apologize for the time you lost reading the article.
Thanks for your comments.
*yaaawwwwnnnnn*
I know the bison and yacc people have been struggling coming up with an L1 grammar for this for years, but maybe XSLT has the answer.
Can it transform Visual Basic code into something taken seriously?
[% slash_sig_val.text %]
So you turned on the "filter Jon Katz stories" too, huh? :-)
psxndc
The emacs religion: to be saved, control excess.
What is it about bookstores that make them ideal for explaining how a programming language, database or markup language work? I must have seen 100 different books and online articles that describe what they are trying to teach with a bookstore as the example.
Not that I'm complaining(being that I program for a bookstore). Its just that there seems to be a disproportionate number of bookstore programming examples compared to other types of businesses. Personally, I'd like to see more manufacturing plants(hospitals, casinos, stock markets, etc).
No, Thursday's out. How about never - is never good for you?
This new XML technology is the perfect standard for the Open Source community to embrace. With their dedication and experience, the millions of developers in the community can extend this XML.
We should try to educate the public that Open Source is the only way to go. Only then will we be able to escape the stranglehold that Eudora has on the e-mail market.
bling bling
Don't assume everyone knows as much as you do and
critisize on that basis!
I found it re-iterated a lot of points that I learned a year ago myself. But that doesn't mean everyone would agree. XML is still pretty new to a lot of people and anyone who reads this not knowing about XML and namespaces is going to gain a lot.
The only crtisism I have of the article is that it doesn't include enough pointers to bibliography and 'learn more here' sources like specific pages on w3c.org or other tutorials on the net. Someone who starts to understand this stuff from the article will want to have a list of resources to continue learning...
Jack William Bell
- -
Are you an SF Fan? Are you a Tru-Fan?
I certainly agree with the author that people should avoid using default namespaces and then clearing the namespaces with an empty namespace declaration. But I would go further to say that you should avoid default namespaces altogether if you intend your XML to be human readable.
And, in my humber opinion, keeping it human readable is the main reason to use XML in the first place. As a purely data-transfer medium it is far to bulky and requires too much CPU at each end. Even HTML query strings are faster to parse and convert to binary equivalents.
For machine to machine transfer we really need a binary XML standard. My understanding is that W3C is working on such...
Jack William Bell
- -
Are you an SF Fan? Are you a Tru-Fan?
i appreciate the time taken by the author to write an article to help others (even if the material is documented elsewhere). having different perspective on a given subject never hurt anyone. besides, he digested it and is now trying to make is simpler for some of us. hell, i know the basics of XML, XSL, and so on, but still find this namespace thing a little daunting.
The point is????
While the article is nice, it is referenced in the MSDN article! It is basically a rehash of that. So why not create a link or is Slashdot trying something new?
"You can't make a race horse of a pig"
"No," said Samuel, "but you can make very fast pig"
Suppose I have two systems. From system 1 I need to notify system 2 of personal data in the db that has been modified, so they can update their info.
First approach: select all persons that have been modified since last time. Write all their data to a file, one person per row, either using a fixed field width representation or a token seperated one. My C program that I wrote in 5 minutes creates the file, his Cobol program that he wrote in 1 hour reads the data, checks it and inserts it into his system.
Moron approach: Select all persons that have been modified since last time. Invent an XML schema to represent the data. Use 5 hours to write the DTD and the program the creates the XML data. Because we are feeling super-trendy, we send this by HTTP POST to (2) ala Soap.
To be cosher (2) now has to have a web server, CGI's that can handle Soap and store the parameters (in this case a file) on the file system, the ability to validate and parse the XML file, on a AS/400, no less.
Perhaps he has some helpful tools, perhaps he has to code a general XML parser himself, perhaps (more likely) he writes my name on the big list he has on the wall saying "People who *will* die".
He tries to get a XML system from the net in, say, Java, spends 5 days getting it to work, while coding the HTTP bits himself (which he does in only 40 hours. Yeah! What a coder!)
Unfortunately, his big-wigs have just been force-fed with XML propaganda, and have decided on their own, incompatible XML representation of the data... And he must write the XSL code and so forth.
(2) now moves my name, and those of his bosses, and some of the people at W3C from the "People who *will* die" list to the new "DIE DIE DIE DIEDIEDIE BLEED FUCKING PIGS!!!!!!!!!1!111!1!" list. And gets his AK-47 and goes out the door...
Net time/life cost:
Rational thinking: 1h5min
XML: 100+h plus 15 deaths and 150 wounded.
I choose to remain celibate, like my father and his father before him.
I find it ironic that so many people here bash Microsoft when one of their employees has been one of the best contributors of original content to Slashdot. Of course, the moment Bill Gates gets a story posted here is the moment I delete /. from my bookmarks.
Mas vale cholo, que mal acompañado.
Search on google, it is the definitive document on XML Namespaces.
Wow, a slashdot article with CeeSharp and VB as the example languages? Someone was asleep when they read that submission. Oh wait, the editors don't read past the first page before deciding to post or reject submissions.
How about an XML processing article using languages that slashdotters actually care about and write in -- Perl, PHP3, Java, C++, Python, etc.? We're not going to pop over to freshmeat and download the latest VB4Debian, you realize.
Slashdot's servers don't die out every five minutes.
Unfortunately, many people are getting excited about XML as a solution to data transfer, even though it's a bad choice for that problem. XML is intrinsically hierarchical, and hierarchies cannot represent any arbitrary data structure. There is no way to represent a graph as a tree; there is no way to represent a graph in XML. (Short of something like UUENCODING a binary representation of one, which defeats the whole point of XML.)
If we are to standardize on a data transfer and manipulation format, it should at least be able to represent arbitrary data.
Of course, K5 would have voted this story up, and has voted this author's stories up before. In fact, I believe he was the author of a fairly big successful cross-posted article about Microsoft .Net or some other technology.
Mas vale cholo, que mal acompañado.
XSL is a tool to transform XML documents. Of course it doesn't touch binary formats, that's outside it's scope.
XSLT transforms XML into XML. So what tool transforms Everything Else into XML?
Will I retire or break 10K?
Using an XML data source to hold all my games, with all the ratings from my friends, as well as photos. I dynamically allow the user to sort the games using different XSLT documents. I used to have an option for changing the look but I never liked any of the other looks.
Take a look at the application here
It requires a 6.0+ browser, Netscape 6.x (or 7), IE 6.x, Mozilla 0.9.8+, or IE 5.5 if you install the updated XSLT update (better to instead just upgrade your whole browser).
Joseph Elwell.
Keep it up guys -- this improves the value of Slashdot immensely. At the very least, give this concept a section of its own
Slashdot already has a section for Features.
It really feels like a kludge: why attributes doesn't inherit the namespace of the element?
I think it's because of "backward compatibility", which is too bad, because it's obvious that they would need something like namespace to prevent clashes.
*Sigh*
Don't feel bad about loosing karma points because of the stupid cap, you could be in my shoes. I had a karma of 97 before the cap, now it is down to 86. Eventually I will have 50 like everyone else. I *so* wanted to break 100 too, although I am not sure why. It isn't like /. karma gets me extra beer. But I felt that I had done rather well for someone who refused to karma whore and often took unpopular positions.
I never did understand the reason for the cap either -- to make all the kiddies with 20 karma feel better? But that's the way it goes...
Jack William Bell
- -
Are you an SF Fan? Are you a Tru-Fan?
We're not going to pop over to freshmeat and download the latest VB4Debian
Oh yes you are. GNOME Basic is an environment compatible with many applications written in the Visual Basic programming language.
Will I retire or break 10K?
If you have two systems, you can do whatever the heck you want with them. But some of us have to interact with more than that, and often, they aren't ours.
Lets say you have one market, and n businesses in that market. Like, say, accounting, or schools, or manufacturing. All of these entities need to interact with each other, and exchange data.
Now, they could take your approach, and create a custom excange format for every different interaction. That scales, well, not at all.
As an alternative, they could define a few formats using an identical grammar. Then all their systems could interact without having to write custom applications for each of the custom exchange formats that their accounting department escapee came up with.
Then they could fire the short-sighted hacks that "saved" all that time by not using XML in the first place.
--
You sure got a purty mouth...
(Project for today: write an XSLT processor that formats your hard drive.)
This whole tutorial relies on using M$'s XSLT processor; otherwise, this example won't work. Feh.
But I heard a good argument against your article:
SELECT * FROM books!
Buy a Nintendo DS Lite
Or pick your own favorite scripting language with decent XML libraries.
DNA just wants to be free...
... and DSSSL is just a dialect of it :)
Tired from semantical hard-coding? Try RDF-schema and ontologies.
Less is more !
In case the site gets slashdotted.
Oh wait...
Noooo not binary formats, 8 bit packed data, there just like strings or numbers. used by a lot of weird people in databases which export the bit packed value as a number in XML e.g.
145 = 10010001 in binary, which might translate to
Cheese, no relish, no cucumber, Brown Bap, No hair, No Spit, No Meat, Cooked.
thank God the internet isn't a human right.
I can spell how the hell i like,
My family can be traced back more that 800 years, Where are you from?
thank God the internet isn't a human right.
Transforms anything to anything?
thank God the internet isn't a human right.
Wow. This article is almost taken verbatim from the Microsoft Developer Network, including .NET examples written in C#. They didn't even hide it... the link to the MSDN article is in the second paragraph.
;)
Shouldn't there be 700 offended comments by Linux people about how Slashdot has sold out?
Fascinating.
Note to anyone who liked this article: This is why developers that use Microsoft stuff like using Microsoft stuff. MSDN has tons of well-written articles like this *all the time*, in addition to complete documentation of *everything* all in one place...
Saying that your data is stored in XML doesn't mean your data has any more intelligent structure than saying that your C program has its data stored with pointers.
Adding a namespace only confuses the issue more.
Intelligent data structures don't happen by accident, and anyone who claims that XML (and by extension, namespaces) makes everything easy is a moron.
Education is the silver bullet.
Might as well rate that MSDN page once you get bounced there. Feel free to give a rating based on general applicability, validity outside MSFT domain, for non-MS browsers, etc. I wonder what a Slashdot effect on the rating might be like...and if it might get re-adjusted by MSDN? :)
If the many companies in your scenario could agree on a XML schema, they could just as easily have agreed on a fixed column width represention or a tab separated representation. The difference is that, yes, it is easier to modify the format with XML, but using XML properly in a non-modern environment (ie. 80% of large companies) is hell, plain and simple.
Have you ever tried to write you own XML validator/parser from scratch? In less than one week? I have. It wasn't funny. The result sort of worked. With this schema. If the input files are flawless. Any future modifications to that program will be tape and solder style.
XML is a ridicoulously overcomplex method of intercommunication. The hype says that if you just represent the data as XML, then anyone can read it, anytime! They don't mention the fact that this is only true if large numbers of people agree to use the same schemas which in reality they don't. Everyone invents their own representations. Translating is utter hell.
In order to get XML to really deliver, people have to agree on common schemas for every different kind of application. Just as people have always had to agree on common data transfer formats! There is nothing new and nothing good, and it's all horribly inefficient and unnesecarily complicated and convoluted.
PS. If you could recomend a XML framework for SCO-Unix (OpenServer 5) I would be extatic.
I choose to remain celibate, like my father and his father before him.