From 7a6c0ce4424659e687a0ce3f9f99d127865dabc8 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Thu, 1 Aug 2024 17:17:43 +0100 Subject: [PATCH 1/4] Integrate step-ixml into the build process --- build.gradle | 53 ++++++++++++++++++++++++++++++++++++++++++ settings.gradle | 2 +- step-ixml/build.gradle | 44 +++++++++++++++++++++-------------- 3 files changed, 81 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index 15085381..a8d007d8 100644 --- a/build.gradle +++ b/build.gradle @@ -101,6 +101,7 @@ task make_etc() { ["steps", "step-file", "step-os", "step-paged-media", "step-run", "step-text", "step-mail", "step-rdf", "step-validation", + "step-ixml" ].each { spec -> Task t = task "copy_${spec}_build"(dependsOn: [ "buildspecs" ], type: Copy) { from "$spec/build/" @@ -653,6 +654,58 @@ task step_mail_xpl(dependsOn: ["step-mail:library"], type: Copy) { rename ("library.xml", "steps.xpl") } +// ====================================================================== +// step-ixml + +task step_ixml(type: DocBookTask, + dependsOn: [ "download_xproc_toc", + "steps", "xproc_schemas", "spec_schemas", + "step-ixml:specification", + "step_ixml_assets", + "step_ixml_src", "step_ixml_xpl" ]) { + inputs.files fileTree(dir: "tools/xsl/") + inputs.files fileTree(dir: "tools/xpl/") + inputs.file "build/xproc/toc.xml" + input("source", "step-ixml/build/source.xml") + output("result", "build/dist/ixml/index.html") + + param("schemaext.schema", file("build/schema/dbspec.rng")) + param("ci", getenv("CIWORKFLOW")) + param("ci-commit", getenv("CI_SHA1")) + param("ci-build-number", getenv("CI_BUILD_NUM")) + param("ci-user", getenv("CI_PROJECT_USERNAME")) + param("ci-repo", getenv("CI_PROJECT_REPONAME")) + param("ci-branch", getenv("CI_BRANCH")) + param("ci-tag", getenv("CI_TAG")) + + option("style", file("tools/xsl/xproc-specs.xsl")) + option("diff", deltaxml()) + option("specid", "ixml") + option("diffloc", buildAbsDir + "/ixml/diff.html") + + pipeline "tools/xpl/formatspec.xpl" +} +buildspecs.dependsOn "step_ixml" + +task step_ixml_assets(type: Copy) { + from "src/main/resources" + into "build/dist/ixml/" +} + +task step_ixml_src(dependsOn: ["step-ixml:source"], type: Copy) { + from "step-ixml/build/" + into "build/dist/ixml/" + include "source.xml" + rename ("source.xml", "specification.xml") +} + +task step_ixml_xpl(dependsOn: ["step-ixml:library"], type: Copy) { + from "step-ixml/build/" + into "build/dist/ixml/" + include "library.xml" + rename ("library.xml", "steps.xpl") +} + // ====================================================================== // Clean up diff --git a/settings.gradle b/settings.gradle index 1f1dc956..e92df9ae 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ include 'steps', 'step-validation', 'step-os', 'step-paged-media', 'step-run', - 'step-file', 'step-text', 'step-mail' + 'step-file', 'step-text', 'step-mail', 'step-ixml' diff --git a/step-ixml/build.gradle b/step-ixml/build.gradle index c9e5eda9..0e771965 100644 --- a/step-ixml/build.gradle +++ b/step-ixml/build.gradle @@ -5,7 +5,7 @@ repositories { configurations { tools { - description = "ixml tools" + description = "Run tools" transitive = true } } @@ -56,27 +56,37 @@ task glossary(dependsOn: ["xinclude"], type: XMLCalabashTask) { pipeline "../tools/xpl/makeglossary.xpl" } -task specification(dependsOn: [ "source" ]) { - // nop +task library(dependsOn: ["source"], type: XMLCalabashTask) { + inputs.file "build/source.xml" + inputs.file "../tools/xpl/typed-pipeline-library.xpl" + inputs.file "../tools/xsl/typed-pipeline-library.xsl" + outputs.file "build/library.xml" + input("source", "build/source.xml") + output("result", "build/library.xml") + pipeline "../tools/xpl/typed-pipeline-library.xpl" } -// ================================================================================ -// Process the examples - -def stripFiles = [ ] - -stripFiles.each { String name -> - String newname = name.substring(0, name.lastIndexOf(".")) + ".txt" +task rnc(dependsOn: ["library"], type: XMLCalabashTask) { + inputs.file "build/library.xml" + inputs.file "../tools/xpl/library-to-rnc.xpl" + inputs.file "../tools/xsl/library-to-rnc.xsl" + outputs.file "build/steps.rnc" + input("source", "build/library.xml") + output("result", "build/steps.rnc") + pipeline "../tools/xpl/library-to-rnc.xpl" +} - task "process_$name"(type: StripAmblesTask) { - input = file("src/main/examples/$name") - output = file("$buildDir/examples/$newname") - } - xinclude.dependsOn "process_$name" +task rng(dependsOn: ["rnc"], type: JavaExec) { + inputs.file "build/steps.rnc" + outputs.file "build/steps.rng" + classpath = configurations.tools + mainClass = 'com.thaiopensource.relaxng.translate.Driver' + args = ["build/steps.rnc", "build/steps.rng"] } -// ================================================================================ -// Process the examples +task specification(dependsOn: [ "source", "library", "rng" ]) { + // nop +} task clean() { doFirst { From 69b233f4c6c140905410d2d135b6cf0550b6c69c Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Thu, 1 Aug 2024 17:18:47 +0100 Subject: [PATCH 2/4] Fix #547 by adding new error codes --- step-ixml/src/main/xml/specification.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/step-ixml/src/main/xml/specification.xml b/step-ixml/src/main/xml/specification.xml index 4f01cca5..358fb833 100644 --- a/step-ixml/src/main/xml/specification.xml +++ b/step-ixml/src/main/xml/specification.xml @@ -84,9 +84,11 @@ the specified Invisible XML grammar. If no grammar is provided on the grammar port, the grammar for Invisible XML is assumed. If an XML or text grammar is provided it -should be an Invisible XML grammar. -If any other grammar format is provided, its interpretation is -implementation-defined. +must be an Invisible XML grammar. +It is a dynamic error if the grammar +provided is not a valid Invisible XML grammar. +It is a dynamic error if more than one +document appears on the grammar port. The source to be processed is usually text, but there’s nothing in principle that prevents an Invisible XML grammar From 26bd76af4920c72bf60a41338f1a62d1c3775ad2 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Thu, 1 Aug 2024 17:19:09 +0100 Subject: [PATCH 3/4] Clarify grammar content types (per new errors) --- step-ixml/src/main/xml/specification.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/step-ixml/src/main/xml/specification.xml b/step-ixml/src/main/xml/specification.xml index 358fb833..f3b97728 100644 --- a/step-ixml/src/main/xml/specification.xml +++ b/step-ixml/src/main/xml/specification.xml @@ -75,7 +75,7 @@ steps is assumed; for background details, see the specified Invisible XML grammar. - + From ce0c9d37e7c5712d5923fd97d7995c6db624cb9f Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Thu, 1 Aug 2024 17:35:47 +0100 Subject: [PATCH 4/4] Attempt to resolve #494 --- step-ixml/src/main/xml/specification.xml | 86 +++++++++++++----------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/step-ixml/src/main/xml/specification.xml b/step-ixml/src/main/xml/specification.xml index f3b97728..2d3c0db9 100644 --- a/step-ixml/src/main/xml/specification.xml +++ b/step-ixml/src/main/xml/specification.xml @@ -77,7 +77,7 @@ the specified Invisible XML grammar. - + @@ -120,16 +120,19 @@ in the output.
-Example +Examples -The following pipeline parses an Invisible XML grammar and returns -its XML representation: +Several examples demonstrate features of the step. + +
+Parsing an Invisible XML grammar + +In this first example, no grammar is provided, so the pipeline parses the +Invisible XML grammar on the source port and returns its XML +representation: - -Parsing an ixml grammar - This would produce an XML version of the grammar: @@ -155,32 +158,35 @@ its XML representation: ]]> -Providing the “date” grammar allows the step to parse dates: +
+
+Parsing a date + +If the grammar is provided on the grammar port, it can be +used to parse input, the string “31 December 2021” in this case: - -Parsing a date with ixml - This would produce an XML version of the date: 31December2021]]> +
+
+Failed parses + If a parse fails, the implementation must indicate this, but it may also provide information about where the processing failed. - -Failing to parse a date with ixml - Here the output might be something like this: - + month -> • M a r c h month -> M • a r c h @@ -189,21 +195,24 @@ month -> M • a r c h month -> • M a y month -> M • a y -]]> +]]> -There is nothing standard about this markup -except the ixml:state attribute with the -value “failed”. +In the case of failure, Invisible XML requires that the ixml:state attribute appear on the root element +containing the token “failed”. It doesn’t constrain the implementation’s +choice of the root element or the content of the document. + + +
+
+Ambiguous parses An ixml grammar may be ambiguous. In the grammar below, there are three different possible ways to parse the input. By default, one of them is returned. - -Parsing an ambiguous grammar - This might return any one of these parses: @@ -221,41 +230,40 @@ different possible ways to parse the input. By default, one of them is returned. >a123]]> All are equally correct. +
+ +
+Ambiguous parse selection An implementation might provide a parameter to allow the author to select a particular parse: - -Selecting a particular parse - This might return: a123]]> +>a123]]> +
+ +
+Multiple ambiguous outputs Or a processor might provide a parameter to return all of the parses. - -Selecting a particular parse - -This might return: +This might return three documents: - -a123 -a123 -a123 -]]> +a123 +a123 +a123]]> As before, there is nothing standardized about the results in this case. - +