xsl-list
[Top] [All Lists]

RE: attributes to nested element problem

2004-05-18 23:22:41
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(_at_)treshna(_dot_)com]
Sent: woensdag 19 mei 2004 7:36
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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



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