Skip to content

Commit

Permalink
improve annotations/anchor affiliation in order to enable transpect/e…
Browse files Browse the repository at this point in the history
  • Loading branch information
gimsieke committed Aug 30, 2023
1 parent fa7a31f commit d1c5a17
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
6 changes: 3 additions & 3 deletions xpl/single-tree.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<p:pipe port="result" step="locate-docx"/>
</p:variable>

<tr:store-debug>
<tr:store-debug name="sd1">
<p:with-option name="pipeline-step" select="concat('docx2hub/', $basename, '/00-file-uri')"/>
<p:with-option name="active" select="$debug"/>
<p:with-option name="base-uri" select="$debug-dir-uri"/>
Expand All @@ -135,7 +135,7 @@
<p:with-option name="overwrite" select="'yes'"/>
</tr:unzip>

<tr:store-debug>
<tr:store-debug name="sd2">
<p:with-option name="pipeline-step" select="concat('docx2hub/', $basename, '/00-unzip')"/>
<p:with-option name="active" select="$debug"/>
<p:with-option name="base-uri" select="$debug-dir-uri"/>
Expand Down Expand Up @@ -189,7 +189,7 @@
</p:input>
</p:xslt>

<tr:store-debug>
<tr:store-debug name="sd3">
<p:with-option name="pipeline-step" select="concat('docx2hub/', $basename, '/00-zip-manifest')"/>
<p:with-option name="active" select="$debug"/>
<p:with-option name="base-uri" select="$debug-dir-uri"/>
Expand Down
42 changes: 39 additions & 3 deletions xsl/comments.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:dbk="http:https://docbook.org/ns/docbook"
xmlns:wx="http:https://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:w14="http:https://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http:https://schemas.microsoft.com/office/word/2012/wordml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:pkg="http:https://schemas.microsoft.com/office/2006/xmlPackage"
xmlns:r="http:https://schemas.openxmlformats.org/officeDocument/2006/relationships"
Expand All @@ -26,7 +28,9 @@
<xsl:if test="//w:commentRangeEnd[@w:id=current()/@w:id][parent::w:tbl]">
<xsl:apply-templates select="//w:commentRangeEnd[@w:id=current()/@w:id][parent::w:tbl]" mode="#current"/>
</xsl:if>
<xsl:apply-templates select="key('comment-by-id', @w:id)" mode="comment"/>
<xsl:apply-templates select="key('comment-by-id', @w:id)" mode="comment">
<xsl:with-param name="comment-id" as="xs:string" tunnel="yes" select="@w:id"/>
</xsl:apply-templates>
</xsl:template>

<!-- dissolve single w:r with only comment(s) -->
Expand All @@ -37,9 +41,25 @@
<xsl:apply-templates mode="#current"/>
</xsl:template>

<xsl:key name="by-w14-paraId" match="*[@w14:paraId]" use="@w14:paraId">
<!-- found on w:p -->
</xsl:key>

<xsl:key name="by-w15-paraId" match="*[@w15:paraId]" use="@w15:paraId">
<!-- found on w15:commentEx in commentsExtended.xml -->
</xsl:key>

<xsl:template match="w:comment" mode="comment">
<annotation>
<xsl:if test="@w:author | @w:date | @w:initials">
<xsl:param name="comment-id" as="xs:string" tunnel="yes"/>
<xsl:variable name="para-ids" as="xs:string*" select="descendant::*/@w14:paraId"/>
<xsl:variable name="extended-info" as="element(w15:commentEx)*"
select="key('by-w15-paraId', $para-ids)/self::w15:commentEx"/>
<xsl:variable name="parent-para-ids" as="xs:string*" select="$extended-info/@w15:paraIdParent"/>
<xsl:variable name="parent-comment-ids" as="xs:string*"
select="key('by-w14-paraId', $parent-para-ids)/ancestor::w:comment[1]/@w:id"/>
<xsl:variable name="done" as="xs:string*" select="distinct-values($extended-info/@w15:done)"/>
<annotation linkend="comment_{$comment-id}">
<xsl:if test="exists(@w:author | @w:date | @w:initials) or exists($done) or exists($parent-comment-ids)">
<info>
<xsl:if test="@w:author | @w:initials">
<author>
Expand All @@ -49,6 +69,22 @@
</author>
</xsl:if>
<xsl:apply-templates select="@w:date" mode="#current"/>
<xsl:if test="exists($done) or exists($parent-comment-ids)">
<keywordset>
<xsl:if test="$done">
<keyword role="done">
<xsl:value-of select="$done" separator=" "/>
</keyword>
</xsl:if>
<xsl:if test="$parent-comment-ids">
<keyword role="parent-comment-ids">
<!-- should be at most one parent comment ID, but this is not guaranteed because the metadata
are attached to comment paras, not to a comment as a whole -->
<xsl:value-of select="for $p in $parent-comment-ids return concat('comment_', $p)" separator=" "/>
</keyword>
</xsl:if>
</keywordset>
</xsl:if>
</info>
</xsl:if>
<xsl:apply-templates select="*" mode="wml-to-dbk"/>
Expand Down
6 changes: 6 additions & 0 deletions xsl/insert-xpath.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
<xsl:apply-templates select="document(resolve-uri(current(), $base-dir))/w:comments" mode="#current"/>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="document($docRels-uri)/rel:Relationships
/rel:Relationship[@Type eq 'http:https://schemas.microsoft.com/office/2011/relationships/commentsExtended']/@Target">
<xsl:if test="doc-available(resolve-uri(current(), $base-dir))">
<xsl:apply-templates select="document(resolve-uri(current(), $base-dir))/w15:commentsEx" mode="#current"/>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates select="document(resolve-uri('fontTable.xml', $base-dir))/w:fonts" mode="#current"/>
<w:docTypes>
<xsl:apply-templates select="document(resolve-uri('../%5BContent_Types%5D.xml', $base-dir))/ct:Types" mode="#current"
Expand Down
3 changes: 2 additions & 1 deletion xsl/modules/prop-mapping/map-props.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
xmlns:word200x="http:https://schemas.microsoft.com/office/word/2003/wordml"
xmlns:wx="http:https://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:w14="http:https://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http:https://schemas.microsoft.com/office/word/2012/wordml"
xmlns:wp="http:https://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:cp="http:https://schemas.openxmlformats.org/package/2006/metadata/core-properties"
xmlns:extendedProps="http:https://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
Expand Down Expand Up @@ -204,7 +205,7 @@
</xsl:if>
<xsl:apply-templates select="../../w:numbering" mode="#current"/>
<xsl:sequence select="../../w:docRels, ../../w:footnoteRels, ../../w:endnoteRels, ../../w:commentRels, ../../w:fonts"/>
<xsl:apply-templates select="../../w:comments, ../../w:footnotes, ../../w:endnotes, ../../w:settings" mode="#current"/>
<xsl:apply-templates select="../../w:comments, ../../w15:commentsEx, ../../w:footnotes, ../../w:endnotes, ../../w:settings" mode="#current"/>
<xsl:apply-templates mode="#current"/>
<xsl:apply-templates select="../../w:footer/w:ftr[$convert-footer]" mode="#current"/>
</xsl:element>
Expand Down
4 changes: 3 additions & 1 deletion xsl/wml2dbk.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
xmlns:wp="http:https://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w14="http:https://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http:https://schemas.microsoft.com/office/word/2012/wordml"
xmlns="http:https://docbook.org/ns/docbook"
version="2.0"
exclude-result-prefixes = "w xs dbk fn r rel tr m mc docx2hub v wp">
Expand Down Expand Up @@ -450,7 +451,8 @@
| /*/w:endnoteRels
| /*/w:commentRels
| /*/w:fonts
| /*/w:comments
| /*/w:comments
| /*/w15:commentsEx
| /*/w:footnotes
| /*/w:endnotes
| mc:AlternateContent
Expand Down

0 comments on commit d1c5a17

Please sign in to comment.