xsl-list
[Top] [All Lists]

Re: need help with converting attribute into elements

2003-10-14 06:12:22
Hi,
thanx for another good approach. I didn't expect there are going to be so
many suportive people.
With such guys, learning something new is easy.

Ales


----- Original Message -----
From: "Jeff Beadle" <Jbeadle(_at_)manh(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Tuesday, October 14, 2003 2:29 PM
X-Scanned: By Symantec Anti-Virus Scan Engine
Subject: Re: [xsl] need help with converting attribute into elements


Hey Ales,

I'm coming into this thread a bit late, but here's an approach that has no
conditional logic and should be easy to extend.

This approach assumes that the order of the nesting doesn't matter ...
which
with html's "b", "i", and "u" elements that's true.

You build in the ordering logic--if needed--into the "the-list" variable.


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="msxsl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="text">
   <xsl:variable name="the-list">
      <xsl:for-each select="@*[.='true']">
         <xsl:element name="{name()}"/>
      </xsl:for-each>
      <the-value><xsl:value-of select="."/></the-value>
   </xsl:variable>
   <font>
      <xsl:apply-templates
select="msxsl:node-set($the-list)/child::*[1]"/>
   </font>
</xsl:template>

<xsl:template match="bold">
   <b>
      <xsl:apply-templates select="following-sibling::*[1]"/>
   </b>
</xsl:template>

<xsl:template match="italic">
   <i>
      <xsl:apply-templates select="following-sibling::*[1]"/>
   </i>
</xsl:template>

<xsl:template match="underline">
   <u>
      <xsl:apply-templates select="following-sibling::*[1]"/>
   </u>
</xsl:template>

<xsl:template match="the-value">
   <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>


HTH,
Jeff

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list