-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added XSLT 3.0 support. #74
base: master
Are you sure you want to change the base?
Conversation
Thanks for submitting the pull request. Would it be possible to share the whole I have oXygen 14.2 and I can see two files |
Here are the two files. The template x:output-expect-TODO-REMOVE...I-CANT-REMEMBER has been renamed to x:output-expect, and the old x:output-expect has been removed. Best regards, Sandro Cirulli [email protected] wrote: |
I tested the support for testing XSLT 3.0 with this XSpec test: <?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="unit-converter.xsl" xslt-version="3.0">
<x:scenario label="When processing a data element with unit feet">
<x:context>
<data>
<altitude>1200</altitude>
<unit>feet</unit>
</data>
</x:context>
<x:expect label="convert feet to meters">
<data>
<altitude>365.76</altitude>
<unit>meters</unit>
</data>
</x:expect>
</x:scenario>
</x:description> It tests the following XSLT which makes use of high-order functions, a new feature of XSLT 3.0 (the example is adapted from www.xfront.com/Pearls-of-XSLT-and-XPath-3-0-Design.pdf). <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
version="3.0">
<xsl:variable name="unit-converter"
select="function(
$value as xs:decimal,
$f as function(item()*) as item()*
)
as xs:decimal
{$f($value)}"/>
<xsl:variable name="feet-to-meters"
select="function(
$a as xs:decimal
)
as xs:decimal
{$a * 0.3048}"/>
<xsl:template match="data[unit='feet']">
<xsl:copy>
<altitude>
<xsl:value-of select="$unit-converter(altitude, $feet-to-meters)"/>
</altitude>
<unit>meters</unit>
</xsl:copy>
</xsl:template>
</xsl:stylesheet> I run this test with Oxygen 14.2 (which includes the Oxygen patch) and the test goes through successfully. However, I noticed that with this patch it is compulsory to specify the If the patch is changed from: <stylesheet version="{( @xslt-version, '2.0' )[1]}"> to: <stylesheet version="{if ( @xslt-version, '3.0' ) then '3' else '2'}"> the XSpec test runs correctly even if I wonder if this implementation may be more suitable as it does not force to specify the Unfortunately I'm unable to test this implementation when running XSpec from the command line as XSLT 3.0 requires saxon9ee.jar (I only have saxon9he.jar available). |
I am not sure to understand your last comment about the version.
|
@cmarchand, why did you remove the new |
@fgeorges: Sorry, I've probably not been very clear in my comment. I noticed that if As for your second comment, I should have written '2.0' and '3.0' instead of '2' and '3'. I didn't consider 1.0 so you are definitely right. |
You mean, "wont' compile", for XSLT 3.0 tests only, right? If so the answer is easy: support for 3.0 is enabled only if |
Yes, I meant it won't compile for XSLT 3.0 tests only, XSLT 2.0 tests are fine. I agree with your suggestion. |
OK, thanks. Now we need to know why @cmarchand removed a big chunk of the implementation :-) |
I was looking for having the same result between xspec (out of the box) and xspec in oXygen.But I didn't look at what was inside. And having a template name xxx_old_do_not_use_anymore, when we can register source changes in git, seems very strange. So, I killed a piece of code. |
- replace saxon:serialize() with fn:serialize and use XSLT 3.0 - output error message for Saxon8 and Saxon8-SA - update XSpec unit test (unit test requires support for XSLT 3.0 to run as requested in #74) - update bats unit test
I re-used this pull request in my fork of XSpec but only used the patch in: <stylesheet version="{( @xslt-version, '2.0' )[1]}" exclude-result-prefixes="pkg impl"> See my comments in xspec#10 |
Patch from OXYGEN, MIT License
https://www.oxygenxml.com/pipermail/oxygen-user/2016-January/005696.html