RE: support for namespace axis?

Subject: RE: support for namespace axis?
From: "Vun Kannon, David" <dvunkannon@xxxxxxxx>
Date: Thu, 2 Dec 1999 14:17:34 -0500
	Thank you to both David Carlisle and Michael Kay for clarifying this
for me. I now understand how to proceed.
	I have to admit that I'm still a little uneasy (or just fuzzy
headed) about //city taking as its choice of the default namespace the one
defined in the stylesheet, rather than the one in force in the source
document on the spot. Can I extend Michael's example to include

<template match="//city" 
xmlns="urn:schemas-biztalk.org:your-namespace/purchaseorder.xml">Found a
city

	But this seems to fundamentally confound the concept of (default)
namespace in the stylesheet with that of (default) namespace in the source.
I would prefer

<template
match="//city[namespace::urn:schemas-biztalk.org:your-namespace/purchaseorde
r.xml]">Found a
city

	That, to me, is clearer. After all, this is all at the level of
XPath expressions. What are other uses of XPath doing or going to do? Every
one of them is going look out to their own namespace environment to resolve
the namespaces within the expression?
Cheers,
David

-----Original Message-----
From: Kay Michael [mailto:Michael.Kay@xxxxxxx]
Sent: Thursday, December 02, 1999 12:14 PM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: RE: support for namespace axis?


> 	IMHO, the stylesheet, which obviously knows the vocabulary that
> includes city, should be able to process documents that reference such
> elements irregardless of the namespace given to that vocabulary in the
> source document, i.e. it shouldn't matter to the match 
> expression whether
> the source contains city elements or blah:city elements. I thought the
> namespace axis was the lever I needed to accomplish this.

No, you don't need namespace axes. You need to specify a prefix on the
"//city" pattern that matches the namespace used for this element in the
source document, thus:

<template match="//po:city" 
xmlns:po="urn:schemas-biztalk.org:your-namespace/purchaseorder.xml">Found a
city

It's not easy to write a stylesheet that processes all elements with local
name CITY regardless of namespace. That's intentional: the thinking is that
CITY has a completely different meaning in one namespace from its meaning in
another. (Unfortunately the XHTML guys blew this out of the window by having
three different namespaces for HTML, so there goes a good idea). If biztalk
hasn't followed this convention, the way I would tackle it would be to write
a preprocessing stylesheet that strips the namespace prefixes off, by using
<xsl:element name="local-part()">

Incidentally, it's far from obvious from its description in the spec, but
<xsl:copy-of> is a much easier way of doing a deep copy from source to
output than <xsl:copy>.

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
*****************************************************************************
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorized. 

If you are not the intended recipient, any disclosure, copying, distribution
or any action taken or omitted to be taken in reliance on it, is prohibited
and may be unlawful. When addressed to our clients any opinions or advice
contained in this email are subject to the terms and conditions expressed in
the governing KPMG client engagement letter.         
*****************************************************************************


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


Current Thread