Page 1 of 1

Map Information with XHTML

Posted: Thu Mar 14, 2024 7:30 pm
by gbv34
Hello guys!
I have spent some time on this one and I don't think it is directly related to DITA-OT but rather a way to gather info from a map during an XHTML transformation.
For the info, the same principles described below worked well in html5.

My XSLT uses a param defined in an external xml file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<params xmlns:if="ant:if">
    <param name="input.map.url" expression="${xhtml.map.url}" if:set="xhtml.map.url"/>
</params>
During the transformation, my xslt needs to output info about the map:

Code: Select all

<!-- map URL -->
<xsl:param name="input.map.url" as="xs:string?"/>
<!-- map document  -->
<xsl:variable name="mapDoc" as="document-node()?">
    <xsl:apply-templates select="document($input.map.url)" mode="normalize-map"/>
</xsl:variable>
<!-- Root template -->
<xsl:template match="/">
    <xsl:message>Value of input.map.url: <xsl:value-of select="$input.map.url"/></xsl:message>
    <xsl:if test="$input.map.url">
        <xsl:if test="$mapDoc">
            <xsl:message>Document loaded successfully.</xsl:message>
        </xsl:if>
        <xsl:if test="not($mapDoc)">
            <xsl:message>Error loading the document at <xsl:value-of select="$input.map.url"/>.</xsl:message>
        </xsl:if>
    </xsl:if>
    <xsl:if test="not($input.map.url)">
        <xsl:message>Error: input.map.url parameter is not set.</xsl:message>
    </xsl:if>
    <xsl:apply-templates/>
</xsl:template>

However, I don't retrieve any relevant info in the logs, as if the map url wouldn't be retrieved.
Any suggestion or pointers would be highly appreciated. Would you have a plugin example to share with me that would be able to provide info from a map? Thanks a lot for your support!

Re: Map Information with XHTML

Posted: Fri Mar 15, 2024 8:56 am
by Radu
Hi Gaspard,
You did not give enough information about how your XSLT is called from the build files.
Is your XSLT stylesheet getting called at all? If you make it not wellformed XML, maybe remove a "<" from it and publish do you get an error reported that the XSLT is invalid?
If it is used, looking inside the XSLT you seem to attempt to load the document early on, before you attempt to debug the problem using xsl:messages:

Code: Select all

<xsl:variable name="mapDoc" as="document-node()?">
    <xsl:apply-templates select="document($input.map.url)" mode="normalize-map"/>
</xsl:variable>
Regards,
Radu

Re: Map Information with XHTML

Posted: Fri Mar 15, 2024 11:50 am
by gbv34
Hi Radu,
Yes, my XSLT is called in the plugin.xml as well as the param used to retrieve the map url:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<plugin id="com.antidot.othermeta.xhtml">
    <feature extension="dita.conductor.xhtml.param" file="buildXhtmlParam.xml"/>
    <feature extension="dita.xsl.xhtml" file="./xsl/get-move-othermeta.xsl"/>
</plugin>
Basically, I have the same plugin used for an HTML5 transtype and it worked well.
The difference lies in the map.url for the XHTML transtype which doesn't seem to be retrieved.

Re: Map Information with XHTML

Posted: Mon Mar 18, 2024 11:59 am
by Radu
Hi Gaspard,
Not sure, do your xsl:messages appear in the console log?
Regards,
Radu

Re: Map Information with XHTML

Posted: Mon Mar 18, 2024 1:28 pm
by gbv34
Unfortunately, not at all.

Re: Map Information with XHTML

Posted: Mon Mar 18, 2024 1:28 pm
by gbv34
I have attached the plugin here.
com.toto.othermeta.xhtml.zip

Re: Map Information with XHTML

Posted: Mon Mar 18, 2024 1:29 pm
by Radu
Linking here to your post on the DITA OT discussions list:
https://github.com/orgs/dita-ot/discussions/4438
If time allows I will try to look into this later on and reply there in order not to have two duplicate threads.
Regards,
Radu

Re: Map Information with XHTML

Posted: Mon Mar 18, 2024 1:33 pm
by Radu
In general, you can try to debug this further. If you have run the DITA OT "-install" to integrate the plugin you can use for example Oxygen's "Find/Replace in Files" to see where in the DITA OT XSLTs your "get-move-othermeta.xsl" is now referenced, it should now be referenced somewhere in this XSLT stylesheet "DITA-OT/plugins/org.dita.xhtml/xsl/dita2html-base.xsl". Maybe there are other stylesheets with higher priority which override the same xsl template match as yours.

Regards,
Radu

Re: Map Information with XHTML

Posted: Mon Mar 18, 2024 1:46 pm
by gbv34
Interesting. The precedence of another stylesheet is a good lead. I'll look at this. Thanks, Radu! If I find the solution, I'll share it here.