By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Getting Xerces to accept copy-of parameters

P: n/a
I have a problem using Xerces with a template for
a generic page-header getting a sub-tree as argument.
The same stylesheet is working flawlessly in IE and
Mozilla, though it would be nice to have a result-file
to work with too.

Here is an example (xerces only get a collapsed string through),
any suggestions or current bug-reports are welcome.

/ Patrik

My "paramtest.xml" :

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="sendparam.xsl"?>
<rootnode>
<treenode>
<organization>The Apache Software Foundation</organization>
<street>1901 Munsey Drive</street>
<address>Forest Hill, MD 21050-2747</address>
<country>U.S.A</country>
</treenode>
<othernode>
othernode
</othernode>
</rootnode>

The stylesheet "sendparam.xsl" sending a node as parameter :

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
encoding="ISO-8859-1" />

<xsl:include href="getparam.xsl"/>

<xsl:template match="rootnode">

<xsl:variable name="treecopy">
<xsl:copy-of select="treenode"/>
</xsl:variable>

<xsl:call-template name="testtemplate">
<xsl:with-param name="paramtree" select="$treecopy"/>
</xsl:call-template>

</xsl:template>
</xsl:stylesheet>

A generic stylesheet "getparam.xsl" using the parameter :

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"
encoding="ISO-8859-1" />

<xsl:template name="testtemplate">
<xsl:param name="paramtree">no recipent</xsl:param>
<xsl:for-each select="$paramtree/treenode/*">
<b>
<xsl:value-of select="."/>
</b>
<br/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
pa*************@mail.com (Patrik Carlsson) wrote in message news:<60*************************@posting.google.c om>...
I have a problem using Xerces with a template for
a generic page-header getting a sub-tree as argument.
The same stylesheet is working flawlessly in IE and
Mozilla, though it would be nice to have a result-file
to work with too.

Here is an example (xerces only get a collapsed string through),
any suggestions or current bug-reports are welcome.

/ Patrik

You do mean you're using Xalan, right? Xerces is an XML parser, not
an XSLT processor.

....
The stylesheet "sendparam.xsl" sending a node as parameter :

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
encoding="ISO-8859-1" />

<xsl:include href="getparam.xsl"/>

<xsl:template match="rootnode">

<xsl:variable name="treecopy">
<xsl:copy-of select="treenode"/>
</xsl:variable>

....

This variable is a result tree fragment, which has limitations in XSLT
1.0.
<xsl:call-template name="testtemplate">
<xsl:with-param name="paramtree" select="$treecopy"/>
</xsl:call-template>

</xsl:template>
</xsl:stylesheet>

A generic stylesheet "getparam.xsl" using the parameter :

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"
encoding="ISO-8859-1" />

<xsl:template name="testtemplate">
<xsl:param name="paramtree">no recipent</xsl:param>
<xsl:for-each select="$paramtree/treenode/*">
<b>
<xsl:value-of select="."/>
</b>
<br/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


You are trying to use a result tree fragment as a node-set, which is
not allowed in XSLT 1.0. MSXSL 3.0 allows this, but 4.0 does not. I
don't know why Mozilla allows this, but that's a bug. Xalan is
correctly rejecting your stylesheet.

One way around this is to use a processor-specific extension to
convert a result tree fragment. Another choice is to use the EXSLT
node-set extension, which is more portable.

Dave
Jul 20 '05 #2

P: n/a
db******@channel1.com (Dave Bertoni) wrote in message news:<79**************************@posting.google. com>...
pa*************@mail.com (Patrik Carlsson) wrote in message news:<60*************************@posting.google.c om>...
I have a problem using Xerces with a template for
a generic page-header getting a sub-tree as argument.
The same stylesheet is working flawlessly in IE and
Mozilla, though it would be nice to have a result-file
to work with too.

Here is an example (xerces only get a collapsed string through),
any suggestions or current bug-reports are welcome.
See the old post...
/ Patrik


You are trying to use a result tree fragment as a node-set, which is
not allowed in XSLT 1.0. MSXSL 3.0 allows this, but 4.0 does not. I
don't know why Mozilla allows this, but that's a bug. Xalan is
correctly rejecting your stylesheet.

One way around this is to use a processor-specific extension to
convert a result tree fragment. Another choice is to use the EXSLT
node-set extension, which is more portable.

Dave


Thank's for the help,
Knowing the difference between node-sets and tree-fragments helped a lot.
Since my application was simple just sending the node without using
a variable solved my problem:

<xsl:with-param name="paramtree" select="/rootnode/treenode"/>

Then the parameter can be traversed as I wished

<xsl:for-each select="$paramtree/*">
<b><xsl:value-of select="."/></b><br/>
</xsl:for-each>

Cheers
Patrik
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.