node-set working for msxml3 , msxml4 , saxon 8.1

Discussion in 'XML' started by Rolf Kemper, Apr 12, 2005.

  1. Rolf Kemper

    Rolf Kemper Guest

    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>
     
    Rolf Kemper, Apr 12, 2005
    #1
    1. Advertising

  2. <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
     
    David Carlisle, Apr 12, 2005
    #2
    1. Advertising

  3. Rolf Kemper

    Rolf Kemper Guest

    Re: node-set working for msxml3 , msxml4 , saxon 8.1 modified

    David Carlisle <> wrote in message news:<>...
    > <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>
     
    Rolf Kemper, Apr 13, 2005
    #3
  4. Re: node-set working for msxml3 , msxml4 , saxon 8.1 modified

    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
     
    David Carlisle, Apr 13, 2005
    #4
  5. Re: node-set working for msxml3 , msxml4 , saxon 8.1 modified

    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>
     
    David Carlisle, Apr 13, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,651
  2. tgtt
    Replies:
    2
    Views:
    453
    C. M. Sperberg-McQueen
    Jan 28, 2004
  3. milesd
    Replies:
    0
    Views:
    626
    milesd
    Jun 14, 2005
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,509
    Dimitre Novatchev
    Aug 24, 2006
  5. Vince C.
    Replies:
    12
    Views:
    276
    Vince C.
    Jan 15, 2004
Loading...

Share This Page