DITA: Create table from release-managemt domain elements

Here should go questions about transforming XML with XSLT and FOP.
pieterjan_vdw
Posts: 21
Joined: Wed Jun 20, 2018 11:30 am

DITA: Create table from release-managemt domain elements

Post by pieterjan_vdw » Tue Jul 09, 2019 3:28 pm

Hi,

I would like to have the following: a summary table with all changes I added in every topic in the release domain elements with a link to the file.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="test">
   <title>Test</title>
   <prolog>
      <!--...-->
      <change-historylist>
         <change-item product="productA productB">
            <change-person>Joan Smith</change-person>
            <change-completed>2013-03-23</change-completed>
            <change-summary>Made change 1 to both products</change-summary>
            <data>Details of change 1</data>
         </change-item>
         <change-item product="productA">
            <change-person>Bill Carter</change-person>
            <change-completed>2013-06-07</change-completed>
            <change-summary>Made change 2 to product A</change-summary>
            <data>Details of change 2</data>
         </change-item>
         <change-item product="productA productB">
            <change-person>Richard Smith</change-person>
            <change-completed>2013-07-20</change-completed>
            <change-summary>Made change 3 to both products</change-summary>
            <data>Details of change 3</data>
         </change-item>
      </change-historylist>
      <!--...-->
   </prolog>
   <conbody>
   </conbody>
</concept>
Starting point: ditamap with topicref (can be nested topicref) or bookmap.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
   <title>change_history</title>
   <topicref href="test.dita" type="concept" navtitle="Test" format="dita" scope="local">
      <topicref href="summary.dita"/>
   </topicref>
</map>

This is what I currently have:
  • Table
  • 4 columns with heading row
  • Column 1: values of change-person in each row
  • Column 2: values of change-completed in each row
  • Column 3: values of change-description in each row
This is what I would like to add in my fourth column: href to the file (same href as the one in ditamap I am starting from).

Current XSLT:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   exclude-result-prefixes="xs"
   version="2.0">

<xsl:template name="change_history" match="node() | @*">
   <xsl:result-document doctype-public="-//OASIS//DTD DITA Topic//EN" doctype-system="topic.dtd" indent="yes">
<topic>
<xsl:attribute name="id">history_list</xsl:attribute>
<xsl:element name="title">History update</xsl:element>
<body>
<xsl:element name="table">
   <xsl:element name="tgroup">
         <xsl:attribute name="cols">4</xsl:attribute>
         <colspec colname="c1" colnum="1" colwidth="1*"/>
         <colspec colname="c2" colnum="2" colwidth="1*"/>
         <colspec colname="c3" colnum="3" colwidth="1*"/>
         <colspec colname="c4" colnum="4" colwidth="1*"/>
            <xsl:element name="thead">
            <row>
               <entry>Person</entry>
               <entry>Description</entry>
               <entry>Date</entry>
               <entry>File</entry>
            </row>
            </xsl:element>
         <xsl:element name="tbody">
         <xsl:for-each select="//topicref">
         <xsl:variable name="changeitem" select="document(@href)//change-item" />
         <xsl:for-each select="$changeitem">
<row>
   <entry><xsl:value-of select="change-person"/></entry>
<entry>
   <xsl:value-of select="change-summary"/>
</entry>
   <entry>
      <xsl:value-of select="change-completed"/>
   </entry>
   <entry>
      <xref>
<!-- Here I need to add the href>
      </xref>   
</entry>
   
</row>   
         </xsl:for-each>
 </xsl:for-each>
   </xsl:element>
</xsl:element>
</xsl:element>
</body>
</topic>
   </xsl:result-document>
</xsl:template>
</xsl:stylesheet>
Thanks a lot in advance for the help.
If anyone knows an easier, also very welcome.

Radu
Posts: 6507
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA: Create table from release-managemt domain elements

Post by Radu » Fri Jul 12, 2019 1:39 pm

Hi Pieterjan,

It is not clear to me how your sample xsl:template is getting called.
You already seem to have in your xsl:template the @href attribute so this would imply you are applying the xsl:template on the topicref. And if you already have the @href why don't you use it?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply