Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2011, 10:19 AM
Registered User
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT result different from Applet vs. command line

Hi,

I would like to get some help on understanding the different result of XSL transformation done in
- Java Applet (that creates and displays HTML output with XSLT)
- command line - tried with 4 XSLT engines: xsltproc, Saxon 6.5.5, XalanJ 2.7.1, simple JAXP(javax.xml.transform.Transformer).

I have a variable that contains a number with scientific notation:
HTML Code:
<xsl:variable name="num" select="'1.0E-6'"/>
where the value is between '' (apostrophes).
For
HTML Code:
<xsl:value-of select="concat($numF, ': [', number($numF), ']')"/>
  • Applet: 1.0E-6: [NaN]
  • xsltproc: 1.0E-6: [ 1e-06]
  • Saxon: 1.0E-6: [NaN]
  • XalanJ: 1.0E-6: [NaN]
  • JAXP: 1.0E-6: [0.000001]

If the
HTML Code:
<xsl:variable name="num" select="1.0E-6"/>
where the value is without '' (apostrophes).
for the same XSL
  • Applet: 0.0000010: [0.0000010]
  • xsltproc: 1.0E-6: [ 1e-06]
  • Saxon: Error in expression 1.0E-6: Unexpected token <name> beyond end of expression
  • XalanJ: SystemId Unknown; ... 1.0E-6 could not be formatted to a number!
  • JAXP: ERROR: 'Syntax error in '1.0E-6'.' FATAL ERROR: 'Could not compile stylesheet'
 
Old October 14th, 2011, 11:47 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XSLT 1.0 the notation '1.0e-6' should NOT be accepted either as a literal in an XPath expression (should be a syntax error) or as input to number() (should produce NaN). In XSLT 2.0 it should be accepted by both.

Looks like you have found some non-conformant XSLT 1.0 processors.

(JAXP is not the name of an XSLT processor, by the way. It is the name of an API supported by several XSLT processors, including two of those on your list, Saxon and Xalan-J. You need to be more precise about which processor you are referring to here. I suspect the one that is distributed with the Sun/Oracle JDK - which is notoriously buggy.)

Michael Kay
Saxonica
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old October 14th, 2011, 03:57 PM
Registered User
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael.

You are right the Applet and the last XSLT processor (that I inaccurately called JAXP) is using Sun/Oracle J2SE 5.0 that is JAXP 1.3 reference implementation (according to http://jaxp.java.net/1.3/index.html) supporting XSLT 1.0 and XPath 1.0.

Actually when I get NaN that's fine.

When I convert the 1.0E-6 value to fixed point number with a recursive xsl that results in [0.0000010000000000000002] that is still fine...

Now the output of for the same XSL is:
Applet: 0.0000010000000000000002:[0.005362758289192256]
xsltproc: 1e-06:[ 1e-06]
Saxon: 0.0000010000000000000002:[0.0000010000000000000002]
XalanJ: 0.0000010000000000000002:[0.0000010000000000000002]
JAXP: 1.0000000000000002E-6:[0.0000010000000000000002]

As I wrote the Applet and the last XSLT processor are using the same J2SE code (from class javax.xml.transform.Transformer) but they Applet gives totally wrong value for the number() function.

Do you think it's a bug in the J2SE JAXP implementation?
 
Old October 19th, 2011, 08:20 AM
Registered User
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi All,

I write here my lessons learned while investigating this problem.
Actually the cause of the different XSLT result was not the Applet but a separate jar file.
The Applet can create various outputs including PDF with Apache's FOP. The xalan.jar (from FOP) was included in the classpath and interfered with the XSL implementation in J2SE 5.0.

Regards,





Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue using "saxon:line-number()" in command line XSL with Saxon9.jar ROCXY XSLT 3 June 3rd, 2009 04:24 AM
result line break. cowbell1 Java Basics 1 October 18th, 2007 05:28 AM
Asp Command Line dizzy1 Classic ASP Basics 1 August 30th, 2007 06:32 PM
Ch 12, Try It Out, p.456, Line 8 Different result VictorVictor BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 February 23rd, 2006 02:52 PM
Command line switches jaucourt Flash (all versions) 0 December 31st, 2004 07:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.