Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions distribution/seed/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
<exclude>wiki/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/${project.artifactId}</outputDirectory>
<includes>
<include>distribution/seed/id.xsl</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/${project.artifactId}</outputDirectory>
Expand Down
27 changes: 27 additions & 0 deletions distribution/seed/id.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- identity transformation with Selene node tracing capability -->
<xsl:package name="https://scdh.github.io/dts-transformations/xsl/id.xsl" package-version="1.0.0"
version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:trace="http://wwu.de/scdh/selection-engine/node-tracing"
xpath-default-namespace="http://www.tei-c.org/ns/1.0" default-mode="tei">

<xsl:mode name="tei" on-no-match="shallow-copy" visibility="public"/>

<xsl:use-package name="http://wwu.de/scdh/selection-engine/node-tracing" package-version="1.0.0"/>

<xsl:template match="/">
<xsl:call-template name="trace:root"/>
</xsl:template>

<xsl:template match="element()">
<xsl:copy>
<xsl:call-template name="trace:source-id"/>
<xsl:apply-templates select="node() | attribute() | comment() | processing-instruction()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="text()">
<xsl:call-template name="trace:text"/>
</xsl:template>

</xsl:package>
82 changes: 80 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,83 @@
</fileMapper>
</fileMappers>
</transformationSet>

<transformationSet>
<!-- generate configuration for SEED XML Transformer for chained transformations in mapping transformations -->
<dir>${project.basedir}</dir>
<!-- Include every transformation resource for the SEED XML Transformer
in an <include>path</include> element! -->
<includes>
<include>distribution/seed/id.xsl</include>
</includes>
<parameters>
<parameter>
<name>saxon-config-uri</name>
<value>${project.basedir}/saxon.xml</value>
</parameter>
<parameter>
<name>id-prefix</name>
<value>${project.artifactId}</value>
</parameter>
<parameter>
<name>media-type</name>
<value>application/tei+xml</value>
</parameter>
<parameter>
<!-- This is a SeleneSelectorMapper! -->
<name>type</name>
<value>SeleneSelectorMapper</value>
</parameter>
</parameters>
<stylesheet>${seed-config-xsl.url}</stylesheet>
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.chain.json</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
<transformationSet>
<!-- generate chained configuration for distribution/seed/id.xsl -->
<dir>${project.basedir}</dir>
<includes>
<include>distribution/seed/id.xsl</include>
</includes>
<parameters>
<parameter>
<name>document-config-uri</name>
<value>${seed-json-config.dir}/xsl/document.seed.json</value>
</parameter>
<parameter>
<name>chained-config-uri</name>
<value>${seed-json-config.dir}/distribution/seed/id.chain.json</value>
</parameter>
<parameter>
<name>media-type-package</name>
<value>https://scdh.github.io/dts-transformations/xsl/id.xsl</value>
</parameter>
<parameter>
<name>media-type-package-version</name>
<value>1.0.0</value>
</parameter>
<parameter>
<name>media-type-component</name>
<value>mode</value>
</parameter>
<parameter>
<name>media-type-processor</name>
<value>tei</value>
</parameter>
</parameters>
<stylesheet>${seed-chain-xsl.url}</stylesheet>
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.seed.json</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>

<transformationSet>
<!-- merge all SEED configurations together -->
<dir>${project.basedir}</dir>
Expand All @@ -547,7 +624,7 @@
<parameters>
<parameter>
<name>json-files-csv</name>
<value>file:${project.build.directory}/generated-resources/xml/xslt/pom.xsl.json,${project.basedir}/distribution/seed/collection.seed.json</value>
<value>file:${project.build.directory}/generated-resources/xml/xslt/pom.xsl.json,${project.basedir}/distribution/seed/collection.seed.json,${project.build.directory}/generated-resources/xml/xslt/distribution/seed/id.seed.json</value>
</parameter>
</parameters>
<stylesheet>${seed-merge-xsl.url}</stylesheet>
Expand All @@ -558,6 +635,7 @@
</fileMapper>
</fileMappers>
</transformationSet>
<!-- testing package -->
<transformationSet>
<!-- generate configuration for SEED XML Transformer for chained transformations in test package -->
<dir>${project.basedir}</dir>
Expand Down Expand Up @@ -633,7 +711,7 @@
<parameters>
<parameter>
<name>json-files-csv</name>
<value>file:${project.build.directory}/generated-resources/xml/xslt/pom.xsl.json,${project.basedir}/distribution/seed/collection.seed.json,file:${project.build.directory}/generated-resources/xml/xslt/test/media-type/tei2txt.seed.json</value>
<value>file:${project.build.directory}/generated-resources/xml/xslt/pom.xsl.json,${project.basedir}/distribution/seed/collection.seed.json,file:${project.build.directory}/generated-resources/xml/xslt/test/media-type/tei2txt.seed.json,file:${project.build.directory}/generated-resources/xml/xslt/distribution/seed/id.seed.json</value>
</parameter>
</parameters>
<stylesheet>${seed-merge-xsl.url}</stylesheet>
Expand Down
18 changes: 18 additions & 0 deletions test/post-proc-apply.xsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
<!-- example XSLT package for post-processing using a mode as entry point

The template set from the mode declared as media-type-processor is applied to
the nodes extracted by dts:cut-ref($ref) dts:cut-start-end($start, $end) or
the whole document.

If no mode is declared as media-type-processor, the package's default mode
(here 'post-proc') is used. Also see post-proc-apply.xspec!

Note, that templates have access to the following tunnel parameters:

<xsl:param name="mediaType" as="xs:string?" tunnel="true"/>
<xsl:param name="resource" as="xs:string?" tunnel="true"/>
<xsl:param name="tree" as="xs:string?" tunnel="true"/>
<xsl:param name="ref" as="xs:string?" tunnel="true"/>
<xsl:param name="start" as="xs:string?" tunnel="true"/>
<xsl:param name="end" as="xs:string?" tunnel="true"/>
<xsl:param name="document-root" as="document-node()" tunnel="true"/>

-->
<xsl:package name="https://scdh.github.io/dts-transformations/xsl/post-proc-apply.xsl"
package-version="1.0.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Expand Down
8 changes: 5 additions & 3 deletions test/post-proc-apply.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
<x:scenario label="$ref on matt.xml results in dts:wrapper element in TEI root">
<x:param name="ref" select="'Matt:2'"/>
<x:context href="matt.xml"/>
<x:expect label="TEI root element" test="exists(/*/self::t:TEI)"/>
<x:expect label="has /TEI/dts:wrapper" test="exists(/t:TEI/dts:wrapper)"/>
<x:expect label="/TEI has only on child element" test="count(/t:TEI/*)" select="1"/>
<x:expect label="no TEI root element" test="exists(//t:TEI) => not()"/>
<x:expect label="has no /TEI/dts:wrapper" test="exists(//dts:wrapper) => not()"/>
<x:expect label="selected div at root" test="exists(/*/self::t:div)"/>
<x:expect label="selected div has label 2" test="/*/self::t:div/@n ! string(.)" select="'2'"
/>
</x:scenario>

<x:scenario
Expand Down
6 changes: 5 additions & 1 deletion test/post-proc-call.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
<!-- entry point called from document.xsl -->
<xsl:template name="post-proc" visibility="public">
<xsl:param name="nodes" as="node()*"/>
<xsl:param name="mediaType" as="xs:string" tunnel="true"/>
<xsl:param name="mediaType" as="xs:string?" tunnel="true"/>
<xsl:param name="resource" as="xs:string?" tunnel="true"/>
<xsl:param name="tree" as="xs:string?" tunnel="true"/>
<xsl:param name="ref" as="xs:string?" tunnel="true"/>
<xsl:param name="start" as="xs:string?" tunnel="true"/>
<xsl:param name="end" as="xs:string?" tunnel="true"/>
<xsl:param name="document-root" as="document-node()" tunnel="true"/>

<!-- do what ever you want -->
Expand Down
8 changes: 5 additions & 3 deletions test/post-proc-call.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
<x:scenario label="$ref on matt.xml results in dts:wrapper element in TEI root">
<x:param name="ref" select="'Matt:2'"/>
<x:context href="matt.xml"/>
<x:expect label="TEI root element" test="exists(/*/self::t:TEI)"/>
<x:expect label="has /TEI/dts:wrapper" test="exists(/t:TEI/dts:wrapper)"/>
<x:expect label="/TEI has only on child element" test="count(/t:TEI/*)" select="1"/>
<x:expect label="no TEI root element" test="exists(/*/self::t:TEI) => not()"/>
<x:expect label="has no /TEI/dts:wrapper" test="exists(/t:TEI/dts:wrapper) => not()"/>
<x:expect label="selected div at root" test="exists(/*/self::t:div)"/>
<x:expect label="selected div has label 2" test="/*/self::t:div/@n ! string(.)" select="'2'"
/>
</x:scenario>

<x:scenario
Expand Down
6 changes: 5 additions & 1 deletion test/post-proc-fun.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
<!-- entry point called from document.xsl -->
<xsl:function name="dts:post-proc" as="node()*" visibility="public">
<xsl:param name="nodes" as="node()*"/>
<xsl:param name="mediaType" as="xs:string"/>
<xsl:param name="mediaType" as="xs:string?"/>
<xsl:param name="resource" as="xs:string?"/>
<xsl:param name="tree" as="xs:string?"/>
<xsl:param name="ref" as="xs:string?"/>
<xsl:param name="start" as="xs:string?"/>
<xsl:param name="end" as="xs:string?"/>
<xsl:param name="document-root" as="document-node()"/>

<!-- do what ever you want -->
Expand Down
10 changes: 6 additions & 4 deletions test/post-proc-fun.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@

<x:param name="media-type-component" select="'function'" static="true"/>

<x:param name="media-type-processor" select="'dts:post-proc#4'" static="true"/>
<x:param name="media-type-processor" select="'dts:post-proc#8'" static="true"/>

<x:scenario label="$ref on matt.xml results in dts:wrapper element in TEI root">
<x:param name="ref" select="'Matt:2'"/>
<x:context href="matt.xml"/>
<x:expect label="TEI root element" test="exists(/*/self::t:TEI)"/>
<x:expect label="has /TEI/dts:wrapper" test="exists(/t:TEI/dts:wrapper)"/>
<x:expect label="/TEI has only on child element" test="count(/t:TEI/*)" select="1"/>
<x:expect label="no TEI root element" test="exists(//t:TEI) => not()"/>
<x:expect label="has no /TEI/dts:wrapper" test="exists(//t:TEI/dts:wrapper) => not()"/>
<x:expect label="selected div at root" test="exists(/*/self::t:div)"/>
<x:expect label="selected div has label 2" test="/*/self::t:div/@n ! string(.)" select="'2'"
/>
</x:scenario>

<x:scenario
Expand Down
Loading
Loading