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
Add Ant build support for Schematron #160
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some questions.
I didn't track the original PR in details. Sorry if they're already answered.
build.xml
Outdated
</antcall> | ||
</sequential> | ||
</macrodef> | ||
<!-- OXYGEN PATCH needed to create a custom Saxon, for example -warnings:recover -strip:none -opt:10 -dtd:off -l:off -versionmsg:off -expand:on -outval:fatal -val:lax --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These OXYGEN PATCH
phrases are confusing. As the changes are being committed here, they aren't patches anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the OXYGEN PATCH
title but kept the comment for documentation purposes in 3b1a6f4
build.xml
Outdated
name="http://saxon.sf.net/feature/allow-external-functions" | ||
value="true"/> | ||
</factory> | ||
</xslt> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saxon.custom.options
is defined before, but not used here. Why? (Is it possible in the first place?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess saxon.custom.options
is used by oXygen. I can see it is defined with this comment:
<!-- OXYGEN PATCH needed to create a custom Saxon, for example -warnings:recover -strip:none -opt:10 -dtd:off -l:off -versionmsg:off -expand:on -outval:fatal -val:lax -->
<property name="saxon.custom.options" value=""/>
<!-- OXYGEN PATCH END -->
I wonder if it is is worth removing oXygen customizations that are currently not needed for this feature and work with oXygen for a smooth integration of XSpec. This should also address #138 (comment) raised by @markdunnoup.
Shall we just remove the saxon.custom.options
if not used? Do you see any side effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may just remove it, but...
This PR changes <java>
to <xslt>
. Is it easy to implement the feature of saxon.custom.options
in <xslt>
? I'm afraid not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reintroduced the use of <java>
instead of <xslt>
in 3bcb2cd#diff-2cccd7bf48b7a9cc113ff564acd802a8R227. I have kept saxon.custom.options
as a result.
build.xml
Outdated
force="true" | ||
> | ||
<factory name="net.sf.saxon.TransformerFactoryImpl" /> | ||
</xslt> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oXygen's build.xml
enables XML catalog here and in other places. Whey are they not incorporated in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reintroduced XML catalog in various places in 3bcb2cd following the current version of build.xml
packaged with oXygen 19. I had to add xml-resolver.jar
as additional jar library in .travis.yaml
and appveyor.yaml
otherwise tests failed on my local machine with the following error message:
[java] Transformation failed: Failed to load Apache catalog resolver library [java]
Tests are passing on Travis but failing on AppVeyor. The culprit is the ant test for Schematron which fails with this error:
[java] Error on line 12 column 87 of demo-03.xsl:
[java] Malformed URL C:/projects/xspec/tutorial/schematron/demo-03-sch-compiled.xsl(base
[java] file:/C:/projects/xspec/tutorial/schematron/xspec/demo-03.xsl): unknown protocol: c
[java] Malformed URL C:/projects/xspec/tutorial/schematron/demo-03-sch-compiled.xsl(base file:/C:/projects/xspec/tutorial/schematron/xspec/demo-03.xsl)
The issue is the path file:/C
, I suspect the XML resolver or the java command may have caused this. I also wonder if this is a similar problem I described in #138 (review) (see where I talk about file:/
in Unix and Windows) but this time it's problematic for Windows.
I won't have more time today to debug this and unfortunately Windows is not my forte. Could you have a look at this failing test in case you spot any glaring error I made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvements!
I looked at the intermediate file (demo-03.xsl
) and found a fake URI:
<xsl:import href="c:/xspec/tutorial/schematron/demo-03-sch-compiled.xsl"/>
...
<xsl:variable name="x:stylesheet-uri"
as="xs:string"
select="'c:/xspec/tutorial/schematron/demo-03-sch-compiled.xsl'"/>
Probably 4e2ed51#diff-2cccd7bf48b7a9cc113ff564acd802a8R129 makes it.
I'm fixing it.
build.xml
Outdated
xspec.phase Required if XSpec describes a Schematron file, with value "#ALL" | ||
xspec.compiled.xsl.dir Folder in which to place the compiled XSLT file generated from a Schematron file | ||
[Optional; the default is a subfolder "xspec" of the folder containing the XSpec file] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all parameters are explained. Are they missed? Or, will be explained only in Wiki?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added more documentation in e9861f8. This will be used to update the wiki. I left the documentation on how to run it in oXygen as it will be useful for the oXygen integration and for all those who want to use it before this feature is fully integrated in oXygen.
build.xml
Outdated
|
||
<!-- Copy of original XSpec file | ||
will be overwritten if XSpec applies to Schematron --> | ||
<property name="xspec.compiled.xml" location="${xspec.base.dir}/${xspec.base}-compiled-oxygen.xspec"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this file name have -oxygen
?
It was puzzling to find such a file when I ran build.xml
outside oXygen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the -oxygen
from the file name in 3b1a6f4#diff-2cccd7bf48b7a9cc113ff564acd802a8R113. This should be unnecessary once we fully integrate with the oXygen ant build file.
test/xspec.bats
Outdated
|
||
|
||
@test "running XSpec via ant for XSLT support" { | ||
run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/../tutorial/escape-for-regex.xspec -lib /tmp/xspec/saxon/saxon9he.jar -lib /tmp/ant/lib/xmltask.jar -lib /tmp/ant/lib/ant-contrib.jar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-lib /tmp/xspec/saxon/saxon9he.jar
should be-lib ${SAXON_CP}
to coordinate with other tests and help changing Saxon versions/editions.-lib /tmp/ant/lib/xmltask.jar -lib /tmp/ant/lib/ant-contrib.jar
may be shortened to-lib /tmp/ant/lib
-Dclean.output.dir=true
should be added, otherwisegit status
finds a temp file after testing locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented this feedback in this branch in cd32771
test/xspec.bats
Outdated
|
||
@test "running XSpec via ant for Schematron support" { | ||
echo ${PWD} | ||
run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/../tutorial/schematron/demo-03.xspec -lib /tmp/xspec/saxon/saxon9he.jar -lib /tmp/ant/lib/xmltask.jar -lib /tmp/ant/lib/ant-contrib.jar -Dtest.type=s -Dxspec.project.dir=${PWD}/../ -Dxspec.compiled.xsl.dir=${PWD}/../tutorial/schematron -Dxspec.phase=#ALL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After running this command line locally, git status
finds tutorial/schematron/demo-03-sch-compiled.xsl
even with -Dclean.output.dir=true
. Is it a bug of clean.output.dir
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember @markdunnoup mentioning this in #138 (comment):
The "cleanup" target is not fully compatible with XSpec for Schematron yet. When ${clean.output.dir} is set to true, it removes SVRL files which the HTML report links to if the XSPec fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that a file is not removed. The known problem in the cited comment is that a file is removed. Are they the same thing?
Anyway, if cleanup
is incomplete, it would be nice if known issues or remaining tasks are commented in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the removal of the temporary file in 3b1a6f4#diff-2cccd7bf48b7a9cc113ff564acd802a8R252, the XSL compiled file was missing. I tested it locally and it removes the temporary files when the option clean.output.dir
is set to true
via the command line.
I pushed the tests to this branch.
I made so, because I usually run |
- See comment in #160 (review) - Use SAXON_CP instead of path to Saxon - Shorten path to ant libraries - Add clean option to remove temp file
test/xspec.bats
Outdated
|
||
|
||
@test "running XSpec via ant for XSLT support" { | ||
run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/../tutorial/escape-for-regex.xspec -lib ${SAXON_CP} -lib /tmp/ant/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly, -Dclean.output.dir=true
is necessary here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I added it in ab86e9f
- Remove comments OXYGEN_PATCH - Remove misleading -oxygen from compiled file name - Add removal of temporary compiled file - Add clean option in test for XSLT support
- Add clean option in test for XSLT support
- Use <java> instead of <xslt> - Enable XML catalog - Add xml-resolver.jar to CI configuration - Format and indent code
because the original comment is no longer true. Initial template can be specified: https://github.com/xspec/xspec/blob/4e2ed51f98b7f530b21bbbc3742eb97fe9712294/build.xml#L223-L225
This build.xml expects Saxon Jar to be specified by the -lib command line option
because makeurl/@Validate=true by default. Also rename the property to better represent its nature.
The issue encountered on Travis was not reproduced locally even with the same version (1.9.3) of Ant. Something may be special on Travis's Ant or environment, I don't know. So I had to install a cleaner Ant on Travis. While doing so, I noticed Bats was readily available on Travis. So I removed its installation process from As we've put some installation processes,
I hope I'm done. Please review the changes which have been accumulated unexpectedly. Beware; I'm not familiar with Ant :)
No problem. |
It will fail.
I hope I'm really done now :( Various changes have been made since the initial commit. For writing the usage in Wiki, you might want to take a look at |
Thanks for your work and the many improvements. I'll review your changes this week and let you know. If everything is fine, I'll approve it and merge this branch into |
Sorry for adding commits. They are supposed to just augment tests and simplify |
@AirQuick: Thanks a lot for your work, it's amazing how you improved this original pull request! Thanks for adding additional tests (always appreciated!), for removing unncessary dependencies, and simplifying the build script. Thanks also for making the Travis and AppVeyor configurations closer and for standardizing on tools like I checked your commits and they look good to me. I just have few questions:
Let me know what you think. I'm aiming to merge this pull request during the weekend and then working on #139 for releasing XSpec v1.0.0. |
Based on the Ant manual, the new
|
Thanks for your replies. I'll mention in the documentation that Ant 1.9.1 is the minimum requirement (I didn't know about I can see the rationale for using a scripting programming language and I can see it is also one of the suggested solutions for a similar question on StackOverflow. It makes sense. I'll merge this pull request during the weekend and review the documentation on the wiki. |
@AirQuick: I merged this pull request into |
Updated the wiki:
|
@AirQuick: thanks for updating the wiki, it's much clearer now. |
Summary
This pull request integrates #138 submitted by @markdunnoup and allows to run XSpec tests for Schematron using the ant build script. For further detail, please see conversation in #138.
This pull request also adds two bats tests checking that the ant build script works correctly for XSLT and Schematron.
As this was approved by @markdunnoup and me in #138 (comment), I'm merging into master.
Further work
I will update the documentation in the wiki.
@AirQuick: would you be able to add similar tests for the batch script? Note that ant is installed by default in Travis but I had to install additional ant libraries in
.travis.yaml
. Ant may not be installed by default on AppVeyor.