Skip to content

Commit

Permalink
Merge pull request #141 from ndw/main
Browse files Browse the repository at this point in the history
Upgrade to Saxon 11
  • Loading branch information
ndw authored Apr 9, 2022
2 parents 72b51b4 + 80e4157 commit 9c7793e
Show file tree
Hide file tree
Showing 13 changed files with 279 additions and 871 deletions.
9 changes: 8 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
machine:
image: ubuntu-1604:202004-01
image: ubuntu-2004:202111-02
resource_class: xlarge

working_directory: ~/repo
Expand Down Expand Up @@ -31,6 +31,13 @@ jobs:
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: |
if [ -z "$SAXPASSPHRASE" ]; then
echo "No secrets available, will run with Saxon-HE"
else
gpg --batch --yes --passphrase $SAXPASSPHRASE -d tools/saxon.enc | tar zxf -
fi
- run: ./gradlew dependencies

- save_cache:
Expand Down
25 changes: 8 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plugins {
id "maven-publish"
id "signing"
//id 'com.github.eerohele.saxon-gradle' version '0.9.0-beta3'
id 'com.nwalsh.saxon-gradle' version '0.9.1-beta4'
id 'com.nwalsh.gradle.saxon.saxon-gradle' version '0.9.6'
id 'com.nwalsh.gradle.relaxng.validate' version '0.0.6'
id 'com.nwalsh.gradle.relaxng.translate' version '0.0.6'
id "de.undercouch.download" version "4.0.4"
Expand All @@ -47,7 +47,7 @@ sourceSets {
}

//import com.github.eerohele.SaxonXsltTask
import com.nwalsh.SaxonXsltTask
import com.nwalsh.gradle.saxon.SaxonXsltTask
import com.nwalsh.gradle.relaxng.validate.RelaxNGValidateTask
import com.nwalsh.gradle.relaxng.translate.RelaxNGTranslateTask

Expand Down Expand Up @@ -97,19 +97,9 @@ dependencies {
defaultTasks 'report'

saxon.configure {
classpath configurations.validateRuntime
entityResolverClass "org.xmlresolver.Resolver"
uriResolverClass "org.xmlresolver.Resolver"
sourceSaxParser "org.xmlresolver.tools.ResolvingXMLReader"
stylesheetSaxParser "org.xmlresolver.tools.ResolvingXMLReader"
}

saxon.configure("docbook") {
classpath configurations.validateRuntime
entityResolverClass "org.xmlresolver.Resolver"
uriResolverClass "org.xmlresolver.Resolver"
sourceSaxParser "org.xmlresolver.tools.ResolvingXMLReader"
stylesheetSaxParser "org.xmlresolver.tools.ResolvingXMLReader"
initializer 'org.docbook.xsltng.extensions.Register'
}

Expand Down Expand Up @@ -233,6 +223,8 @@ configurations.compileClasspath.each { it ->
System.setProperty("org.docbook.xsltng.extensions.verbose", verbose)
System.setProperty("org.docbook.extensions.pygmentize", pygmentize)

println("Building with Java version ${System.getProperty('java.version')}")

task configureEnvironment() {
def envVars = [:]
envVars['TEST_DIR'] = buildDir
Expand All @@ -259,18 +251,17 @@ task setupXSpec(type: Download) {
doLast {
copy {
from "${projectDir}/src/test/resources/xspec"
into "${buildDir}/xspec-${xspecVersion}/bin"
include "xspec.sh"
into "${buildDir}/xspec-${xspecVersion}/src/common"
include "uri-utils.xsl"
}
}
doLast {
copy {
from "${projectDir}/src/test/resources/xspec"
into "${buildDir}/xspec-${xspecVersion}/src/compiler"
include "generate-tests-utils.xsl"
into "${buildDir}/xspec-${xspecVersion}/bin"
include "xspec.sh"
}
}

onlyIf { !file("${buildDir}/xspec-${xspecVersion}/README.md").exists() }
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
sourceSets {
main {
java {
srcDirs = ['src', 'build/generated/sources/buildconfig']
srcDirs = ['src/main/java', 'build/generated/sources/buildconfig']
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ systemProp.javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactor

verbose=false

xspecVersion=1.6.0
xspecVersion=2.2.4
xsltExplorerVersion=0.1.10

pdftool=antennahouse
Expand Down
12 changes: 6 additions & 6 deletions properties.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
ext {
xslTNGtitle = 'DocBook xslTNG'
xslTNGbaseName = 'docbook-xslTNG'
xslTNGversion = '1.6.2'
guideVersion = '1.6.2'
xslTNGversion = '1.7.0-11'
guideVersion = '1.7.0-11'

docbookVersion = '5.2b12'
publishersVersion = '5.2b12'
docbookVersion = '5.2b13'
publishersVersion = '5.2b13'

saxonVersion = '10.6'
saxonVersion = '11.3'
saxonGroup = 'net.sf.saxon'
saxonEdition = 'Saxon-HE'
//saxonGroup = 'com.saxonica'
Expand All @@ -17,6 +17,6 @@ ext {
metadataExtractorVersion = '2.15.0'
jingVersion = '20181222'
xmlresolverVersion = '4.2.0'
sincludeVersion = '4.0.0'
sincludeVersion = '4.0.0-11'
slf4jVersion = '1.7.30'
}
44 changes: 35 additions & 9 deletions src/bin/docbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,23 @@ def __init__(self, args):
# environment because that version may not be published yet.
# Instead, we rely on the fact that we can get the
# docbook-xslTNG package from the distribution environment and
# we seed with its dependencies.
# we seed with its dependencies. These must all be in the
# DocBook distribution (in libs/lib).
self.seeds = set(["@@PACKAGE_LIST@@"])

self.config = {
"maven-local": str(Path.home()) + "/.m2/repository",
"maven-packages": [],
"pinned-packages": ["xml-apis:xml-apis:1.4.01"],
"excluded-packages": ["xml-resolver:xml-resolver:1.2"],
"excluded-packages": ["xml-resolver:xml-resolver:1.2",
"org.jdom:jdom:*",
"org.jdom:jdom2:*",
"xom:xom:*",
"dom4j:dom4j:*",
"jline:jline:*",
"org.apache.ws.commons.axiom:axiom:*",
"org.apache.ws.commons.axiom:axiom-dom:*",
"org.apache.ws.commons.axiom:axiom-impl:*"],
"args": [],
"classpath": [],
"class": "net.sf.saxon.Transform",
Expand Down Expand Up @@ -80,7 +89,14 @@ def __init__(self, args):

try:
with open(self.config_file, "r") as depfile:
# There's a real potential for this to become a nest of hacks.
# I want the excluded files to be a union of what the user
# might have suggested and what the script suggests.
excluded = self.config['excluded-packages']
self.config = json.load(depfile)
for package in excluded:
if package not in self.config['excluded-packages']:
self.config['excluded-packages'].append(package)
except FileNotFoundError:
with open(self.config_file, "w") as depfile:
depfile.write(json.dumps(self.config, indent=2, sort_keys=True))
Expand Down Expand Up @@ -360,12 +376,25 @@ def compute_dependencies(self):
"""Find all the (transitive closure) of available dependencies
among the packages that we're going to use.
"""
required_list = []
for package in self.seeds:
group, artifact, version = package.split(":")
self._update_dependencies(group, artifact, version)
required_list.append(package)
for package in self.config["pinned-packages"]:
required_list.append(package)

found = True
for package in required_list:
group, artifact, version = package.split(":")
self._update_dependencies(group, artifact, version)
if group not in self.depends \
or artifact not in self.depends[group] \
or version not in self.depends[group][artifact] \
or self.depends[group][artifact][version] is None:
print(f"Required package not found: {group}:{artifact}:{version}; download with Maven")
found = False

if not found:
sys.exit(1)

def _higher_version(self, curver, newver):
if curver == newver:
Expand Down Expand Up @@ -512,10 +541,7 @@ def args(self):
if key not in argset:
args.append(arg)

for arg in ["-x:org.xmlresolver.tools.ResolvingXMLReader",
"-y:org.xmlresolver.tools.ResolvingXMLReader",
"-r:org.xmlresolver.Resolver",
"-init:org.docbook.xsltng.extensions.Register"]:
for arg in ["-init:org.docbook.xsltng.extensions.Register"]:
if ":" in arg:
key = arg[0:arg.index(":")]
else:
Expand All @@ -535,7 +561,7 @@ def run(self):
print(self._java)
for item in jopt:
print(f"\t{item}")
print("-cp")
print("-cp (in addition to libs/lib/*.jar)")
for item in cp.split(os.pathsep):
print(f"\t{item}")
print(self.config["class"])
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/docbook/xsltng/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ public void run() {
}

System.setProperty("xml.catalog.files", catBuilder.toString());
userArgs.add("-x:org.xmlresolver.tools.ResolvingXMLReader");
userArgs.add("-y:org.xmlresolver.tools.ResolvingXMLReader");
userArgs.add("-r:org.xmlresolver.Resolver");
userArgs.add("-init:org.docbook.xsltng.extensions.Register");
if (!userStylesheet) {
userArgs.add("-xsl:https://cdn.docbook.org/release/xsltng/current/xslt/docbook.xsl");
Expand Down
48 changes: 48 additions & 0 deletions src/test/resources/xml/fixed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<article xmlns="http://docbook.org/ns/docbook"
xmlns:xl="http://www.w3.org/1999/xlink" version="5.0">
<title>content</title>
<informaltable frame="all" rowsep="1" colsep="1">
<tgroup cols="5">
<colspec colname="col_1" colwidth="20*"/>
<colspec colname="col_2" colwidth="20*"/>
<colspec colname="col_3" colwidth="20*"/>
<colspec colname="col_4" colwidth="20*"/>
<colspec colname="col_5" colwidth="20*"/>
<thead>
<row>
<entry align="left" valign="top"/>
<entry align="left" valign="top">content</entry>
<entry align="left" valign="top">content</entry>
<entry align="left" valign="top">content</entry>
<entry align="left" valign="top">content</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top" morerows="1"><simpara><emphasis role="strong">content</emphasis></simpara></entry>
<entry align="center" valign="top" namest="col_2" nameend="col_3"><simpara>content</simpara></entry>
<entry align="left" valign="top"><simpara>content</simpara></entry>
<entry align="left" valign="top"/>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">content</emphasis></simpara></entry>
<entry align="center" valign="top" namest="col_2" nameend="col_3"><simpara>content</simpara></entry>
<entry align="left" valign="top"/>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">content</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>content</simpara></entry>
<entry align="center" valign="top" namest="col_3" nameend="col_4"><simpara>content</simpara></entry>
<entry align="left" valign="top"/>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">content</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>content</simpara></entry>
<entry align="center" valign="top" namest="col_3" nameend="col_4"><simpara>content</simpara></entry>
<entry align="left" valign="top"/>
</row>

</tbody>
</tgroup>
</informaltable>
</article>
Loading

0 comments on commit 9c7793e

Please sign in to comment.