node-set working for msxml3 , msxml4 , saxon 8.1

R

Rolf Kemper

Hi All,

ned help on the example below. It works fine for msxml3/4 but has
problems with saxon. Saxon complains "can not find matching function
..... "

My target is to write style sheets usable for msxml3 , msxml4 , saxon
..
Is there a general solution ?

Any help is highly welcome.

Rolf

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:eek:utput method="xml" encoding="UTF-8" />

<xsl:variable name="gMyNodes">
<MyNodes>
<a/>
<b/>
</MyNodes>
</xsl:variable>

<xsl:template match="/">
<xsl:variable name="vMyNodeSet">
<xsl:choose>
<xsl:when test="function-available('msxsl:node-set')">
<xsl:copy-of select="msxsl:node-set($gMyNodes)"/>
</xsl:when>
<xsl:eek:therwise>
<xsl:copy-of select="$gMyNodes"/>
</xsl:eek:therwise>
</xsl:choose>
</xsl:variable>
<xsl:copy-of select="$vMyNodeSet"/>
</xsl:template>

</xsl:stylesheet>
 
D

David Carlisle

<xsl:when test="function-available('msxsl:node-set')">
<xsl:copy-of select="msxsl:node-set($gMyNodes)"/>
</xsl:when>

saxon 6's node set function is in the saxon namespace
xmlns:saxon="http://icl.com/saxon"
so you could add a when clause for that that uses saxon:node-set

Perhaps your example is just over simplified for posting but the above
code doesn't need node-set extension at all, if you are just copying to
the result you could use
<xsl:copy-of select="$gMyNodes"/>
with identical results.


David
 
R

Rolf Kemper

David Carlisle said:
<xsl:when test="function-available('msxsl:node-set')">
<xsl:copy-of select="msxsl:node-set($gMyNodes)"/>
</xsl:when>

saxon 6's node set function is in the saxon namespace
xmlns:saxon="http://icl.com/saxon"
so you could add a when clause for that that uses saxon:node-set

Perhaps your example is just over simplified for posting but the above
code doesn't need node-set extension at all, if you are just copying to
the result you could use
<xsl:copy-of select="$gMyNodes"/>
with identical results.


David

Dear David ,

Thank you for yopur feedback. Yes , I have oversimplified a bit. But
my real intention is to process the result of a temporary node set
further on by xslt.

I have tried your proposal, may be I made it wrong. It still complains
with saxon8.1.1. I have marked the error lines by comment. Please find
the modified xslt and the result for saxon below.
Do I really need the node-set function for saxon ?
I was thinking for xslt 2.0 I do not need a specific function to get
access to a temporary node set.

Thanks a lot

Rolf

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:saxon="http://icl.com/saxon"<xsl:eek:utput method="xml" encoding="UTF-8" />

<xsl:variable name="gMyNodes">
<MyNodes>
<a/>
<b/>
</MyNodes>
</xsl:variable>

<xsl:template match="/">
<NodeTest>
<xsl:variable name="vMyNodeSet">
<xsl:choose>
<xsl:when test="function-available('msxsl:node-set')">
<msxml>
<xsl:copy-of select="msxsl:node-set($gMyNodes)"/><!-- saxon
error -->
</msxml>
</xsl:when>
<xsl:when test="function-available('saxon:node-set')">
<saxon>
<xsl:copy-of select="saxon:node-set($gMyNodes)"/><!-- saxon
error -->
</saxon>
</xsl:when>
<xsl:eek:therwise>
<ERROR>No node set function available, or missing
processor</ERROR>
</xsl:eek:therwise>
</xsl:choose>
</xsl:variable>
<xsl:copy-of select="$vMyNodeSet"/>
</NodeTest>
</xsl:template>

</xsl:stylesheet>
 
D

David Carlisle

I have tried your proposal, may be I made it wrong. It still complains
with saxon8.1.1

That's why I said saxon 6. I just noticed that the subject line does
explictly say saxon 8 but I missed that on first reading:)


To be honest you probably shouldn't be using saxon 8.1: saxon 8 is
tracking the XSLT 2 drafts so is something of a moving target, It's
pretty stable but I think it's best to keep up to date (8.4 is current)
lest you find you are relying on some feature that got changed in the
final spec.

There is an extension namespace in saxon 8 (check the docs) but
it's not the same one as for saxon6. But in that case you are correct
that it shouldn't be needed at all. as you can use XSLT2 features (even
though presumably your stylesheet is flagged as version="1.0" so you
will be in backward compatibility mode.

David
 
D

David Carlisle

I tried your stylesheet (running on itself) with saxon 8.4, it falls
foul of compile time checking. XSLt2 allows the system to report
certain errors even in code that will never be executed.
(Don't blame me:)
this severely compromises the use of function-available in an xsl:choose
as a guard for conditional code as the compiler barfs on the branches
that will not be executed. A compile time xsl:use-when facility has been
added to try to restore some usability, I have added this to your code
below and Ithink it should work now in msxml saxon6 and saxon8 (although
I only ran it with saxon 8.4)

David



<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:saxon="http://icl.com/saxon"<xsl:eek:utput method="xml" encoding="UTF-8" />

<xsl:variable name="gMyNodes">
<MyNodes>
<a/>
<b/>
</MyNodes>
</xsl:variable>

<xsl:template match="/">
<NodeTest>
<xsl:variable name="vMyNodeSet">
<xsl:choose>
<xsl:when test="function-available('msxsl:node-set')">
<msxml>
<xsl:copy-of use-when="function-available('msxsl:node-set')" select="msxsl:node-set($gMyNodes)"/><!-- saxon
error -->
</msxml>
</xsl:when>
<xsl:when test="function-available('saxon:node-set')">
<saxon>
<xsl:copy-of use-when="function-available('saxon:node-set')" select="saxon:node-set($gMyNodes)"/><!-- saxon
error -->
</saxon>
</xsl:when>
<xsl:when test="system-property('xsl:version')='2.0'">
<saxon8>
<xsl:sequence select="$gMyNodes"/>
</saxon8>
</xsl:when>
<xsl:eek:therwise>
<ERROR>No node set function available, or missing
processor</ERROR>
</xsl:eek:therwise>
</xsl:choose>
</xsl:variable>
<xsl:copy-of select="$vMyNodeSet"/>
</NodeTest>
</xsl:template>

</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top