Create Multiple Table Styles
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 10
- Joined: Tue Apr 23, 2013 11:48 pm
Create Multiple Table Styles
Is there a way in Oxygen XML to create two or more types of table such that when I generate a webhelp and PDF output, the tables will have different colors in the heading. For example, table 1 will have blue background in the heading, table 2 will have yellow, etc.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Create Multiple Table Styles
Post by sorin_ristache »
Hello,
That is possible by marking each type of table with the attribute outputclass in the DITA XML topic files. This will create a different category of tables for each distinct value of the outputclass attribute. For example:
For the Webhelp output you should set the style in a CSS stylesheet that you set in the parameter args.css of the DITA Webhelp transformation. Also set the parameter args.copycss to true. In the Webhelp pages the table will be <table class="table blue-table">, so in the CSS stylesheet you can use for example:
For the PDF output you have to customize the stylesheet:
[Oxygen-install-dir]\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\cfg\fo\attrs\tables-attr.xsl
by adding the following in the XSLT attribute set with name="thead.row.entry":
Regards,
Sorin
That is possible by marking each type of table with the attribute outputclass in the DITA XML topic files. This will create a different category of tables for each distinct value of the outputclass attribute. For example:
Code: Select all
<table outputclass="blue-table">
. . .
</table>
<table outputclass="yellow-table">
. . .
</table>
Code: Select all
table.blue-table thead {
background-color:blue;
}
table.yellow-table thead {
background-color:yellow;
}
[Oxygen-install-dir]\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\cfg\fo\attrs\tables-attr.xsl
by adding the following in the XSLT attribute set with name="thead.row.entry":
Code: Select all
<xsl:attribute name="background-color">
<xsl:choose>
<xsl:when test="ancestor-or-self::*[contains(@class, ' topic/table ')][@outputclass='blue-table']">blue</xsl:when>
<xsl:when test="ancestor-or-self::*[contains(@class, ' topic/table ')][@outputclass='yellow-table']">yellow</xsl:when>
<xsl:otherwise>antiquewhite</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
Regards,
Sorin
-
- Posts: 7
- Joined: Wed Nov 26, 2014 3:22 pm
Re: Create Multiple Table Styles
Post by Phil Champ »
This XPath expression is shorter and does the same job:
Code: Select all
<xsl:when test="ancestor::table[contains(@outputclass,'blue-table')]">blue</xsl:when>
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Create Multiple Table Styles
Hi Phil,
The DITA vocabulary can be specialized (for example I can create a DITA vocabulary extension which renames the <table> element to <myTable>) and the @class attribute value on each element shows its inheritance.
So usually when writing XSLT for DITA you need to match the @class attribute of an element instead of matching its name in order to have the same stylesheet work with a potential DITA specialization which renamed that element.
Of course, if you consider you will never create a DITA specialization to rename the <table> element you can match on the element name.
Regards,
Radu
The DITA vocabulary can be specialized (for example I can create a DITA vocabulary extension which renames the <table> element to <myTable>) and the @class attribute value on each element shows its inheritance.
So usually when writing XSLT for DITA you need to match the @class attribute of an element instead of matching its name in order to have the same stylesheet work with a potential DITA specialization which renamed that element.
Of course, if you consider you will never create a DITA specialization to rename the <table> element you can match on the element name.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 7
- Joined: Wed Nov 26, 2014 3:22 pm
Return to “General XML Questions”
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