Re: [xsl] Namespaces best practice in XML

Subject: Re: [xsl] Namespaces best practice in XML
From: "tom tom" <tomxsllist@xxxxxxxxxxx>
Date: Tue, 04 Apr 2006 16:17:05 +0100
path-default-namespace is exactly what I am looking for, I didn't know this existed.

One further question:

If I (using saxon8) apply the following XSLT:

<xsl:stylesheet version="2.0" xmlns="http://www.eeeeee.com"; xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xhtml"/>
<xsl:template match="ppp" priority="2">lllllllllllllllllll</xsl:template>
</xsl:stylesheet>


to the following XML

<ppp xmlns="http://www.eeeeee.com"; xmlns:xi="http://www.w3.org/2001/XInclude";>ddd</ppp>

The match="ppp" does not get invoked yet I have declared the default namespace to be the same namespace as <ppp> is in in the XML. Why does this happen?


From: David Carlisle <davidc@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Namespaces best practice in XML
Date: Tue, 4 Apr 2006 15:28:57 +0100

> at I need this stylesheet to be
> as accessible to as many people as possible. Having to prefix all source XML
> elements in the XSLT when that prefix doesn't physically exist in the XML
> adds a level of complexity that non-namespace-savvy developers might find
> confusing.


I think people get used to this pretty quickly (if they look at xsl for
very long at all) if in the stylesheet you declare a prefix a: and then
select a:foo that means select foo in that namespace, whatever prefix
(including no prefix at all) is used in the source file. the source file
doesn't have to use the same prefix a:. This is just a general rule: there
is really nothing special about the so called default namespace here.

Although having said that, a lot of people did apparent;y want to use
non-prefixed element names to refer to namespaced elements in XPath so
in XPath2 (and so in XSLT2) you will be able to set the default Xpath
element namespace, and have everything that you want.


> use a version of HTML which doesn't require a namespace declaration which of course is _all_ versions of html. Namespaces don't apply to HTML, only to XHTML (all versions of which do require the elements to be in a namespace, sadly different namespaces for XHTML 1 and XHTML 2)


David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


_________________________________________________________________
Are you using the latest version of MSN Messenger? Download MSN Messenger 7.5 today! http://join.msn.com/messenger/overview


Current Thread