xsl-list
[Top] [All Lists]

RE: A very basic question.

2003-02-24 08:30:55
From: Simon Kelly [mailto:kelly(_at_)ipe(_dot_)fzk(_dot_)de]
Sent: Monday, February 24, 2003 7:54 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] A very basic question.

I've not been using xsl and xml for that long, but I can do 
pretty much what
I need with what I already know.  But I have never really 
understood what a
name-space is really refering too.

A namespace refers to a collection of names, or XML elements, bound to a
given name.  A very basic example is XSLT itself: its elements (stylesheet,
template, variable, etc.) are bound to the 'xsl' namespace.  In order for
the XML parser to recognize that a set of elements belong to a namespace, an
XML namespace declaration must be used:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

The value of xmlns:xx must be a globally unique Uniform Resource Identifier
(URI); this is often a URL, but can be any unique string.  (In the case of
XSLT, it should always be the above-referenced URL.)  Any elements belonging
to a declared namespace must be prefixed by the namespace name, so that
<xsl:stylesheet> has special meaning to an XSLT processor, but <stylesheet>
(note no prefix) does not.

This also allows you to use your own namespaces in an XML document, as long
as the URI you use is unique:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0"
                xmlns:myxml="http://my.own.xmlnames.org";>
  <myxml:some-element>foo</myxml:some-element>
  etc.
</xsl:stylesheet>

There is a lot more information (surely better explained than what I've
written) in the XSLT FAQ at http://www.dpawson.co.uk/xsl/sect2/N5536.html.

hth,
b.

| brian martinez                              
brian(_dot_)martinez(_at_)trip(_dot_)com |
| senior gui programmer                                  303.708.7248 |
| trip network, inc.                                 fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| http://www.cheaptickets.com/                   http://www.trip.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>