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

RE: support for namespace axis?


Subject: RE: support for namespace axis?
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 2 Dec 1999 17:14:07 -0000

> 	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



Current Thread
Keywords