[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: nested output

Subject: Re: nested output
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 21 Dec 2004 16:12:08 GMT
xsl nested output
> Here's the LaTeX transformed from the above:

?? the result you posted had no latex markup at all (and does have a
couple of strange characters (octal 226, decimal 150) just after each
page number, is that intended to be a dash of some sort?

> pp. 15476.


   <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>


This will repeat the string-value of the content span once for each
token in the class attribute. If your span ever has any markup
that should be transformed you want apply-templates not
value-of, and you only want to do it once.

Also there's no need to do a for-each over tokenize(@class, ' ')
as string equality testing automatically will work over the entire
sequence.

something like

   <xsl:template match="xhtml:span" mode="output-latex">
     <xsl:variable name="c" select="tokenize(@class, ' +')">

         <xsl:if test="$c='italic'">\textit{</xsl:if>
         <xsl:if test="$c='bold'">\textbf{</xsl:if>

          <xsl:apply-templates/>

         <xsl:if test="$c='italic'">}</xsl:if>
         <xsl:if test=".='bold'">}</xsl:if>
 </xsl:template>


untested

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.