Thanks Hussein that's really helpful. I'm definitely going to put this code in a custom script now that I've got it working - thanks for your pointers on this front.
Damian On Fri, 13 Sep 2019 at 08:19, Hussein Shafie <[email protected]> wrote: > 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 > -- *Damian Cannon | Senior Developer | Scribestar Limited* T: +44 (0) 208 528 1494 | [email protected] 11th Floor, 88 Wood Street, London, EC2V 7RS [image: Inline images 1] -- Scribestar Limited is a company registered in England and Wales. Registered number: 06935972. Registered office: Suite 202, Central Point, 45 Beech Street, London, EC2Y 8AD. This message is private and confidential. If you have received this message in error please remove it from your system. You must not disclose, copy or distribute the contents of this email or any attachments to any other person nor use its contents or the content in any attachments in any way or you may be acting unlawfully.
-- XMLmind Word To XML Support List [email protected] https://www.xmlmind.com/mailman/listinfo/w2x-support
