Skip to content

Remove dead wood re: SVG diagrams from the XSLT build #1744

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

Merged
merged 1 commit into from
Feb 3, 2025
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
65 changes: 0 additions & 65 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -644,72 +644,7 @@ System.getenv("PATH").split(System.getProperty("path.separator")).each { dir ->
}
}

task xslt_svg(
) {
if (dot_exec == null) {
dependsOn "xslt_copy_svg"
} else {
dependsOn "xslt_make_svg"
}
}

task xslt_make_svg(
dependsOn: ["xslt_merge_catalog", "saxon_config"],
description: "Create SVG images with GraphViz"
) {
inputs.dir "${projectDir}/style"
inputs.dir "${projectDir}/specifications/xslt-40/style"
inputs.file xslt_merge_catalog.outputs.getFiles().getSingleFile()
outputs.file "${buildDir}/xslt-40/img/fig1.svg"

doLast {
transform("${xslt_merge_catalog.outputs.getFiles().getSingleFile().toString()}",
"${projectDir}/specifications/xslt-40/style/xslt.xsl",
"${buildDir}/xslt-40/xslt-temporary.html",
["-im:make-dot-files"], null)
}

doLast {
delete "${buildDir}/xslt-40/xslt-temporary.html"
}

doLast {
new File("${buildDir}/xslt-40/img").listFiles().each { imgfile ->
def fn = imgfile.toString()
if (fn.endsWith(".dot")) {
exec {
commandLine dot_exec, "-Tsvg",
"-o${fn.replace('.dot', '.svg')}",
fn
}
delete fn
}
}
}
}

task xslt_copy_svg(
description: "Copy SVG images"
) {
inputs.dir "${projectDir}/style"
inputs.dir "${projectDir}/specifications/xslt-40/style"
outputs.file "${buildDir}/xslt-40/img/fig1.svg"

doLast {
println("GraphViz dot unavailable; copying SVG diagram(s)")
}

doLast {
copy {
from "${projectDir}/specifications/xslt-40/src"
into "${buildDir}/xslt-40/img"
include "*.svg"
}
}
}

task xslt_resources(
dependsOn: ["xslt_svg"],
description: "Copy static resources for publication"
) {
doFirst {
Expand Down
90 changes: 0 additions & 90 deletions specifications/xslt-40/style/dotml2dot.xsl

This file was deleted.

72 changes: 1 addition & 71 deletions specifications/xslt-40/style/xslt.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
xmlns:g="http://www.martin-loetzsch.de/DOTML"
exclude-result-prefixes="e xs g"
exclude-result-prefixes="e xs"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xsl:import href="../../../style/xsl-query-2016.xsl"/>
<xsl:import href="../../../style/funcproto.xsl"/>
<xsl:import href="dotml2dot.xsl"/>

<xsl:output method="xml" indent="no" encoding="utf-8"/>
<xsl:output name="xml" method="xml" indent="no" encoding="utf-8"/>
Expand Down Expand Up @@ -998,74 +996,6 @@ constructor. These elements are:</p>
</div>
</xsl:template>

<!-- Handle DotML graphs -->

<xsl:template match="/" mode="make-dot-files">
<!-- entry point for processing that only makes the .dot files -->
<xsl:for-each select=".//g:graph">
<xsl:variable name="preprocessed-graph">
<xsl:apply-templates select="." mode="preprocess-dotml"/>
</xsl:variable>
<xsl:variable name="n" select="count(preceding::g:graph) + 1"/>
<xsl:result-document href="img/fig{$n}.dot" method="text">
<!-- invoke template in imported DotML stylesheet -->
<xsl:apply-templates select="$preprocessed-graph/g:graph"/>
</xsl:result-document>
</xsl:for-each>
</xsl:template>

<xsl:template match="*/g:graph">
<!-- */g:graph so that this template doesn't match when we
are preprocessing the graphs from make-dot-files mode. -->
<xsl:variable name="n" select="count(preceding::g:graph) + 1"/>
<xsl:variable name="svgfile" select="concat('../img/fig', $n, '.svg')"/>
<xsl:variable name="svgdoc" select="doc(resolve-uri($svgfile, base-uri($root)))"/>

<xsl:apply-templates select="$svgdoc" mode="copy-svg"/>
</xsl:template>

<xsl:template match="node() | @*" mode="copy-svg">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="@*, node()" mode="copy-svg"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@contentScriptType | @contentStyleType" mode="copy-svg"/>

<xsl:function name="g:points-to-pixels" as="xs:string">
<xsl:param name="points" as="xs:string"/>
<xsl:sequence select="string(round(number(replace($points, 'pt', '')) * 1.33))"/>
</xsl:function>

<xsl:template match="g:*" mode="preprocess-dotml">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="preprocess-dotml"/>
</xsl:copy>
</xsl:template>

<xsl:template match="g:node" mode="preprocess-dotml">
<xsl:copy>
<xsl:copy-of select="@* except @edge-color"/>
<xsl:if test="empty(@id)">
<xsl:attribute name="id" select="generate-id(.)"/>
</xsl:if>
</xsl:copy>
<xsl:apply-templates mode="preprocess-dotml"/>
<xsl:for-each select="g:node">
<g:edge from="{g:node-id(..)}" to="{g:node-id(.)}" >
<xsl:if test="@edge-color">
<xsl:attribute name="color" select="@edge-color"/>
</xsl:if>
</g:edge>
</xsl:for-each>
</xsl:template>

<xsl:function name="g:node-id" as="xs:string">
<xsl:param name="node" as="element(g:node)"/>
<xsl:sequence select="($node/@id, generate-id($node))[1]"/>
</xsl:function>

<xsl:template match="eg">
<xsl:variable name="max-length"
select="max(for $line in tokenize(., '\n') return string-length($line))"/>
Expand Down