A question about templates for specialized elements
Posted: Fri Mar 02, 2012 11:12 pm
Hi, I also posted this question on the Yahoo DITA user group board.
This is a question I've always wanted to ask but never had a chance to
do so, partly because I didn't really think this could be a problem until now.
Long story short: I've created a new specialized element called <artifact_type>
based off <codeph>, and I want <artifact_type> to output in bold, monospaced
font. I've already defined an attribute set for <artifact_type> in a new
stylesheet and imported it in my custom.xsl. I wrote a template that points
directly to the name of the specialized element. However when I applied the
template I wrote, the output still uses the style defined for <codeph>
(monospaced but NOT bolded). Here is the template in question:
<!-- template No.1 -->
<xsl:template match="*[contains(@class, ' myDomain/artifact_type ')]">
<fo:inline xsl:use-attribute-sets="artifact_type" id="{@id}">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
But if I required my users to manually input a value of "sp" in the @outputclass
field of <artifact_type>, and applied the following template, the output was as
expected:
<!-- template No.2 -->
<xsl:template match="*[contains(@class, ' pr-d/codeph ')]">
<xsl:choose>
<xsl:when test="@outputclass='sp'">
<fo:inline xsl:use-attribute-sets="artifact_type" id="{@id}">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="codeph" id="{@id}">
<xsl:apply-templates/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
However, I don't want to use the template above, because users are forced to
remember that they need to manually input a value in the @outputclass field,
which undermines their user experiences. Is it possible to write a template that
points directly to the name of the specialized element, the same way that
template No.1 above demonstrates? I've tried this with DITA-OT v. 1.4.2.1 and
also with the latest v.1.5.4, but to no avail. Any help from this group is
appreciated.
p.s. I also must mention that I placed the specialized template in the override stylesheet.
This is a question I've always wanted to ask but never had a chance to
do so, partly because I didn't really think this could be a problem until now.
Long story short: I've created a new specialized element called <artifact_type>
based off <codeph>, and I want <artifact_type> to output in bold, monospaced
font. I've already defined an attribute set for <artifact_type> in a new
stylesheet and imported it in my custom.xsl. I wrote a template that points
directly to the name of the specialized element. However when I applied the
template I wrote, the output still uses the style defined for <codeph>
(monospaced but NOT bolded). Here is the template in question:
<!-- template No.1 -->
<xsl:template match="*[contains(@class, ' myDomain/artifact_type ')]">
<fo:inline xsl:use-attribute-sets="artifact_type" id="{@id}">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
But if I required my users to manually input a value of "sp" in the @outputclass
field of <artifact_type>, and applied the following template, the output was as
expected:
<!-- template No.2 -->
<xsl:template match="*[contains(@class, ' pr-d/codeph ')]">
<xsl:choose>
<xsl:when test="@outputclass='sp'">
<fo:inline xsl:use-attribute-sets="artifact_type" id="{@id}">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="codeph" id="{@id}">
<xsl:apply-templates/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
However, I don't want to use the template above, because users are forced to
remember that they need to manually input a value in the @outputclass field,
which undermines their user experiences. Is it possible to write a template that
points directly to the name of the specialized element, the same way that
template No.1 above demonstrates? I've tried this with DITA-OT v. 1.4.2.1 and
also with the latest v.1.5.4, but to no avail. Any help from this group is
appreciated.
p.s. I also must mention that I placed the specialized template in the override stylesheet.