RE: [xsl] CLARIFICATION ON MY XSLT

Subject: RE: [xsl] CLARIFICATION ON MY XSLT
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 23 Apr 2005 09:18:56 +0100
Interesting one. I think I would tackle this in the template that matches
the text nodes, something like this:

<xsl:template match="para//i/text() | para//b/text() | para//inf/text()">
  <render>
    <xsl:if test="ancestor::i">
      <xsl:attribute name="font-style">italic</xsl:attribute>
    </xsl:if>
    <xsl:if test="ancestor::b">
      <xsl:attribute name="font-weight">bold</xsl:attribute>
    </xsl:if>
    <xsl:if test="ancestor::inf">
      <xsl:attribute name="baseline-shift">sub</xsl:attribute>
      <xsl:attribute name="font-size">smaller</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="."/>
  </render>
</xsl:template>

Michael Kay
http://www.saxonica.com/     

> -----Original Message-----
> From: Arulxml@xxxxxxxxxxxx [mailto:Arulxml@xxxxxxxxxxxx] 
> Sent: 23 April 2005 06:15
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] CLARIFICATION ON MY XSLT
> 
> Greetings all,
> 
> I am processing XML to XML by using XSL style sheet and Saxonb 8.0
> 
> My source XML file
> <root>
> <p>some text</p>
> <p>some text <i>italic text</i></p>
> <p>some text <b><i>bold+italic text</i> bold text</b></p>
> <p>some text <i>italic text <sub>subscript+italic 
> text</sub></i> some text</p>
> <p>some text <b>bold text <i>Italic text</i> bold continues 
> <i>x<inf>2</inf></i> bold continues</b></p>
> </root> 
> 
> My resulting XML file
> <root>
> <para>some text</para>
> <para>some text <render font-style="italic">italic 
> text</render></para>
> <para>some text <render font-weight="bold" 
> font-style="italic">bold+italic text</render><render 
> font-weight="bold"> bold text</render></para>
> <para>some text <render font-style="italic">italic text 
> </render><render font-style="italic" baseline-shift="sub" 
> font-size="smaller">subscript+italic text</render> some text</para>
> <para>some text <render font-weight="bold">bold text 
> </render><render font-weight="bold" 
> font-style="italic">bold+Italic text</render><render 
> font-weight="bold"> bold continues </render><render 
> font-weight="bold" font-style="italic">x</render><render 
> font-weight="bold" baseline-shift="sub" 
> font-size="smaller">2</render><render font-weight="bold"> 
> bold continues</render></para>
> </root>
> 
> Please advise how the XSLT will be to bring the resulting XML 
> file. Many Many thanks in advance.
> 
> Best regards to you
> Arul Kumar
> 
> 
> 
> __________________________________________________________________
> Switch to Netscape Internet Service.
> As low as $9.95 a month -- Sign up today at 
> http://isp.netscape.com/register
> 
> Netscape. Just the Net You Need.
> 
> New! Netscape Toolbar for Internet Explorer
> Search from anywhere on the Web and block those annoying pop-ups.
> Download now at http://channels.netscape.com/ns/search/install.jsp

Current Thread