On 09/12/2019 03:45 PM, Damian Cannon wrote:
After some further analysis I've determined that it's not actually
necessary to modify Ref fields to Hyperlinks in the original document.
Instead it's possible to modify the topic.xslt template in a minor way
to handle the different anchor elements that are supplied to the
template for Ref and Hyperlink fields:
e.g.
Ref field: <a xmlns="http://www.w3.org/1999/xhtml" class="role-xref"
href="#step_reference" title="Conversion step reference"/>
Hyperlink field: <a xmlns="http://www.w3.org/1999/xhtml"
href="#option_p">–p</a>
The change that I've made to the topic.xslt is to insert this code
within the processXref named template:
<!-- If title is populated for xref element then extract the text -->
<xsl:if test="@class = 'role-xref'">
<xsl:variable name="title" select="normalize-space(@title)"/>
<xsl:choose>
<xsl:when test="$title != ''">
<xsl:value-of select="$title"/>
</xsl:when>
</xsl:choose>
</xsl:if>
I don't know if this is of interest to you but I thought that I'd
mention my solution to the problem.
NB I know that there is a more elegant way to override these template
matches than directly modifying your templates but I'm having some
trouble getting that working for map creation.
In its principle, there is no best way to do this. The code you wrote is
just fine.
Now if you want your customization to survive upgrades, it's best not to
directly modify the stock W2X_install_dir/xslt/topic.xslt.
Instead run:
w2x -f map.options in_docx_file out_file
where "map.options" contains:
---
-o map
-t custom_topic.xslt
---
and also possibly other w2x options.
and where "custom_topic.xslt" (found in the same directory as
"map.options") contains:
---
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="h">
<xsl:import href="w2x:xslt/topic.xslt"/>
<xsl:template name="processXref">
<!-- YOUR CUSTOM processXref HERE -->
</xsl:template>
</xsl:stylesheet>
---
("map.options" is usable as is in w2x-app too.)
All this is explained in "A custom XSLT stylesheet",
https://www.xmlmind.com/w2x/_distrib/doc/manual/index.html#general_customize_semantic_xml
--
XMLmind Word To XML Support List
w2x-support@xmlmind.com
https://www.xmlmind.com/mailman/listinfo/w2x-support