[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Re: removing a specific namespace declaration


Subject: Re: [xsl] Re: removing a specific namespace declaration
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 08 Nov 2009 15:15:25 -0500

At 2009-11-08 11:41 -0800, tom a wrote:
The foo namespace usage is an unused artifact, so I just wanted to clean up the output.

Fine ... but just remember an unused namespace is supposed to be benign to XML-based applications.


It's still a little unclear to me why this approach requires a namespace declaration in the element (namespace="{namespace-uri(.)}"), as I would have thought the explicit copying of namespace nodes would have taken care of it,

What you say would be fine if every element in your data is prefixed, but that would not be true in the general case when you don't know what your users are doing with their data with respect to using or not using the default namespace. Nor is it the case in your test data:


At 2009-11-07 16:42 -0800, you wrote:
I'm trying to remove what I believe to be an unused namespace declaration from the output. eg:

Source:
<?xml version="1.0" encoding="ISO-8859-1"?>
<svg viewBox="0 0 360 792" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:foo="http://www.foo.com">
<!-- svg content -->
</svg>

Note that your document element "svg" is in the default namespace.


Creating the result element with the name "svg" without namespace="{namespace-uri(.)}" would have created a result element <svg> in no namespace, not in the SVG namespace.

So it really is absolutely required.

but the namespace fog is gradually starting to clear.

I tell my students to just think of XML as a labeled hierarchy of your information and that namespaces are used to make globally unique labels. I see it as that simple. Without making the labels unique then processing applications can get confused, so adding a namespace to the label makes the label distinctive from other labels of the same local name.


A metaphor I use in class is that the namespace URI identifies the dictionary in which the local name is found, as what one would use to look up the definition of a word. Consider the word "chair": in French it is the word for "flesh" while in English it is a piece of furniture. Without knowing what dictionary to look in for the word "chair" to know what you need to do to process the word, you don't know the meaning of the word. Similarly without knowing which of the vocabularies SVG or MathML you are working with you don't know how to handle the element named <set>.

Hopefully the fog will clear soon for you.

I hope this helps.

. . . . . . . . . . . Ken

--
Upcoming:  hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009
Interested in other classes?  http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


Current Thread
Keywords