Commit 222ca968 authored by Alf Eaton's avatar Alf Eaton

Fetch and use only the required XSL files

parent 9ffa2035
<?php
$urls = [
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/docx-extract/collapse-paragraphs.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/docx-extract/docx-html-extract.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/docx-extract/handle-notes.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/docx-extract/join-elements.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/docx-extract/scrub.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/html-polish/final-rinse.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/list-promote/itemize-lists.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/list-promote/mark-lists.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/header-promote/make-header-escalator-xslt.xsl',
'https://gitlab.coko.foundation/XSweet/XSweet/raw/ink-api-publish/applications/header-promote/digest-paragraphs.xsl',
'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/ink-api-publish/p-split-around-br.xsl',
'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/ink-api-publish/editoria-notes.xsl',
'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/ink-api-publish/editoria-basic.xsl',
'https://gitlab.coko.foundation/XSweet/editoria_typescript/raw/ink-api-publish/editoria-reduce.xsl',
];
$outputDir = __DIR__ . '/src/xsl';
if (!file_exists($outputDir)) {
mkdir($outputDir);
}
foreach ($urls as $url) {
$input = fopen($url, 'r');
if (!$input) {
exit("Failed opening $url\n");
}
$outputPath = $outputDir . '/' . basename($url);
$output = fopen($outputPath, 'w');
if (!$output) {
exit("Failed opening $outputPath\n");
}
print("Copying $url to $outputPath\n");
$result = stream_copy_to_stream($input, $output);
if (!$result) {
exit("Failed copying $url to $outputPath\n");
}
fclose($input);
fclose($output);
}
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsw="http://coko.foundation/xsweet"
xmlns="http://www.w3.org/1999/xhtml"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<!-- Drop on default traversal -->
<xsl:template match="@style"/>
<xsl:template match="*[matches(@style,'\S')]">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="class">
<xsl:value-of select="@class"/>
<xsl:for-each select="@style/../@class"><xsl:text> </xsl:text></xsl:for-each>
<xsl:apply-templates select="@style" mode="styleClass"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="head">
<xsl:variable name="abstracted-css">
<xsl:call-template name="rewrite-css-styles"/>
</xsl:variable>
<xsl:copy>
<xsl:apply-templates/>
<xsl:if test="matches($abstracted-css,'\S')">
<style type="text/css">
<xsl:sequence select="$abstracted-css"/>
</style>
</xsl:if>
</xsl:copy>
</xsl:template>
<xsl:template name="rewrite-css-styles">
<!-- Note that we depend on styles being in a regular order. Note they are sorted when
they are filtered by scrub.xsl in a previous step. -->
<xsl:for-each-group select="//@style" group-by="string(.)">
<xsl:text>&#xA;.</xsl:text>
<xsl:apply-templates select="." mode="styleClass"/>
<xsl:text> { </xsl:text>
<xsl:value-of select="current-grouping-key()"/>
<xsl:text> }</xsl:text>
</xsl:for-each-group>
</xsl:template>
<!-- Emits a string translating a value sequence into a @class-compatible string -->
<xsl:template match="@style" mode="styleClass">
<xsl:variable name="props" select="tokenize(., '\s*;\s*')"/>
<xsl:value-of>
<xsl:text>xsw_</xsl:text>
<!-- Since we're looking at a sequence of strings, we can't write path expressions (in 2.0). -->
<xsl:for-each select="$props[starts-with(., 'text-align:')]">
<xsl:sequence select="replace(., '(^text-align|[:\s\.])', '')"/>
</xsl:for-each>
<xsl:for-each select="$props[starts-with(., 'margin-')]">
<xsl:text>margin</xsl:text>
<xsl:sequence select="replace(., '(^margin-|[:\s\.])', '')"/>
</xsl:for-each>
<xsl:for-each select="$props[starts-with(., 'padding-')]">
<xsl:text>pad</xsl:text>
<xsl:sequence select="replace(., '(^padding-|[:\s\.])', '')"/>
</xsl:for-each>
<xsl:if test="some $p in $props satisfies matches($p,'^font-(family|size)')">font</xsl:if>
<xsl:for-each select="$props[starts-with(., 'font-family:')]">
<xsl:sequence select="replace(., '(^font-family:|\C)', '')"/>
</xsl:for-each>
<xsl:for-each select="$props[starts-with(., 'font-size:')]">
<xsl:sequence select="replace(., '(^font-size:|\C)', '')"/>
</xsl:for-each>
<xsl:for-each select="$props[starts-with(., 'text-indent:')]">
<xsl:sequence select="replace(., '(^text-|:|\C)', '')"/>
</xsl:for-each>
<xsl:for-each select="$props[matches(., '^\-?xsweet-')]">
<xsl:sequence select="replace(., '(^-?xsweet-|:|\C|\-)', '')"/>
</xsl:for-each>
<xsl:if test="$props = 'font-weight: bold'">bold</xsl:if>
<xsl:if test="$props = 'font-style: italic'">italic</xsl:if>
<xsl:if test="$props = 'text-decoration: underline'">underline</xsl:if>
<xsl:if test="$props = 'font-variant: small-caps'">smallcaps</xsl:if>
<xsl:for-each select="$props[starts-with(., 'color:')]">
<xsl:sequence select="replace(., '^color:|\C', '')"/>
</xsl:for-each>
</xsl:value-of>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
exclude-result-prefixes="#all"
version="2.0">
<xsl:import href="docx-html-extract.xsl"/>
<!-- A 'shell' stylesheet, permitting us to pass a .docx file as an input parameter,
using Java to retrieve the document.xml from inside it and process that file
through imported templates (matching elements in the w: namespace), for "extraction" output. -->
<!-- The full path (URI) to the input docx must be passed at runtime. -->
<xsl:param as="xs:string" name="docx-file-uri" required="yes"/>
<!-- Overriding imported binding yes|no -->
<xsl:param as="xs:string" name="show-css">yes</xsl:param>
<xsl:output indent="no" omit-xml-declaration="yes"/>
<xsl:variable name="document-path" select="concat('jar:',$docx-file-uri,'!/word/document.xml')"/>
<xsl:variable name="document-xml" select="document($document-path)"/>
<xsl:template name="extract">
<!-- Grabbing the document element of document.xml; imported templates will take over. -->
<xsl:apply-templates select="$document-xml/*"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsw="http://coko.foundation/xsweet"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<!-- Produces an HTML report describing (HTML) inputs. -->
<xsl:template match="/">
<xsl:call-template name="page">
<xsl:with-param name="contents">
<xsl:call-template name="analysis"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="analysis">
<div>
<h2>Elements by signature <tt style="font-size: smaller">(name.class ::: @style)</tt></h2>
<ul>
<xsl:for-each-group select="//*" group-by="xsw:signature(.)">
<xsl:sort select="count(current-group())" order="descending"/>
<li>
<span class="e"><xsl:value-of select="current-grouping-key()"/></span>
<span class="count"><xsl:value-of select="count(current-group())"/></span>
</li>
</xsl:for-each-group>
</ul>
</div>
<div>
<h2>Abstract tree hierarchy (by signature)</h2>
<xsl:call-template name="element-hierarchy"/>
</div>
</xsl:template>
<xsl:template name="element-hierarchy">
<xsl:param name="n" select="/*/*"/>
<xsl:if test="exists($n)">
<ul>
<xsl:for-each-group select="$n" group-by="xsw:signature(.)">
<li>
<span class="e">
<xsl:value-of select="current-grouping-key()"/>
</span>
<span class="count">
<xsl:value-of select="count(current-group())"/>
</span>
<xsl:call-template name="element-hierarchy">
<xsl:with-param name="n" select="current-group()/*"/>
</xsl:call-template>
</li>
</xsl:for-each-group>
</ul>
</xsl:if>
</xsl:template>
<xsl:function name="xsw:signature" as="xs:string">
<xsl:param name="n" as="element()"/>
<xsl:value-of>
<xsl:value-of select="name($n)"/>
<xsl:value-of select="$n/@class/ (for $t in (tokenize(.,'\s+')) return concat('.',$t))"/>
<xsl:for-each select="$n/@style">
<xsl:text> ::: </xsl:text>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:value-of>
</xsl:function>
<xsl:template name="page">
<xsl:param name="contents">
<xsl:apply-templates/>
</xsl:param>
<html>
<head>
<meta charset="UTF-8"><!-- comment me --></meta>
<style type="text/css">
.e { color: darkgreen; font-weight: bold }
.count { color: darkred; font-style: italic }
</style>
</head>
<body>
<xsl:copy-of select="$contents"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsw="http://coko.foundation/xsweet"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>
<!-- Stylesheet to rewrite style and class on HTML
via a template cascade - i.e., more than a single transformation
can be performed over a single element.
Ultimately this could support a little language kinda like:
where { font-size: 18pt } .FreeForm
remove { font-size } .FreeForm
add { color: red } .FreeFormNew
<where>
<match>
<style>font-size: 18pt</style>
<class>FreeForm</class>
</match>
<remove>
<style>font-size</style>
<class>FreeForm</class>
</remove>
<add>
<class>FreeFormNew</class>
<style>color: red</style>
</add>
</where>
providing mappings across @class (considered as NMTOKENS) and @style (considered as CSS property sets)
-->
<!-- How to use (until we implement a next-layer-up):
match using appropriate key for class (name), style (property or property-value)
call execute-tweak with replacement values.
Note it is possible to pass in multiple values for parameters using , and ; within style and class settings.
i.e.
<with-param name="removeStyleProperties">font-size; font-weight</with-param>
removes both the properties named.
Note also that control of style values is by property for removal (i.e., remove any/all 'font-size' property),
but by property-value pair for addition (i.e., add 'font-size: larger").
Not that you should be adding @style!
-->
<!-- Implementation of rule given above. -->
<xsl:template priority="12" match="key('elements-by-propertyValue','font-size: 18pt')
[. intersect key('elements-by-class', 'Freeform')]" >
<xsl:call-template name="makeTweak">
<xsl:with-param name="removeStyleProperties" >font-size</xsl:with-param>
<xsl:with-param name="addStylePropertyValues" >color: red</xsl:with-param>
<xsl:with-param name="removeClass" >FreeForm</xsl:with-param>
<xsl:with-param name="addClass" >FreeFormNew</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template priority="11" match="key('elements-by-propertyValue','font-family: Arial Unicode MS')">
<xsl:call-template name="makeTweak">
<xsl:with-param name="removeStyleProperties">font-family</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template priority="10" match="key('elements-by-propertyValue','text-indent: 36pt')">
<xsl:call-template name="makeTweak">
<xsl:with-param name="addClass" select="'indented'"/>
</xsl:call-template>
</xsl:template>
<!-- Infrastructure should not require modification. -->
<xsl:include href="html-tweak-lib.xsl"/>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsw="http://coko.foundation/xsweet"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<!-- See html-tweak-demo.xsl for an example of how to use this stylesheet fragment. -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template name="makeTweak">
<!-- for class, a string with , delimiters; for style, a string with ; delimiters -->
<xsl:param name="addClass" select="()" as="xs:string?"/>
<xsl:param name="removeClass" select="()" as="xs:string?"/>
<xsl:param name="addStylePropertyValues" select="()" as="xs:string?"/>
<xsl:param name="removeStyleProperties" select="()" as="xs:string?"/>
<xsl:variable name="alreadyTweaked">
<xsl:next-match/>
</xsl:variable>
<xsl:for-each select="$alreadyTweaked/*"><!-- change context to results of applying templates
which we expect to be a single (html) element -->
<xsl:copy>
<xsl:copy-of select="@* except (@class | @style)"/>
<xsl:call-template name="tweakStyle">
<xsl:with-param name="removeProperties" select="tokenize($removeStyleProperties, '\s*;\s*')"/>
<xsl:with-param name="addPropertyValues" select="tokenize($addStylePropertyValues,'\s*;\s*')"/>
</xsl:call-template>
<xsl:call-template name="tweakClass">
<xsl:with-param name="remove" select="tokenize($removeClass,'\s*,\s*')"/>
<xsl:with-param name="add" select="tokenize($addClass, '\s*,\s*')"/>
</xsl:call-template>
<xsl:copy-of select="child::node()"/>
</xsl:copy>
</xsl:for-each>
</xsl:template>
<xsl:template name="tweakClass">
<xsl:param name="remove" select="()" as="xs:string*"/>
<xsl:param name="add" select="()" as="xs:string*"/>
<xsl:if test="exists( ($add, xsw:classes(.)[not(.= $remove)] (: either $add or classes other than $remove :)))">
<xsl:attribute name="class" select="xsw:classes(.)[not(.=$remove)], $add" separator="&#32;"/>
</xsl:if>
</xsl:template>
<xsl:template name="tweakStyle">
<!-- $removeProperties are expected as 'font-size', 'text-indent' -->
<!-- $addPropertyValues are expected as 'font-size: 12pt', 'text-indent: 36pt' -->
<xsl:param name="removeProperties" select="()" as="xs:string*"/>
<xsl:param name="addPropertyValues" select="()" as="xs:string*"/>
<xsl:variable name="oldPropertyValues" select="xsw:style-propertyValues(.)"/>
<xsl:variable name="newPropertyValues"
select="$oldPropertyValues[not(replace(.,':.*$','') = $removeProperties)],
$addPropertyValues"/>
<xsl:if test="exists($newPropertyValues)">
<xsl:attribute name="style">
<xsl:for-each select="$newPropertyValues">
<xsl:sort data-type="text"/>
<xsl:if test="position() gt 1">; </xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
</xsl:template>
<xsl:function name="xsw:classes" as="xs:string*">
<xsl:param name="e" as="element()"/>
<xsl:sequence select="tokenize($e/@class/normalize-space(.),'\s')"/>
</xsl:function>
<xsl:function name="xsw:style-properties" as="xs:string*">
<!-- Returns 'font-family','font-size','color','text-indent' whatever
properties are defined on @style -->
<xsl:param name="e" as="element()"/>
<xsl:sequence select="for $propVal in xsw:style-propertyValues($e)
return substring-before($propVal,':')"/>
</xsl:function>
<xsl:function name="xsw:style-propertyValues" as="xs:string*">
<!-- Returns 'font-family: Helvetica','font-size: 10pt' whatever
properties are defined on @style -->
<xsl:param name="e" as="element()"/>
<xsl:sequence select="tokenize($e/@style/normalize-space(.),'\s*;\s*')"/>
</xsl:function>
<!--<xsl:function name="xsw:hasClass" as="xs:boolean">
<xsl:param name="e" as="element()"/>
<xsl:param name="c" as="xs:string"/>
<xsl:sequence select="xsw:classes($e) = $c"/>
</xsl:function>-->
<xsl:key name="elements-by-class" match="*[matches(@class,'\S')]" use="xsw:classes(.)"/>
<xsl:key name="elements-by-property" match="*[matches(@style,'\S')]" use="xsw:style-properties(.)"/>
<xsl:key name="elements-by-propertyValue" match="*[matches(@style,'\S')]" use="xsw:style-propertyValues(.)"/>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Requests a tool use HTML5 serialization rules. -->
<xsl:output method="html" html-version="5" indent="no"/>
<!-- Otherwise, just copies. -->
<xsl:mode on-no-match="deep-copy"/>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsw="http://coko.foundation/xsweet"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>
<xsl:template match="* | @* | processing-instruction() | comment()">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<!-- Deprecating these ... since @style info is factored out ...
<xsl:template match="span[@style='font-family: Helvetica'][empty(@class)]">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@style[.='font-family: Helvetica']"/> -->
<xsl:variable name="tlds" as="xs:string" expand-text="true">(com|org|net|gov|mil|edu|io|foundation)</xsl:variable>
<xsl:variable name="urlchar" as="xs:string" expand-text="true">[\w\-_]</xsl:variable>
<xsl:variable name="domain" as="xs:string" expand-text="true">({$urlchar}+\.)</xsl:variable>
<xsl:variable name="url-match" as="xs:string" expand-text="true">((http|ftp|https):/?/?)?{$domain}+{$tlds}</xsl:variable>
<xsl:template match="text()">
<xsl:analyze-string select="." regex="{$url-match}">
<!--(https?:)?(\w+\.)?(\w+)\.(\w\w\w)-->
<xsl:matching-substring>
<xsl:variable name="has-protocol" select="matches(.,'^https?://')"/>
<a href="{'http://'[not($has-protocol)]}{regex-group(0)}">
<xsl:value-of select="."/>
</a>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
<!--<xsl:template match="text()[matches(.,'^https?:')][string(.) castable as xs:anyURI][empty(ancestor::a)]">
<a href="{encode-for-uri(.)}">
<xsl:value-of select="."/>
</a>
</xsl:template>-->
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsw="http://coko.foundation/xsweet"
exclude-result-prefixes="#all">
<xsl:output indent="yes"/>
<!-- Stylesheet transforms a rough transformation spec for HTML
(affecting @style and @class only) into an XSLT executable.
So you can write simple maps for your HTML and have the XSLT written for you behind the scenes.
-->
<!--
<where>
<match>
<style>font-size: 18pt</style>
<class>FreeForm</class>
</match>
<remove>
<style>font-size</style>
<class>FreeForm</class>
</remove>
<add>
<class>FreeFormNew</class>
<style>color: red</style>
</add>
</where>
-->
<xsl:namespace-alias stylesheet-prefix="xsw" result-prefix="xsl"/>
<xsl:param name="debug-mode" as="xs:string">silent</xsl:param>
<xsl:template match="/*">
<!-- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsw="http://coko.foundation/xsweet"
xmlns="http://www.w3.org/1999/xhtml"
-->
<xsw:stylesheet version="2.0" exclude-result-prefixes="#all">
<!--<xsw:template match="node() | @*">
<xsw:copy>
<xsw:apply-templates select="node() | @*"/>
</xsw:copy>
</xsw:template>
<xsl:apply-templates select="div[@class='grouped']/div[@class='hX']/*" mode="xslt-produce"/>
<xsl:if test="not($debug-mode='silent')">
<xsw:variable name="in">
<xsl:copy-of select="div"/>
</xsw:variable>
</xsl:if>
-->
<xsl:apply-templates mode="xslt-produce"/>
<xsw:include href="{resolve-uri('html-tweak-lib.xsl',document-uri(document('')) )}"/>
</xsw:stylesheet>
</xsl:template>
<!-- Template writes XSLT templates -->
<!--
<where>
<match>
<style>font-size: 18pt</style>
<class>FreeForm</class>
</match>
<remove>
<style>font-size</style>
<class>FreeForm</class>
</remove>
<add>
<class>FreeFormNew</class>
<style>color: red</style>
</add>
</where>
-->
<xsl:template match="where" mode="xslt-produce">
<xsw:template priority="{count(.|following-sibling::where)}">
<xsl:attribute name="match">
<xsl:apply-templates mode="keyPattern" select="match/*[1]"/>
<xsl:for-each select="match/*[1]/following-sibling::*">
<xsl:text>[. intersect </xsl:text>
<xsl:apply-templates mode="keyPattern" select="."/>
<xsl:text>]</xsl:text>
</xsl:for-each>
</xsl:attribute>
<!--match="key('elements-by-propertyValue','font-size: 18pt')
[. intersect key('elements-by-class', 'Freeform')]" >-->
<xsw:call-template name="makeTweak">
<!--<xsw:with-param name="removeStyleProperties" >font-size</xsw:with-param>
<xsw:with-param name="addStylePropertyValues" >color: red</xsw:with-param>
<xsw:with-param name="removeClass" >FreeForm</xsw:with-param>
<xsw:with-param name="addClass" >FreeFormNew</xsw:with-param>-->
<xsl:apply-templates select="(add | remove)/(class | style)" mode="tweakParams"/>
</xsw:call-template>
</xsw:template>
</xsl:template>
<xsl:template match="match/style[matches(.,':')]" priority="2" mode="keyPattern">
<xsl:text>key('elements-by-propertyValue','</xsl:text>
<xsl:apply-templates/>
<xsl:text>')</xsl:text>
</xsl:template>
<xsl:template match="match/style" priority="1" mode="keyPattern">
<xsl:text>key('elements-by-property','</xsl:text>
<xsl:apply-templates/>
<xsl:text>')</xsl:text>
</xsl:template>
<xsl:template match="match/class" mode="keyPattern">
<xsl:text>key('elements-by-class','</xsl:text>
<xsl:apply-templates/>
<xsl:text>')</xsl:text>
</xsl:template>
<xsl:template match="remove/class" mode="tweakParams">
<xsw:with-param name="removeClass">
<xsl:apply-templates/>
</xsw:with-param>
</xsl:template>
<xsl:template match="add/class" mode="tweakParams">
<xsw:with-param name="addClass">
<xsl:apply-templates/>
</xsw:with-param>
</xsl:template>
<xsl:template match="remove/style" mode="tweakParams">
<xsw:with-param name="removeStyleProperties">
<xsl:apply-templates/>
</xsw:with-param>
</xsl:template>
<xsl:template match="add/style" mode="tweakParams">
<xsw:with-param name="addStylePropertyValues">
<xsl:apply-templates/>
</xsw:with-param>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsw="http://coko.foundation/xsweet"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<xsl:output method="text"/>
<!-- We don't actually have to copy anything but in case we run
in XProc we actually need to emit XML despite aiming for plain text.
So we copy the document element. (Its tagging will be dropped when
the result is serialized with method 'text.) -->
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<!-- Elements directly under 'div' get 2 x LF -->
<xsl:template match="div/*">
<xsl:text>&#xA;&#xA;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:xsw="http://coko.foundation/xsweet"
exclude-result-prefixes="#all">
<!-- Indent should really be no, but for testing. -->
<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>
<xsl:param as="xs:string" name="show-css">yes</xsl:param>
<!-- Turn $show-css to 'yes' to switch on $css-reflect. -->
<!-- $show-css supplements the traversal with @style markers wherever certain
kinds of formatting (e.g. font shift indicators including the spurious font shifts
left in by word processors) are indicated in the text; it can be very noisy. -->
<xsl:variable as="xs:boolean" name="css-reflect" select="$show-css='yes'"/>