Differences between XSL engines

Discussion in 'XML' started by mikea_59, Mar 21, 2005.

  1. mikea_59

    mikea_59 Guest

    I continue to see diferences between XSLT 2.0 engines. Specifically
    XMLSpy 2005 and Saxon. I have been using XMLSpy to develop some XSLT
    because of the nice debugging environment. When I move my code to Saxon
    I often get something completely different. I'm still a newbie to XSL
    so I'm not sure which one is correct (I lean towards Saxon, but I'm not
    sure). Here is the latest case in point.

    I have the following simple example of an input xml file:

    <ROOT >
    <MAIN>
    <flag1>CC</flag1>
    <flag2>BB</flag2>
    <flag3></flag3>
    </MAIN>
    </ROOT>

    This is the desired output:

    flag1=CC flag2=BB


    and here is the XSL:

    <xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="text" omit-xml-declaration="yes" />
    <xsl:template match="/">
    <xsl:apply-templates select="//*"/>
    </xsl:template>
    <xsl:template match="*">
    <xsl:if test="text()">
    <xsl:value-of select="name()"/>=<xsl:value-of select="."/>
    <xsl:text> </xsl:text>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>


    In XMLSpy I get the desired output:

    flag1=CC flag2=BB


    In Saxon I get this:

    ROOT=

    CC
    BB


    MAIN=
    CC
    BB

    flag1=CC flag2=BB

    This seems like a really simple translation but I can't get it to
    work in Saxon. I can't take advantage of element names because thay are
    not fixed - although the pattern is consistent the element names change
    for each xml instance file. Can someone point out why I am getting
    different results. How can I get the desired output in Saxon?
     
    mikea_59, Mar 21, 2005
    #1
    1. Advertising

  2. I would guess that xml spy is using MXSML. That parser has a documented
    non-conformance to the XML specification in its default state.
    It discards white space text nodes.
    To get a conformant XML parser you need to set the presevewhitespace
    property to true.

    In this case you probably want to discard the white space text nodes,
    but the parser is not supposed to do it by default (and saxon is giving
    the right answer)

    add <xsl:strip-space elements="*"/> to remove white space text nodes
    from the input.


    David
     
    David Carlisle, Mar 21, 2005
    #2
    1. Advertising

  3. mikea_59

    mikea_59 Guest

    XMLSpy uses it's own parser by default.

    I added the <xsl:strip-space elements="*"/> and that worked in Saxon,
    thanks a bunch!
     
    mikea_59, Mar 21, 2005
    #3
    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. Karsten Weinert
    Replies:
    3
    Views:
    1,024
    Karsten Weinert
    Jul 5, 2004
  2. Replies:
    1
    Views:
    3,636
    A. Bolmarcich
    May 27, 2005
  3. Home_Job_opportunity
    Replies:
    0
    Views:
    509
    Home_Job_opportunity
    Jan 8, 2009
  4. Home_Job_opportunity
    Replies:
    0
    Views:
    596
    Home_Job_opportunity
    Jan 14, 2009
  5. Yan Huang
    Replies:
    24
    Views:
    268
    Jorge
    Oct 10, 2009
Loading...

Share This Page