xsl-list
[Top] [All Lists]

Re: Can one _generate_ namespace nodes?

2003-02-21 23:37:45
Can you provide a *small* example, please?


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Joseph Kesselman" <keshlam(_at_)us(_dot_)ibm(_dot_)com> wrote in message
news:OF1F7F3FE0(_dot_)CCCBEB71-ON85256CD5(_dot_)000050E0-85256CD5(_dot_)000236B3(_at_)us(_dot_)ibm(_dot_)com(_dot_)(_dot_)(_dot_)
I've got a situation where I'm using namespace aliasing. It's working
fine, but the output (using Xalan, at least) is a bit ugly; the serializer
doesn't realize that the new prefix binding is required until it gets down
to the aliased nodes, and generates the binding there. Since these are
scattered throughout the document, that means a lot of namespace
declaration nodes.

I'd prefer to declare the new prefix once, at the top of the generated
document. But there doesn't seem to be a way to express that. There's no
<xsl:namespace-node> to go with <xsl:attribute>, and <xsl:attribute> is
explicitly forbidden to generate namespace declarations. (Actually, the
way it's forbidden doesn't work now that namespaces have been redefined to
be namespace-aware rather than being hardcoded to the xmlns: prefix, but
that's a separate matter.)

I could generate a dummy attribute with the correct prefix and namespace
at the top level, and let that imply a declaration -- but that could break
validation of the generated document, and sometimes it's explicitly
forbidden. (If I'm generating a stylesheet element, I'd have to create an
attribute in the same namespace as xsl: -- but those are reserved for
XSL's use, and there isn't one which is officially legal on an
<xsl:stylesheet> element.)


I say again, this is an attempt to fix a purely cosmetic problem... but it
really feels like there ought to be a solution. If anyone *does* know of
an official and reliable way to generate a namespace declaration into a
document at a specific point, I'd appreciate the tip!

If not... well, the article goes out as "it's ugly but it works."

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies:
XML, XSL and more.  "may'ron DaroQbe'chugh vaj bIrIQbej"
("Put down the squeezebox and nobody gets hurt.")

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






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