|
Subject: RE: [xsl] How to stop xalan from deleting namespace declarations From: "Michael Kay" <mhk@xxxxxxxxx> Date: Wed, 11 Jun 2003 15:10:13 +0100 |
A classic example of the problem that namespace prefixes don't matter,
except when they do.
The rules for xsl:namespace-alias don't say what namespace prefix should
be used in the result tree. This makes it difficult to reliably use a
namespace prefix within the content of the result document, as in your
example system-property('xsl:version').
You may be better off not using xsl:namespace-alias at all. I find it
more straightforward to write:
<xsl:element name="xsl:stylesheet">
etc., and this way you're more likely to get the prefix you want, though
it's still not guaranteed.
Using <xsl:element> to generate just the outermost (xsl:stylesheet)
element may be enough to force the processor to output a namespace
declaration for the desired prefix.
You can force the result tree to contain a particular namespace
declaration in XSLT 2.0 by using xsl:namespace, or in 1.0 by copying a
namespace node from another document.
Michael Kay
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Peter Janker
> Sent: 11 June 2003 08:00
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How to stop xalan from deleting namespace declarations
>
>
>
> Hello All,
>
> I try to write an xslt-script that outputs an xslt-script.
> Saxon (6.5.2) and MSXSL(3) seem to work but I have difficulties with
> the namespace handling within xalan (2_5_0).
> Therefore I have three related questions concerning xalan(2-5-0) and
> the handling of namespace declarations.
>
> 1: How can I prevent xalan from deleting its own namespace
> prefix declaration?
> 2: How can I prevent xalan from deleting a second namespace prefix
> declaration for a given namespace?
> 3: How can I force xalan to explicitely write a namespace declaration
> within a tag in the output script?
> (like: <out:apply-templates xmlns:xalan="http://xml.apache.org/xalan"
> select="xalan:nodeset($Var)"/> )
>
> Details:
>
> The command
> <xsl:namespace-alias stylesheet-prefix="out"
> result-prefix="xsl"/> is used to set the prefix in the output
> script. (Saxon and msxsl replace the prefix, xalan uses the
> prefix 'out' and
> replaces the URL.)
>
> To handle tree fragments in different environments I want to
> know the vendor:
>
> <out:variable name="Vendor" select="system-property('xsl:vendor')" />
>
> 'xsl' because within the single quotes ('') the prefix is not
> replaced.
>
> Because of the URI-replacement xalan does not know the xsl
> prefix. I thought a workaround would be to declare the
> namespace either for
> both prefixes or within the variable tag:
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:out="http://www.w3.org/1999/XSL/Transform"
> <out:variable name="Vendor"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> select="system-property('xsl:vendor')" />
>
> <out:apply-templates xmlns:xalan="http://xml.apache.org/xalan"
> select="xalan:nodeset($Var)"/>
>
> Unfortunately xalan is always deleting one of the declarations and
> omittes the inline declaration.
> Furthermore xalan is always deleting its own namespace-prefix
> declaration (xmlns:xalan="http://xml.apache.org/xalan" ) from the
> stylesheet-tag and therefore the following lines
> in the output script do not work because of an unknown prefix 'xalan'.
>
> <out:choose>
> ....
> <out:when test="contains($Vendor, 'Apache') ">
> <out:apply-templates select="xalan:nodeset($Var)"/>
> </out:when>
> ....
> </out:choose>
>
>
> The transformation is started by a batch file with one line:
> java -classpath
> .;D:\jdk1.3.1_04\lib\tools.jar;D:\Xalan\xalan-j_2_5_0\bin\xala
> n.jar;D:\Xalan\xalan-j_2_5_0\bin\xml-apis.jar;D:\Xalan\xalan-j
> _2_5_0\bin\xercesImpl.jar
> org.apache.xalan.xslt.Process -in m2t.xml -xsl m2t.xsl -out
> xalan_m2T_out.xsl
>
> The generated script xalan_m2T_out.xsl works if one adds the two by
> xalan omitted declarations.
>
> Thank you for your help.
>
>
> Peter
>
> --
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] How to stop xalan from deleti, Peter Janker | Thread | [xsl] xsl:for-each evaluator?, Corey Wilson |
| RE: [xsl] parameters for matching t, Michael Kay | Date | [xsl] node() implementation, Jarkko . Moilanen |
| Month |