Commit 37dd0fb0 authored by Wendell Piez's avatar Wendell Piez
Browse files

Adding 'input' to scrub list; silencing Saxon warnings on child:: traversal;...

Adding 'input' to scrub list; silencing Saxon warnings on child:: traversal; initial support for numlist sniffing from numbering.xml; pipeline tweakage
parent 36ec4971
<?xml version="1.0" encoding="UTF-8"?>
<project version="19.0">
<project version="20.1">
<meta>
<filters directoryPatterns="" filePatterns="XSweet-away.xpr" positiveFilePatterns="" showHiddenFiles="false"/>
<options/>
</meta>
<projectTree name="XSweet-away.xpr">
<folder path="../HTMLevator/"/>
<folder path="."/>
<file name="../../OSCAL-working/SP800-171/CUI-SSP-Template-final.docx"/>
</projectTree>
</project>
\ No newline at end of file
......@@ -47,7 +47,7 @@
<p:pipe port="result" step="analysis"/>
</p:output>
<p:serialization port="_Z_FINAL" indent="true" omit-xml-declaration="true"/>
<p:serialization port="_Z_FINAL" indent="false" omit-xml-declaration="true"/>
<p:serialization port="_0_ooxml_document" indent="true" omit-xml-declaration="true"/>
<p:serialization port="_A_extracted" indent="true" omit-xml-declaration="true"/>
<p:serialization port="_B_arranged" indent="true" omit-xml-declaration="true"/>
......@@ -64,7 +64,9 @@
<p:import href="docx-extract/docx-document-production.xpl"/>
<!-- docx-file-uri must be a URI, not a simple file name (path) -->
<p:variable name="document-path" select="concat('jar:',$docx-file-uri,'!/word/document.xml')"/>
<!--<p:variable name="document-xml" select="doc($document-path)"/>-->
<!-- Validate HTML5 results here: http://validator.w3.org/nu/ -->
......@@ -72,7 +74,6 @@
<p:with-option name="href" select="$document-path"/>
</p:load>
<xsw:docx-document-production name="document-production"/>
<p:identity name="mapped"/>
......
......@@ -30,10 +30,11 @@
<!-- Indent should really be no, but for testing. -->
<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>
<xsl:variable name="endnotes-file" select="resolve-uri('endnotes.xml', document-uri(/))"/>
<xsl:variable name="footnotes-file" select="resolve-uri('footnotes.xml', document-uri(/))"/>
<xsl:variable name="styles-file" select="resolve-uri('styles.xml', document-uri(/))"/>
<xsl:variable name="rels-file" select="resolve-uri('_rels/document.xml.rels', document-uri(/))"/>
<xsl:variable name="endnotes-file" select="resolve-uri('endnotes.xml', document-uri(/))"/>
<xsl:variable name="footnotes-file" select="resolve-uri('footnotes.xml', document-uri(/))"/>
<xsl:variable name="styles-file" select="resolve-uri('styles.xml', document-uri(/))"/>
<xsl:variable name="numbering-file" select="resolve-uri('numbering.xml', document-uri(/))"/>
<xsl:variable name="rels-file" select="resolve-uri('_rels/document.xml.rels', document-uri(/))"/>
<xsl:variable name="docx-base" select="resolve-uri('.', document-uri(/))"/>
<!-- We have no interest in stylesWithEffects.xml. -->
......@@ -41,6 +42,7 @@
<!--<xsl:variable name="endnotes-file" select="'x'"/>
<xsl:variable name="styles-file" select="'x'"/>-->
<!-- If no styles are found we get a root (temporary tree) w/ no branches. -->
<xsl:variable name="endnotes-doc">
<xsl:if test="doc-available($endnotes-file)">
<xsl:sequence select="doc($endnotes-file)"/>
......@@ -53,22 +55,30 @@
</xsl:if>
</xsl:variable>
<!-- If no styles are found we get a root (temporary tree) w/ no branches. -->
<xsl:variable name="styles">
<xsl:if test="doc-available($styles-file)">
<xsl:sequence select="doc($styles-file)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="numbering">
<xsl:if test="doc-available($numbering-file)">
<xsl:sequence select="doc($numbering-file)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="relations-doc">
<xsl:if test="doc-available($rels-file)">
<xsl:sequence select="doc($rels-file)"/>
</xsl:if>
</xsl:variable>
<xsl:key name="styles-by-id" match="w:style" use="@w:styleId"/>
<xsl:key name="numbering-by-id" match="w:num" use="@w:numId"/>
<xsl:key name="abstract-numbering-by-id" match="w:abstractNum" use="@w:abstractNumId"/>
<xsl:key name="rels-by-id" match="rel:Relationship" use="@Id"/>
<!-- Reinstate footnotes handling when we have some. -->
......@@ -199,7 +209,7 @@
<!-- Echoing XSweet properties as semantic data-* attributes -->
<xsl:variable name="semantic-properties"
select="tokenize($style, '\s*;\s*')[matches(., 'xsweet-(outline|list)-level')]"/>
select="tokenize($style, '\s*;\s*')[matches(., 'xsweet-|mso-')]"/>
<xsl:for-each select="$semantic-properties">
<xsl:attribute name="data-{ replace(., ':.*$', '')}">
<xsl:value-of select=". ! replace(., '.*:\s*', '')"/>
......@@ -222,7 +232,15 @@
<!-- br documented at http://officeopenxml.com/WPtextSpecialContent-break.php -->
<xsl:template match="w:fldChar"/>
<!--<xsl:template match="w:fldChar"/>-->
<xsl:template match="w:checkBox">
<input type="checkbox">
<xsl:if test="w:default/@w:val='1'">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:template>
<xsl:template match="w:br">
<br class="br"/>
......@@ -568,17 +586,49 @@
<!--<w:ilvl w:val="0"/>-->
<xsl:template mode="build-properties" as="element(xsw:prop)*" match="w:numPr">
<xsl:template mode="build-properties" as="element()*" match="w:numPr">
<!-- not determining numbering type yet, which requires a traversal to numbering.xml -->
<xsw:prop name="xsweet-list-type">numbered</xsw:prop>
<xsl:apply-templates mode="#current">
<xsl:with-param name="num-level" tunnel="true" select="w:ilvl/@w:val"/>
</xsl:apply-templates>
</xsl:template>
<!-- w:numPr/w:numId points to a numbering style;
nb we are now tunneling $num-level -->
<xsl:template mode="build-properties" as="element()*" match="w:numId">
<xsl:apply-templates select="key('numbering-by-id',@w:val,$numbering)" mode="#current"/>
</xsl:template>
<xsl:template mode="build-properties" as="element()*" match="w:num">
<xsl:apply-templates mode="#current"/>
</xsl:template>
<xsl:template mode="build-properties" as="element(xsw:prop)*" match="w:ilvl">
<xsl:apply-templates mode="#current" select="@w:val"/>
<!-- In the numbering specification w:num contains only w:abstractNumId and w:lvlOverride; when it is given, only the override is used -->
<xsl:template mode="build-properties" as="element()*" match="w:num[exists(w:lvlOverride)]/w:abstractNumId"/>
<!-- If it is used, abstractNumId redirects to an abstract numbering format -->
<xsl:template mode="build-properties" as="element()*" match="w:abstractNumId">
<xsl:apply-templates select="key('abstract-numbering-by-id',@w:val,$numbering)" mode="#current"/>
</xsl:template>
<xsl:template mode="build-properties" as="element(xsw:prop)*" match="w:ilvl/@w:val">
<xsw:prop name="xsweet-list-level"><xsl:value-of select="."/></xsw:prop>
<xsl:template mode="build-properties" as="element()*" match="w:abstractNum">
<!-- num-level will be a w:numPr/w:ilvl/@w:val set on the paragraph -->
<xsl:param name="num-level" tunnel="true"/>
<!-- getting properties from the appropriate w:lvl spec -->
<xsl:apply-templates select="w:lvl[@w:ilvl=$num-level]" mode="#current"/>
</xsl:template>
<xsl:template mode="build-properties" as="element()*" match="w:lvl">
<xsl:apply-templates mode="#current"/>
</xsl:template>
<xsl:template mode="build-properties" as="element(xsw:prop)*" match="w:lvl/w:numFmt">
<xsw:prop name="mso-list-format"><xsl:value-of select="@w:val"/></xsw:prop>
</xsl:template>
<!-- We no longer report nominal list levels, since they don't reliably report the "apparent" (i.e., actual) nesting: two lists of two types can be mashed up to show different nominal levels at the same indent level -->
<xsl:template mode="build-properties" as="element(xsw:prop)*" match="w:spacing">
<xsl:apply-templates mode="#current" select="@w:before | @w:after"/>
......@@ -592,7 +642,7 @@
</xsl:template>
<!-- Suppress @w:left when there is a @w:hanging .... -->
<xsl:template mode="build-properties" priority="2" as="element(xsw:prop)*" match="w:ind[matches(@w:hanging,'\S')]/@w:left"/>
<!--<xsl:template mode="build-properties" priority="2" as="element(xsw:prop)*" match="w:ind[matches(@w:hanging,'\S')]/@w:left"/>-->
<!-- With apologies, not supporting other values of text alignment in Word. -->
<xsl:template priority="2" mode="build-properties" as="element(xsw:prop)*" match="w:jc[@w:val=('left','right','center','both')]">
......
......@@ -35,7 +35,7 @@
<!-- Retrieveing endnotes, keep only those that are referenced, in their order of reference. -->
<xsl:template match="div[@class='docx-endnotes']">
<xsl:variable name="notes" select="div[@class='docx-endnote']"/>
<xsl:variable name="notes" select="child::div[@class='docx-endnote']"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<!-- We only capture end notes that have actually been referenced, in their order of referencing. -->
......@@ -48,7 +48,7 @@
</xsl:template>
<xsl:template match="div[@class='docx-footnotes']">
<xsl:variable name="notes" select="div[@class='docx-footnote']"/>
<xsl:variable name="notes" select="child::div[@class='docx-footnote']"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:for-each
......
......@@ -61,7 +61,7 @@
this includes <b> </b> and <b><tab/></b> -->
<xsl:template priority="5" match="img | br | hr">
<xsl:template priority="5" match="img | br | hr | input">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
......
......@@ -4,7 +4,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0"
type="xsw:html-header-promote" name="html-header-promote">
type="xsw:html-list-promote" name="html-list-promote">
<!-- XSweet: XProc implementation of two-step list promotion pipeline. -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment