diff options
author | Rutger Broekhoff | 2024-05-04 16:33:53 +0200 |
---|---|---|
committer | Rutger Broekhoff | 2024-05-04 16:33:53 +0200 |
commit | 279f790f078325582aa62e562a766204034766e4 (patch) | |
tree | 6aea4ebf68194afee9bbd4d5a8339355ec6753a7 /scratch/netex-nl-cxx | |
parent | 4f5cb257dc47dcff1b1306e4ae702669dfa93197 (diff) | |
download | oeuf-279f790f078325582aa62e562a766204034766e4.tar.gz oeuf-279f790f078325582aa62e562a766204034766e4.zip |
Try generating C++ code from NeTEx XSDs using CodeSynthesis XSD
Diffstat (limited to 'scratch/netex-nl-cxx')
-rw-r--r-- | scratch/netex-nl-cxx/.gitignore | 2 | ||||
-rw-r--r-- | scratch/netex-nl-cxx/merge-enums-into-basic.xslt | 23 | ||||
-rwxr-xr-x | scratch/netex-nl-cxx/process.sh | 29 | ||||
-rw-r--r-- | scratch/netex-nl-cxx/remove-enums-include.xslt | 12 |
4 files changed, 66 insertions, 0 deletions
diff --git a/scratch/netex-nl-cxx/.gitignore b/scratch/netex-nl-cxx/.gitignore new file mode 100644 index 0000000..f7d74b2 --- /dev/null +++ b/scratch/netex-nl-cxx/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | /vendor/ | ||
2 | /gen/ | ||
diff --git a/scratch/netex-nl-cxx/merge-enums-into-basic.xslt b/scratch/netex-nl-cxx/merge-enums-into-basic.xslt new file mode 100644 index 0000000..6e3fdad --- /dev/null +++ b/scratch/netex-nl-cxx/merge-enums-into-basic.xslt | |||
@@ -0,0 +1,23 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
3 | <!-- Replace includes of netex-nl-enums.xsd with the (almost) literal | ||
4 | contents of the xsd:schema definition in netex-nl-enums.xsd --> | ||
5 | <xsl:template match="xsd:include[@schemaLocation='netex-nl-enums.xsd']"> | ||
6 | <xsl:apply-templates select="document('netex-nl-enums.xsd', /)/xsd:schema/node()"/> | ||
7 | </xsl:template> | ||
8 | |||
9 | <!-- Remove the big 'AFHANKELIJKHEDEN' (dependencies) comment, which | ||
10 | otherwise looks out of place in the output --> | ||
11 | <xsl:template match="comment()[following-sibling::*[1]/self::xsd:include[@schemaLocation='netex-nl-basic.xsd']]"/> | ||
12 | |||
13 | <!-- Remove includes of netex-nl-basic.xsd (coming from netex-nl-enums.xsd), | ||
14 | because we basically inline netex-nl-enums.xsd into netex-nl-basic.xsd --> | ||
15 | <xsl:template match="xsd:include[@schemaLocation='netex-nl-basic.xsd']"/> | ||
16 | |||
17 | <!-- Apply the transformation on the entire tree --> | ||
18 | <xsl:template match="@*|node()"> | ||
19 | <xsl:copy> | ||
20 | <xsl:apply-templates select="@*|node()"/> | ||
21 | </xsl:copy> | ||
22 | </xsl:template> | ||
23 | </xsl:transform> | ||
diff --git a/scratch/netex-nl-cxx/process.sh b/scratch/netex-nl-cxx/process.sh new file mode 100755 index 0000000..8ab7a94 --- /dev/null +++ b/scratch/netex-nl-cxx/process.sh | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | set -eu | ||
4 | set -o pipefail | ||
5 | |||
6 | XSD_TAG="v9.3.0-draft1" | ||
7 | |||
8 | rm -rf ./gen ./vendor/src | ||
9 | mkdir -p gen vendor/src | ||
10 | |||
11 | curl -L "https://github.com/BISONNL/NeTEx-NL/archive/refs/tags/$XSD_TAG.tar.gz" -o ./vendor/netex-nl.tar.gz | ||
12 | tar -xzf ./vendor/netex-nl.tar.gz --strip-components 1 -C ./vendor/src/ | ||
13 | |||
14 | xsltproc -o ./vendor/src/xsd/netex-nl-basic-new.xsd ./merge-enums-into-basic.xslt ./vendor/src/xsd/netex-nl-basic.xsd | ||
15 | xsltproc -o ./vendor/src/xsd/netex-nl-data-new.xsd ./remove-enums-include.xslt ./vendor/src/xsd/netex-nl-data.xsd | ||
16 | xsltproc -o ./vendor/src/xsd/netex-nl-new.xsd ./remove-enums-include.xslt ./vendor/src/xsd/netex-nl.xsd | ||
17 | rm ./vendor/src/xsd/netex-nl-enums.xsd | ||
18 | mv ./vendor/src/xsd/netex-nl-basic-new.xsd ./vendor/src/xsd/netex-nl-basic.xsd | ||
19 | mv ./vendor/src/xsd/netex-nl-data-new.xsd ./vendor/src/xsd/netex-nl-data.xsd | ||
20 | mv ./vendor/src/xsd/netex-nl-new.xsd ./vendor/src/xsd/netex-nl.xsd | ||
21 | |||
22 | process () { | ||
23 | xsdcxx cxx-tree --output-dir ./gen --namespace-map http://www.opengis.net/gml/3.2=gml "vendor/src/xsd/$1.xsd" | ||
24 | } | ||
25 | |||
26 | process gml-bison | ||
27 | process netex-nl-basic | ||
28 | process netex-nl-data | ||
29 | process netex-nl | ||
diff --git a/scratch/netex-nl-cxx/remove-enums-include.xslt b/scratch/netex-nl-cxx/remove-enums-include.xslt new file mode 100644 index 0000000..170f732 --- /dev/null +++ b/scratch/netex-nl-cxx/remove-enums-include.xslt | |||
@@ -0,0 +1,12 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
3 | <!-- Remove includes of netex-nl-enums.xsd --> | ||
4 | <xsl:template match="xsd:include[@schemaLocation='netex-nl-enums.xsd']" /> | ||
5 | |||
6 | <!-- Apply the transformation on the entire tree --> | ||
7 | <xsl:template match="@*|node()"> | ||
8 | <xsl:copy> | ||
9 | <xsl:apply-templates select="@*|node()"/> | ||
10 | </xsl:copy> | ||
11 | </xsl:template> | ||
12 | </xsl:transform> | ||