Implementing a Character-style Dropdown Style?

Version

Date

Changes

1.0

2009-04-28

Initial version.

1.1

2009-07-27

New discussion and .zip file added.

1.2

2009-07-28

Imported and edited info provided by Lauren L.

2.0

2009-08-05

Solution posted.

2.1

2009-08-12

Revised solution posted.

2.2

2009-08-24

Conclusion with code changes.

Description

Does ePublisher provide an API mechanism to implement the Dropdown setting in the Character Styles Options Tab pane, or can Character Style Dropdown be implemented via XSLT in a "straight-forward" manner?

Currently ePublisher Pro provides a paragraph style for implementing a Dropdown that is enabled by the Dropdown setting in the Paragraph Styles Options Tab pane.

We have a character style, DropDownClosed, that we use to indicate a hypertext link that activates the Dropdown. The current ePublisher Pro Character Styles Options Tab pane has a See Also setting, but it does not have the Dropdown setting. How can we add a Dropdown setting in this tab?

We carried this DropDownClosed character style over from our WebWorks Publisher Professional for FrameMaker 2003 projects where we were able to reproduce the paragraph style dropdown macro as a character style macro. We have two very large, multi-volume projects that we still maintain in the older version because of the extensive use of dropdowns. The issues go beyond just changing paragraph styles since the content that contains the Dropdown also include hypertext links. Resolving how to reproduce the character style feature will enable us to move to the current version of ePublisher.

Any insights you can provide here in this wiki topic will be most helpful and appreciated.

Thanks!

--Allen


Allen,

Can you upload a sample source document and describe where in the document the character style dropdown should be. Additionally, please provide the character style names you are using. Finally, if you do have example output from Publisher 2003, that would be helpful.

Ben


Our character style used for the dropdown feature is DropDownClosed. I have provided a .zip file (ePublisher_DropDown_Sources.zip) that includes:

* a sample document (ePub_DropDown.fm, with the heading "DropDown Examples" that provides examples with and without hypertext links).

* an ePublisher DropDown directory contains a ePublisher Express project that you can run to create ePublisher paragraph dropdowns based on FrameMaker styles (code as *_DropDown; for example Body_DropDown).

* a WWP2003_HTML_DropDown_Example directory that contains HTML output showing the desired behavior of paragraphs containing dropdowns and hypertext.

--Allen

Solution

Discussion with Allen defined the goal for this customization as changing the trigger for dropdowns from an entire paragraph to a specific character style within a paragraph. The goal was not to implement inline text expansions.

Overrides were created to alter ePublisher's processing of dropdown code both in the Shared transforms area and in the WebWorks Help 5.0 format. The customizations are compatible with ePublisher versions 2009.1 and 2009.2.

ePublisher DropDown.2009-08-05

Response

I gather that I have mislead your understanding or perhaps I do not understand "inline expand/collapse behaviors" The example does not work as I thought it would.

The FrameMaker example file topic "DropDown Examples" includes a procedure section. If I change the style of step 3 from Number_Two_Plus_DropDown to Number_Two_Plus and regenerate the output, I should see the dropdown close arrow which should remain closed when I click on the hypertext link that appears earlier in the sentence. I should be able to independently click on the dropdown to see it open.

This is not happening in the example when I change the style of step 3 to Number_Two_Plus (which was what was used back in WWP2003). The dropdown is in the continue mode (open) and no arrow is present to close it.

-- Allen


Reviewing the two outputs more closely, I see that ePublisher's output is behaving as if the DropDownEnd marker is being ignored. Now, the expand code is firing when the earlier paragraph link is clicked, but that is probably just something I missed in the code. I'll have a look at both issues and update you soon.

-- Ben

Solution - Take 2

The original solution contained two errors:

  1. The dropdown reporting code for the character style link was reporting an incorrect value.
  2. The addition of character style dropdown code inadvertently suppressed Marker processing, leading to missing DropDownEnd markers, and therefore "unbounded" dropdowns.

The revised solution corrects both of these issues and was tested with paragraph styles "Number_Two_Plus" in place of "Number_Two_Plus_DownDown", "Numbered_A_Tables" in place of "Numbered_A_Tables_DownDown", and "Numbered_B+_Tables" in place of "Numbered_B+_Tables_DownDown".

ePublisher DropDown.2009-08-12.zip

Conclusion with Code

The character dropdown enables your output to provide optional additional information that can be hidden below a sentence, step or paragraph. A user can access this optional additional information as needed. In addition, the same sentence, step or paragraph can also contain independent hypertext links to other topics.

The implementation of the character format dropdown feature is a non-trival undertaking as this feature mimics much of the behavior used for the paragraph dropdown. The implementation requires code revisions and new code additions to four files in two directories:

Formats\Shared\common\behaviors document.xsl pullup.xsl

Formats\WebWorks Help 5.0\Transforms content.xsl pages.fti (Pages Format Trait Info)

These modified files are all available in the sample download .zip file (ePublisher_DropDown.2009-08-12.zip) in the Formats directory. For comparison, the original files are also included in the Formats.2009.1.or.2009.2 directory.

The following sections provide the code changes in the files. The references to the code line numbers are based on the original unedited files. For a better understanding of the changes, use a diff tool or diff editor to compare the files side-by-side.

Code edit in document.xsl (Formats\Shared\common\behaviors\document.xsl)

Add code between line 329 and line 330

<xsl:template match="wwdoc:TextRun" mode="wwmode:behavior">
  <xsl:param name="ParamTextRun" select="." />
  <xsl:param name="ParamWIFFile" />
  <xsl:param name="ParamTopLevel" />

  <!-- Get context rule -->
  <!--                  -->
  <xsl:variable name="VarRule" select="wwprojext:GetRule('Character', $ParamTextRun/@stylename)" />

  <!-- Generate output? -->
  <!--                  -->
  <xsl:variable name="VarGenerateOutputOption" select="$VarRule/wwproject:Options/wwproject:Option[@Name = 'generate-output']/@Value" />
  <xsl:variable name="VarGenerateOutput" select="(string-length($VarGenerateOutputOption) = 0) or ($VarGenerateOutputOption != 'false')" />
  <xsl:if test="$VarGenerateOutput">
   <!-- Drop Down -->
   <!--           -->
   <xsl:variable name="VarDropDownOption" select="$VarRule/wwproject:Options/wwproject:Option[@Name = 'dropdown']/@Value" />
   <xsl:variable name="VarDropDown">
    <xsl:choose>
     <xsl:when test="($ParameterDropDowns != 'true') or (string-length($VarDropDownOption) = 0)">
      <xsl:value-of select="'continue'" />
     </xsl:when>

     <xsl:otherwise>
      <xsl:value-of select="$VarDropDownOption" />
     </xsl:otherwise>
    </xsl:choose>
   </xsl:variable>

   <wwbehaviors:TextRun id="{$ParamTextRun/@id}" dropdown="{$VarDropDown}" />

   <xsl:apply-templates select="$ParamTextRun/wwdoc:*" mode="wwmode:behavior">
    <xsl:with-param name="ParamWIFFile" select="$ParamWIFFile" />
    <xsl:with-param name="ParamTopLevel" select="false()" />
   </xsl:apply-templates>
  </xsl:if>
 </xsl:template>

Code edit in pullup.xsl (Formats\Shared\common\behaviors\pullup.xsl)

Add code after line 158 and after 161

      <xsl:otherwise>
         <! -- The new code goes here -->
       <xsl:value-of select="'continue'" />
        <! -- The new code goes here -->
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>

so the code changes to the following:

       <xsl:otherwise> <! -- this is line 158 -->

       <!-- Check for character dropdowns -->
       <!--                               -->
       <xsl:choose>
        <xsl:when test="count($ParamParagraph//wwbehaviors:TextRun[@dropdown = 'start-open']) &gt; 0">
         <xsl:value-of select="'start-open'" />
        </xsl:when>

        <xsl:when test="count($ParamParagraph//wwbehaviors:TextRun[@dropdown = 'start-closed']) &gt; 0">
         <xsl:value-of select="'start-closed'" />
        </xsl:when>

        <xsl:otherwise>
         <xsl:value-of select="'continue'" />
        </xsl:otherwise>
       </xsl:choose>
      </xsl:otherwise>
     </xsl:choose>

Code edits in pages.fti (Formats\WebWorks Help 5.0\Transforms\pages.fti)

Add code after line 67

  <Class name="dropdown-character">
   <Item value="continue" />
   <Item value="start-open" />
   <Item value="start-closed" />
  </Class>

Add code after line 205 (after the last Option name = pass-through element)

    <Option name="dropdown" group="options" default="continue">
     <OptionClass name="dropdown-character" />
    </Option>

Code edits in content.xsl (Formats\WebWorks Help 5.0\Transforms\content.xsl)

Add code after line 38

 <xsl:key name="wwbehaviors-textruns-by-id" match="wwbehaviors:TextRun" use="@id" />

Add new code after line 1039

   <xsl:variable name="VarCharacterDropdown" select="count($ParamParagraphBehavior//wwbehaviors:TextRun[(@dropdown = 'start-open') or (@dropdown = 'start-closed')]) &gt; 0" />
   <xsl:if test="not($VarCharacterDropdown) and (($ParamParagraphBehavior/@dropdown = 'start-open') or ($ParamParagraphBehavior/@dropdown = 'start-closed'))">

Revise code on line 1148

             <!-- Dropdown Arrow -->
             <!--                -->
             <xsl:if test="($ParamParagraphBehavior/@dropdown = 'start-open') or ($ParamParagraphBehavior/@dropdown = 'start-closed')">

The code changes to:

             <!-- Dropdown Arrow -->
             <!--                -->
             <xsl:if test="not($VarCharacterDropdown) and (($ParamParagraphBehavior/@dropdown = 'start-open') or ($ParamParagraphBehavior/@dropdown = 'start-closed'))">

Revise code on line 1232

     <!-- Dropdown Arrow -->
     <!--                -->
     <xsl:if test="($ParamParagraphBehavior/@dropdown = 'start-open') or ($ParamParagraphBehavior/@dropdown = 'start-closed')">

The code changes to:

     <!-- Dropdown Arrow -->
     <!--                -->
     <xsl:if test="not($VarCharacterDropdown) and (($ParamParagraphBehavior/@dropdown = 'start-open') or ($ParamParagraphBehavior/@dropdown = 'start-closed'))">

Add code after line 1841

    <!-- Dropdown -->
    <!--          -->
    <xsl:variable name="VarParagraphDropdownOption">
     <xsl:for-each select="$ParamCargo/wwbehaviors:Behaviors[1]">
      <xsl:variable name="VarParagraphBehavior" select="key('wwbehaviors-paragraphs-by-id', $ParamParagraphID)[1]" />

      <xsl:value-of select="$VarParagraphBehavior/@dropdown" />
     </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="VarCharacterDropdownOption">
     <xsl:for-each select="$ParamCargo/wwbehaviors:Behaviors[1]">
      <xsl:variable name="VarTextRunBehavior" select="key('wwbehaviors-textruns-by-id', $ParamTextRun/@id)[1]" />

      <xsl:value-of select="$VarTextRunBehavior/@dropdown" />
     </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="VarCharacterDropdown" select="($VarCharacterDropdownOption = 'start-open') or ($VarCharacterDropdownOption = 'start-closed')" />

Add new attribute code for the DropDown 'onclick' attribute after line 1878

        </xsl:attribute>
       </xsl:if>

       <!-- Dropdown -->
       <!--          -->
       <xsl:if test="($VarCharacterDropdown) and (($VarParagraphDropdownOption = 'start-open') or ($VarParagraphDropdownOption = 'start-closed'))">
        <xsl:attribute name="onclick">
         <xsl:value-of select="concat('WebWorks_ToggleDIV(WebWorksRootPath, &quot;wwdd', $ParamParagraphID, '&quot;);')" />

Add new code after line 1890

       <!-- Dropdown Arrow -->
       <!--                -->
       <xsl:if test="($VarCharacterDropdown) and (($VarParagraphDropdownOption = 'start-open') or ($VarParagraphDropdownOption = 'start-closed'))">
        <html:script type="text/javascript" language="JavaScript1.2">WebWorks_WriteArrow(WebWorksRootPath, &quot;<xsl:value-of select="concat('wwdd', $ParamParagraphID)" />&quot;, <xsl:value-of select="$VarParagraphDropdownOption = 'start-open'" />);</html:script>
       </xsl:if>

Thanks so much to Ben Allums and the WebWorks Team for providing the the code modfications!

Regards,

--Allen

DevCenter/Projects/WebWorksHelp/Implementing a Character-style Dropdown Style (last edited 2010-01-22 23:40:24 by BenAllums)