On Sun, 07 May 2000, Stefano Mazzocchi wrote:
> firstname.lastname@example.org wrote:
> > Added namespace preservation for XSP pages. To preserve namespaces in an
> > XSP page, add an "xsp:xxx" attribute to the page's root element, where
> > "xxx" is the namespace and the attribute value is the namespace URI
> > Ahhhhh!!!! This is invalid :)
Caramba! I know this mechanism may look kinda kludgy, but let's
take the following into consideration:
Namespace usage in XSP is typically associated with logicsheet
Most logicsheets declare only their own namespace as well as
that of XSP.
During XSP code generation, one or more selected logicsheets
are applied in turn to transform the input XSP document into an
equivalent source program.
As each logicsheet is applied, those namespaces not explicitly
declared in it are _not_ preserved in the [intermediate] resulting
Briefly stated, "xmlns:" attributes are not copied by XSLT unless
they correspond to a namespace declared at the stylesheet root
To avoid this, one would need to declare all namespaces in all
In many cases namespaces used for logicsheets need not be
preserved on output, as their dynamic tags are typically
substituted by Java expressions rather than by markup.
For those cases where the result of dynamic tag expansion _is_
a set of one or more namespace-qualified elements, preserving
namespace becomes a necessity.
So far, XSP would silently drop namespace prefixes forcing
stylesheet templates to match _non-qualified_ elements only.
While this works in most cases, it also impairs the usefulness
of namespaces: the resulting element names may well clash
with unrelated, "synonymous" elements...
Thus, a mechanism is needed to selectively preserve
namespaces in XSP documents. "Selectively" here means
that namespaces declared only for logicsheet processing
should not be preserved in the output document.
The strategy chosen for this is to "reuse" the "xsp:" prefix
(not used at all for attributes in XSP) to preserve namespaces
dropped by logicsheet processing.
Thus, for example, if logicsheet "xsql.xsl" uses namespace
"xsql:" for both dynamic and result tags, the following XSP
page illustrates how to preserve the namespace:
<-- Namespace preserved here -->
SELECT ename, job, sal
ORDER BY ename
Upon execution, this XSP page would yield:
. . .
which could then be processed by an XSLT template like:
(1) Btw, let's recall that logicsheets can now be explicitly declared by means
of the pi and are no longer tied to namespaces