RE: [xsl] attributes to nested element problem

Subject: RE: [xsl] attributes to nested element problem
From: "Kielen, Agnes" <Agnes.Kielen@xxxxxxxxxxxxxx>
Date: Wed, 19 May 2004 08:22:41 +0200
Hi Tim,
Something like this maybe. I'm sure it can be made smarter.
Cheers,
Agnes

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/label">
<xsl:apply-templates select="@paragraph"/>

</xsl:template>

<xsl:template match="@paragraph">
<xsl:choose>
   <xsl:when test=".='true'">
      <p><xsl:apply-templates select="../@align"/></p>
   </xsl:when>
   <xsl:otherwise><xsl:apply-templates select="../@align"/></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="@align">
     <span align="{.}">
        <xsl:apply-templates select="../@italic"/>
     </span>
</xsl:template>

<xsl:template match="@italic">
<xsl:choose>
   <xsl:when test=".='true'">
      <i><xsl:apply-templates select="../@bold"/></i>
   </xsl:when>
   <xsl:otherwise><xsl:apply-templates select="../@bold"/></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="@bold">
<xsl:choose>
   <xsl:when test=".='true'">
      <b><xsl:value-of select=".."/></b>
   </xsl:when>
   <xsl:otherwise><xsl:value-of select=".."/></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>



-----Original Message-----
From: Tim Lord [mailto:timl@xxxxxxxxxxx]
Sent: woensdag 19 mei 2004 7:36
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] attributes to nested element problem


Hi,

I was wondering how to convert an element:

<label align="left" paragraph="true" italic="true" bold="true">This is a 
label</label>

Into this html:

<p><span align="left"><b><i>This is a label</i></b></span></p>

I found solutions to converting attributes to elements but what about 
nested elements like this?

Cheers,

/tim

Current Thread