Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Differences between XSL engines

Reply
Thread Tools

Differences between XSL engines

 
 
mikea_59
Guest
Posts: n/a
 
      03-21-2005
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput 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?

 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      03-21-2005

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
 
Reply With Quote
 
 
 
 
mikea_59
Guest
Posts: n/a
 
      03-21-2005

XMLSpy uses it's own parser by default.

I added the <xsl:strip-space elements="*"/> and that worked in Saxon,
thanks a bunch!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DEVELOP THE WINNING EDGE, SMALL DIFFERENCES IN YOUR PERFORMANCE CANLEAD TO LARGE DIFFERENCES IN YOUR RESULTS Home_Job_opportunity C Programming 0 01-14-2009 03:51 PM
DEVELOP THE WINNING EDGE, SMALL DIFFERENCES IN YOUR PERFORMANCE CANLEAD TO LARGE DIFFERENCES IN YOUR RESULTS Home_Job_opportunity C Programming 0 01-08-2009 04:31 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
"Add engines"... how can I "remove engines" ? Jude Barnes Firefox 4 08-19-2004 11:02 PM
Difference between xsl:param and xsl:variable? Karsten Weinert XML 3 07-05-2004 04:58 PM



Advertisments