On Sun, 07 May 2000, Stefano Mazzocchi wrote: > ricardo@locus.apache.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 activation (1). 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 document. Briefly stated, "xmlns:" attributes are not copied by XSLT unless they correspond to a namespace declared at the stylesheet root element level. To avoid this, one would need to declare all namespaces in all logicsheets! 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 --> Employee List<title> <xsql:execute-query id="demo" use-connection="scott"> <xsql:statement> SELECT ename, job, sal FROM emp ORDER BY ename </xsql:statement> </xsql:execute-query> </page> </xsp:page> Upon execution, this XSP page would yield: <page xmlns:xsql="http://www.plenix.org/xsp/xsql"> <title>Employee List ADAMS CLERK 1100 . . . which could then be processed by an XSLT template like:
Name Jon Salary
=============================================================== (1) Btw, let's recall that logicsheets can now be explicitly declared by means of the pi and are no longer tied to namespaces