Pages: 1
Print
Author Topic: Applying a custom css when using the multiple html file output  (Read 313 times)
bholtam
Member

Posts: 1


« on: November 04, 2011, 12:32:27 PM »

I've been using the XMetaL help topics, and I've been able to apply the custom CSS to the TOC that generates. However, any topic I click on from the TOC opens up with the default XMetaL css (commonltr.css) applied. Both the custom css (tcadmin.css in the example) and commonltr.css appear in the code.

<link href="../commonltr.css" type="text/css" rel="stylesheet" />
<link href="../tcadmin.css" type="text/css" rel="stylesheet" />

The TOC code only includes the custom css:
<link href="../tcadmin.css" type="text/css" rel="stylesheet" />

I don't have a lot of experience with CSS, but I'm stumped why I can't get this to work. I feel like I've tried everything. I'm sure I've overlooking something simple. Any help would be greatly appreciated.

Thanks
Logged
kwag_myers
Member

Posts: 63


« Reply #1 on: November 10, 2011, 02:49:36 PM »

I've found the best way is to actually use the commonltr.css file for customization. Also, make sure to Browse for the file in the Specific CSS field on the General tab of the Edit Deliverable Type dialog box to be sure the complete directory is correct.
Logged

XMetaL 6 Author in Windows 7 Home Premium
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #2 on: November 10, 2011, 05:14:58 PM »

The DITA OT seems to have a limitation that causes it to fail to put CSS links into the TOC file as you might expect it to. There is code there that looks like it should work, and I don't see why it is failing when the CSS links (that use similar code) work for the individual HTML topic files.

The main file that does the Multiple HTML transform is this:
<dita ot>\xsl\map2xhtmtoc.xsl

It doesn't really do much except set up the XSLT output to be XML (to produce XHTML output) and then import this file, which does most of the work for the TOC:
map2htmtoc.xsl

That file is where most of the magic for the TOC happens.
It contains this template that should build up and insert CSS links:

  <xsl:template name="generateCssLinks">
    <xsl:variable name="urltest">
      <xsl:call-template name="url-string">
        <xsl:with-param name="urltext">
          <xsl:value-of select="concat($CSSPATH,$CSS)"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:if test="string-length($CSS)>0">
      <xsl:choose>
        <xsl:when test="$urltest='url'">
          <link rel="stylesheet" type="text/css" href="{$CSSPATH}{$CSS}" />
        </xsl:when>
        <xsl:otherwise>
          <link rel="stylesheet" type="text/css" href="{$PATH2PROJ}{$CSSPATH}{$CSS}" />
        </xsl:otherwise>
      </xsl:choose>
      <xsl:value-of select="$newline"/>
    </xsl:if>
  </xsl:template>

 
My tests show that this is failing for some reason, but I can't figure out why.

If you need a solution immediately I'd just hard code what you need into the main template and leave it at that for now. The easiest way to do that is to change the following. My new stuff is in blue. You would obviously change the text "insert your path here" to be your actual path.


  <!-- *********************************************************************************
     Setup the HTML wrapper for the table of contents
     ********************************************************************************* -->
  <xsl:template match="/">
    <html>
      <xsl:value-of select="$newline"/>
      <head>
        <xsl:value-of select="$newline"/>
        <xsl:if test="string-length($contenttarget)>0 and
           $contenttarget!='NONE'">
          <base target="{$contenttarget}"/>
        </xsl:if>
        <xsl:choose>
          <xsl:when test="/*[contains(@class,' map/map ')]/*[contains(@class,' topic/title ')]">
            <title>
              <xsl:value-of select="/*[contains(@class,' map/map ')]/*[contains(@class,' topic/title ')]"/>
            </title>
            <xsl:value-of select="$newline"/>
          </xsl:when>
          <xsl:when test="/*[contains(@class,' map/map ')]/@title">
            <title>
              <xsl:value-of select="/*[contains(@class,' map/map ')]/@title"/>
            </title>
            <xsl:value-of select="$newline"/>
          </xsl:when>
        </xsl:choose>
        <xsl:call-template name="generateCssLinks"/>
        <xsl:call-template name="gen-user-head"/>
        <xsl:call-template name="gen-user-scripts"/>
        <xsl:call-template name="gen-user-styles"/>
      
      <link rel="stylesheet" type="text/css" href="insert your path here" />
      
      </head>
      <xsl:value-of select="$newline"/>

      <body>
        <xsl:if test="string-length($OUTPUTCLASS) &gt; 0">
          <xsl:attribute name="class">
            <xsl:value-of select="$OUTPUTCLASS"/>
          </xsl:attribute>
        </xsl:if>
        <xsl:value-of select="$newline"/>
        <xsl:apply-templates/>
      </body>
      <xsl:value-of select="$newline"/>
    </html>
  </xsl:template>


If I have some time I might have a look further to see what is really going on there. I suspect this should already be a known issue and that it likely would have a bug listed at the DITA OT project at SourceForge: http://sourceforge.net/tracker/?group_id=132728&atid=725074
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #3 on: November 10, 2011, 05:56:00 PM »

I missed some other code that seems to be checking for the presence of the CSS file. The CSS file seems to need to be present otherwise you get nothing in the TOC (which is what you are seeing, so I assume it is the same case).

Given the following conditions...
  • This file exists: c:\cssfiles\myspecific.css
  • The setting for "Specific CSS" is: c:\cssfiles\myspecific.css
  • The setting for "Default CSS path" is: \cssfolderonwebsite

...you should end up with this in the TOC file's <head>:
<link href="/cssfolderonwebsite/myspecific.css" type="text/css" rel="stylesheet" />

You will also see that the subfolder /cssfolderonwebsite is created for you in your output and the file c:\cssfiles\myspecific.css is copied into it.

No XSLT changes required.

(and all of this explains why I can't find a bug at SourceForge, because the feature is working)
« Last Edit: November 10, 2011, 05:57:38 PM by Derek Read » Logged
Pages: 1
Print
Jump to:  

email us