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).
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)"/> )
The lines
<xsl:transform version="1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:saxon="http://icl.com/saxon"
<xsl:transform version="1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:saxon="http://icl.com/saxon"
xmlns:out="to_be_converted_to_XSL/Transform">
<xsl:output method="xml"
indent="yes"/>
...
...
...
</out:transform>
</xsl:transform>
result in:
<out:transform
xmlns:out="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
...
<out:variable select="system-property('xsl:vendor')"
name="Vendor"/>
<out:choose>
<out:when test="contains($Vendor,'Microsoft')
">
<out:apply-templates
select="msxsl:node-set($Tree)"/>
</out:when>
<out:when test="contains($Vendor,'SAXON')
">
<out:apply-templates
select="saxon:node-set($Tree)"/>
</out:when>
<out:when
test="contains(system-property('out:vendor'), 'Apache')
">
</xsl:transform>
result in:
<out:transform
xmlns:out="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
...
...
</out:transform >
without the namespacedelcaration for xalan and xsl.
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 URI.
To handle tree fragments in different environments I want to know
the vendor:
<out:variable name="Vendor"
select="system-property('xsl:vendor')" /> with
'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)"/>
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\xalan.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
Unfortunately xalan is always deleting one of the declarations
and omittes the inline declarations.
Furthermore xalan is always deleting its own namespace-prefix
declaration (xmlns:xalan="http://xml.apache.org/xalan" )
from the stylesheet-tag and therefore the output script does not
work because of an unknown prefix 'xalan'.
The generated script xalan_m2T_out.xsl works if one adds the two
by xalan omitted declarations.
So how can I prevent xalan from deleting the declarations?
Thank you for your help.
Peter
--
