This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: ***********Transformation of an XML document containing a default namespace ************
At 01/10/24 17:40 +0100, David Carlisle wrote:
> > I tried doing something like this a few weeks ago and it didn't work
> > for me. There seems to be no way to control which namespace prefix
> > (including the "empty" prefix) the serializer uses if there is more
> > than one prefix for a given namespace URI.
>
>there are two answers to this: "yes" and "no".
>
>According to the spec, you _never_ get any control over th eprefixes
>used, and it is perfectly OK for an XSLT serialiser to always use
>prefixes like kmsqzzxss1: kmsqzzxss2: .... even if the stylesheet uses
>fo: or whatever. (So this is the no, it can't be done answer)
>
>However most (all?) systems do in fact try to preserve the namespace
>prefixes in most situtaions.
Can we not, however, assume that the processor has to preserve the
namespace prefix regardless of what the Spec says?
The reason I ask came up when I wrote a stylesheet that writes stylesheets,
and I used a processor that did not preserve the namespace prefix ... the
author of the processor ended up changing it so it does preserve the prefix
because this particular situation I had (and anyone else could have)
requires that it be done.
Consider I have a stylesheet using "xsl:" for XSLT instructions and "xslo:"
for my result tree prefix where the XSLT stylesheet generates an XSLT
stylesheet using namespace-alias accordingly. Given I am using "xslo:" in
the template for my result, I may have the following:
<xsl:template match="foo">
<xslo:value-of select="system-property('xslo:version')"/>
</xsl:template>
If the processor does not preserve the prefix that I use, then the
resulting XSLT stylesheet will not have a valid string being passed to the
system-property() function, as there would be no namespace mapped to the
prefix I use in my function argument. And no amount of heuristics would
help a processor unambiguously find my use of namespace prefixes in other
contexts than a namespace prefix of elements or attributes.
I hope this helps.
........................ Ken
--
G. Ken Holman mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML/OmniMark services, training, products.
Book: Practical Transformation Using XSLT and XPath ISBN 1-894049-06-3
Article: What is XSLT? http://www.xml.com/pub/2000/08/holman/index.html
Next public training (instructor-live, Internet-live, and web-based):
-2001-10-22,11-01,11-02,11-05,11-19,11-21,12-03,12-05,12-09,12-10,12-19
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list