Template creates an empty div
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 72
- Joined: Tue Oct 21, 2014 10:01 pm
Template creates an empty div
We have an xsl:template in our WebHelp plugin that places all of the <info> content within a collapsible div. We designed this template so that any cautions and Important Notes are outside of the collapsible div. What the developer of this XSLT neglected to code is if the <info> tag contains only cautions and Important Notes then the results would be an empty div. The developer is long gone so I need to fix it, but I'm not sure how to approach this.
Here's our code:
Here's our code:
Code: Select all
<xsl:template match="*[contains(@class,' task/info ')]|*[contains(@otherprops, 'enable_moreinfo')]|*[contains(@otherprops, 'disable_moreinfo')]" name="topic.task.info">
<xsl:choose>
<xsl:when test="contains(@otherprops, 'disable_moreinfo')">
<xsl:apply-templates select="*[contains(@type,'caution') or contains(@type,'important')]"/>
<xsl:call-template name="generateItemGroupTaskElement"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*[contains(@type,'caution') or contains(@type,'important')]"/>
<div data-role="collapsible" data-collapsed="true" data-mini="true" data-theme="c" style="border:1pt solid red">
<h2>More Information:</h2>
<xsl:call-template name="generateItemGroupTaskElement"/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="generateItemGroupTaskElement">
<div>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="setidaname"/>
<xsl:apply-templates
select="*[not(contains(@type,'important')) and not(contains(@type,'caution'))]|text()"/>
</div>
</xsl:template>
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Template creates an empty div
Hello,
You can generate the 'notes' in a temporary variable and then generate the '<div>' element if at least one note was found.
For example:
Regards,
Alin
You can generate the 'notes' in a temporary variable and then generate the '<div>' element if at least one note was found.
For example:
Code: Select all
............
<xsl:template name="generateItemGroupTaskElement">
<xsl:variable name="notes">
<xsl:apply-templates
select="*[not(contains(@type,'important')) and not(contains(@type,'caution'))]|text()"/>
</xsl:variable>
<xsl:if test="count($notes/*) > 0">
<!-- Generate the 'div' element if at least one note was matched. -->
<div>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="setidaname"/>
<xsl:copy-of select="$notes"/>
</div>
</xsl:if>
</xsl:template>
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service