Pages: 1
Print
Author Topic: Help with DITA-OT  (Read 3995 times)
super-structure
Member

Posts: 6


« on: December 16, 2010, 08:45:44 PM »

I've been banging around with this one for a while now and I just can't seem to locate where to put my modification.

Product: XMetaL Author v5.5

Specifically, I'd like to add a new line with "or" between <choice> items in a <choices> list to match our company's style. Now, normally, I'd just use some CSS to do this but, sadly, it seems that HTML Help cannot make use of the :after pseudo element. So it seems just as easy to modify the XSL transform to produce this for me. I know pretty much how to write the XML Stylesheet to do this:

Code:
<xsl:template match="*[contains(@class,' choice/choice ')]">
<li><xsl:value-of select="." />
<xsl:if test="position()!=last()">
<p>or,</p>
</xsl:if>
</li>
</xsl:for-each>

...but I cannot locate where in the DITA-OT files to place the extra style bit (and there's sure to be more to it, but until I even find where this transform takes place, I won't know).

I've located what appears to be the inclusion of the unordered list for the <choices> element in the .../xsl/xslhtml/taskdisplay.xsl file, around line 619. The unordered list is in this template, anyway. However, the templates "commonattributes," "gen-style," and "setid" don't appear to have anything to do with the display of list items (but surely that's wrong as there's nothing else there!). Further, my searching through the DITA-OT files using FileLocator Lite has turned up nothing (e.g., choice-fmt turns up nothing).

Anyone have any thoughts? Any DITA-OT hackers out there who know how to track this sort of thing down? In the meantime, I'm using jQuery to do this, but that's a bit like swatting flies with missiles and I'd love to loose the JavaScript overhead if possible.

(Note: Yes, I've made backup copies of all of these files before I ever started tinkering.)

Update:

I solved this one myself after a spending a couple of hours away from it. It seems that I was looking in exactly the right spot, just not identifying what I was seeing (I'll be cracking some books on XSL to be sure).

This is a cleaned up portion of what I modified in taskdisplay.xsl:

Code:
<xsl:template match="*[contains(@class,' task/choices ')]" mode="choices-fmt">
...
<!-- large section of un-modified template  goes here-->
...
 <ul> <!-- The beginning of a <choices> list -->
   <xsl:call-template name="commonattributes"/>
    <xsl:call-template name="gen-style">
      <xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
      <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
    </xsl:call-template>
<!-- begin custom <choice> list items -->
<xsl:for-each select="choice">
<li>
<xsl:call-template name="setid"/>
<xsl:apply-templates/>
<xsl:if test="position()!=last()">
<span class="choicesSeparator">or</span>
</xsl:if>
</li>
</xsl:for-each>
<!-- end custom list -->
   <!-- <xsl:call-template name="setid"/>
   <xsl:apply-templates/> -->   <!-- Rem out portions which need to be included in xsl:if loop above -->
  </ul><xsl:value-of select="$newline"/>



« Last Edit: December 16, 2010, 11:36:39 PM by super-structure » Logged

Jason Coleman
Sr. Technical Writer
Bentley Systems
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: December 17, 2010, 12:40:16 AM »

Good to see you've figured this out. I have not tried the change, but it looks like it makes sense.

This change should affect all HTML output types (CHM, WebHelp, Multiple HTML, Single HTML, Eclipse and Java Help), in case that was not obvious.

Regarding the support for CSS :after -- this is not a WebHelp issue, it is a browser support for CSS issue. So, unless you can guarantee the browser and version your readers would be using I wouldn't rely on it at present. Some newer versions of browsers support it (my copy of FF 3.6 does and Microsoft specifically documents support for :after and :before as one of the great new things in IE8).

Your solution seems better anyway as I should think that the "or" you are inserting should actually be present in the content (this is the "purist" part of my brain talking). I can't think of any really bad things that would occur if this was done using CSS (for supported browsers) except that in some of them a copy action might not include it because the browser doesn't treat it as "real" content. The main thing however (as you have seen in your testing) is that for many browsers the reader will see nothing.
« Last Edit: December 17, 2010, 12:45:25 AM by Derek Read » Logged
gcrews
Member

Posts: 265


« Reply #2 on: December 17, 2010, 12:50:40 AM »

the code around 619 is for the choices, the actual li choice items are created in the call on line 661. This calls the template matching topic/li since there is no matching templates for task/choice. The  topic/li template is around line 1273 of to dita2htmlImpl.xsl.

It calls this because of the dita inheritance of "- topic/li task/choice "
http://docs.oasis-open.org/dita/v1.1/CS01/langspec/langref/choice.html

You will most likely want to add your code around line 1304 just before the ending li tag. Since your not matching items in a for loop but rather a template match the position code you have will not quite work since it counts text nodes. It might work if you  use last() -  1 but im not sure  if it would work if there are child nodes on the last choice. There a couple of ways o go about figuring out if your on the last node. you might try something like:
<xsl:if test="count(following-sibling::*) &gt; 0" >
       <p>or,</p>
</xsl:if>
Logged
gcrews
Member

Posts: 265


« Reply #3 on: December 17, 2010, 10:15:01 AM »

your code above may work but since you are overriding the default processing with a simple for loop you may run into unintended consequences. If you look at the topic/li template mentioned above its also flagging the output based on your ditaval and preforming some rev attribute flagging if needed. It also calls commonattributes and setidaname. if you ever try and use a xref to a li now it will likely not work because the id attribute was not applied. Essentially any attribute on the choice tag  will no longer work properly.
Logged
super-structure
Member

Posts: 6


« Reply #4 on: December 17, 2010, 11:39:43 AM »

Derek

You're correct, it is a function of Internet Explorer and not so much HTML Help Viewer. Though Microsoft claims that the :before and :after pseudo elements and generated content are now supported in IE8, I still don't see them (Win 7 64-bit with IE8). Either way, previous version are far too prevalent to make it okay for our users.

I do agree that adding "actual" content instead of browser rendered content is preferable when it comes to text (and far more reliable). It was intentional that this be used for all HTML output, though .CHM is the only HTML output I currently use. At least in this case, missing an "or" between two lines doesn't dramatically affect the users ability to understand what is required.

gcrews

Excellent advice. This does work to suite my current needs (ref. attached image), but that isn't to say that larger projects in the future (when other writers are making use of this), that changes won't be needed. Honestly, I cannot think of many cases when we'll need to reference or reuse just a single <choice> list item, as opposed to the entire <step>. However, it is always best to limit the effect a modification like this to as small a set as possible. I appreciate your help.


* 12-17-2010 11-10-11 AM.png (19.79 KB, 600x206 - viewed 517 times.)
Logged

Jason Coleman
Sr. Technical Writer
Bentley Systems
Pages: 1
Print
Jump to:  

email us