Converting attributes set in the map to element in a prolog
Posted: Thu Oct 26, 2023 3:00 pm
Hello everyone!
This is a task I'm currently struggling with.
I work with people who'd like to leverage the subject scheme map and its controlled values to automatically convert the attributes initially declared o the topicrefs as elements in topics' prolog.
Basically, my plugin relies on the following extension point <feature extension="dita.xsl.mappull" file="./xsl/backup-subjectschememap-attributes-2-elements.xsl"/>. What I do in it is creating a corresponding "othermeta" elements for each attribute from this list: "audience," "status," "props," "otherprops," "rev," "product," and "platform."
For now , I have this XSLT:
I see the temporary source for the map correctly populates the othermeta in the topicref, but I don't retrieve navtitle or the other elements that should be included in it too. I wonder how I could call the remaining processing to be applied.
I have tried using the topicpull extension point, navtitle and linktext are provided, but I loose my transformation for the othermeta element creation.
I feel stuck at this point and any suggestion would be helpful.
Thanks a lot for your attention
This is a task I'm currently struggling with.
I work with people who'd like to leverage the subject scheme map and its controlled values to automatically convert the attributes initially declared o the topicrefs as elements in topics' prolog.
Basically, my plugin relies on the following extension point <feature extension="dita.xsl.mappull" file="./xsl/backup-subjectschememap-attributes-2-elements.xsl"/>. What I do in it is creating a corresponding "othermeta" elements for each attribute from this list: "audience," "status," "props," "otherprops," "rev," "product," and "platform."
For now , I have this XSLT:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
xmlns:mappull="http://dita-ot.sourceforge.net/ns/200704/mappull"
xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
xmlns:saxon="http://saxon.sf.net/"
exclude-result-prefixes="xs dita-ot mappull ditamsg saxon">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[contains(@class, ' map/topicref ')]">
<xsl:call-template name="processTopicref">
<xsl:with-param name="element" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template name="processTopicref">
<xsl:param name="element"/>
<xsl:message>XSLT transform started!</xsl:message>
<xsl:variable name="xtrf" select="$element/@xtrf"/>
<xsl:variable name="attributes"
select="tokenize($element/@*[local-name() = ('audience', 'status', 'props', 'otherprops', 'rev', 'product', 'platform')], ' ')"/>
<xsl:copy>
<xsl:apply-templates
select="$element/@*[not(local-name() = ('audience', 'status', 'props', 'otherprops', 'rev', 'product', 'platform'))]"/>
<xsl:apply-templates select="$element/node()"/>
<topicmeta class="- map/topicmeta ">
<xsl:copy-of select="topicmeta/*[not(self::othermeta)]"/>
<xsl:if test="@audience">
<xsl:variable name="attributes"
select="tokenize($element/@*[local-name() = ('audience')], ' ')"/>
<xsl:for-each select="$attributes">
<xsl:variable name="attrValue" select="."/>
<othermeta name="audience" content="{$attrValue}" xtrf="{$xtrf}"
class="- topic/othermeta "/>
</xsl:for-each>
</xsl:if>
</topicmeta>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I have tried using the topicpull extension point, navtitle and linktext are provided, but I loose my transformation for the othermeta element creation.
I feel stuck at this point and any suggestion would be helpful.
Thanks a lot for your attention
