xsl-list
[Top] [All Lists]

nested output

2004-12-21 08:28:44
Now that I got the other output modes working, I need to figure out how to convert this:

<span style="font-weight: bold; font-style: italic;">Riots and Pogroms</span>

.... to this:

\textit{\textbf{Riots and Pogroms}}

... but I'm getting some problems.  Here's the xhtml, which is correct:

<p class="bibref" id="TimesP2001a"><span class="creator">Times</span> (<span class="year">2001</span>) <span class="title ">Senators Stamp OK on Anti-Terrorism Laws</span>, <span class="container"><span class="origin"></span><span class="part-details">October26, <span class="pages"> pp. A–01</span></span></span>.</p> <p class="bibref" id="Veer1996a"><span class="creator">van der Veer, P. </span> (<span class="year">1996</span>) <span class="title ">Riots and Rituals: The Construction of Violence and Public Space in Hindu Nationalism</span><span class="container">, In P. BrassEd., <span class="title italic ">Riots and Pogroms</span><span class="origin"> (<span class="place">New York</span>:<span class="publisher">NYU Press</span>) </span><span class="part-details"><span class="pages"> pp. 154–76</span></span></span>.</p>

Here's the LaTeX transformed from the above:

Times (2001) Senators Stamp OK on Anti-Terrorism LawsSenators Stamp OK on Anti-Terrorism LawsSenators Stamp OK on Anti-Terrorism Laws, October 26, pp. A–01.

van der Veer, P. (1996) Riots and Rituals: The Construction of Violence and Public Space in Hindu NationalismRiots and Rituals: The Construction of Violence and Public Space in Hindu NationalismRiots and Rituals: The Construction of Violence and Public Space in Hindu Nationalism , In P. Brass Ed., Riots and Pogroms (New York:NYU Press) pp. 154–76.

Note duplicate titles.

Here's my current template:

  <xsl:template match="xhtml:span" mode="output-latex">
    <xsl:variable name="content" select="."/>
    <xsl:for-each select="tokenize(@class, ' ')">
      <xsl:variable name="css-class" select="."/>
      <xsl:choose>
        <xsl:when test="$css-class='italic'">
          <xsl:text>\textit{</xsl:text>
          <xsl:value-of select="$content"/>
          <xsl:text>}</xsl:text>
        </xsl:when>
        <xsl:when test="$css-class='bold'">
          <xsl:text>\textbf{</xsl:text>
          <xsl:value-of select="$content"/>
          <xsl:text>}</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select="$content"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

Is there some better way to tackle this?

I should add I'm seriously contemplating switching the style handling (per Wendell's suggestion awhile back) to split the presentation into the style attribute, and keep the class attribute semantic. I haven't done that yet, but if it would be easier for the above issue, I can do that.

Bruce

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>