Sablotron 0.50 - great software so far.

I would like to see xsl:attribute-set being implemented in the next release.

Consider a typical XML fragment:

<image>
 <url>/icons/home.gif</url>
 <width>20</width>
 <height>22</height>
</image>

Now to generate HTML from this XML via XSL would be (via sabcmd 0.50):

<xsl:template match="image">
 <xsl:text disable-output-escaping="yes">&lt;IMG SRC="</xsl:text>
 <xsl:value-of select="url"/>
 <xsl:text disable-output-escaping="yes">" ALT="</xsl:text>
 <xsl:value-of select="name"/>
 <xsl:text disable-output-escaping="yes">" WIDTH="</xsl:text>
 <xsl:value-of select="width"/>
 <xsl:text disable-output-escaping="yes">" HEIGHT="</xsl:text>
 <xsl:value-of select="height"/>
 <xsl:text disable-output-escaping="yes">" TITLE="</xsl:text>
 <xsl:value-of select="name"/>
 <xsl:text disable-output-escaping="yes">" BORDER="0"&gt;</xsl:text>
</xsl:template>

However if the xsl:attribute-set element was available, the code would 
become:

<xsl:template match="image">
 <xsl:element name="IMG" use-attribute-sets="image-attributes"/>
</xsl:template>

<xsl:attribute-set name="image-attributes">
 <xsl:attribute name="URL">
  <xsl:value-of select="url"/>
 </xsl:attribute>
 <xsl:attribute name="ALT">
  <xsl:value-of select="name"/>
 </xsl:attribute>
 <xsl:attribute name="WIDTH">
  <xsl:value-of select="width"/>
 </xsl:attribute>
 <xsl:attribute name="HEIGHT">
  <xsl:value-of select="height"/>
 </xsl:attribute>
 <xsl:attribute name="TITLE">
  <xsl:value-of select="name"/>
 </xsl:attribute>
 <xsl:attribute name="BORDER">0</xsl:attribute>
</xsl:attribute-set>

I personally think with the xsl:attibutes-set being available the XSL would 
be clearer to read and easier to maintain.

Thankyou in advance.

BTW: the examples on the web site are getting a little out of date ;-(

for example in leftbar.xsl top.xsl there is the following code fragment:

<xsl:text><A HREF="</xsl:text>
<xsl:value-of select="url" />
<xsl:text>"></xsl:text>
<xsl:value-of select="name" />
<xsl:text></A></xsl:text>

which could be updated to:

<A>
 <xsl:attribute name="HREF">
  <xsl:value-of select="url"/>
 </xsl:attribute>
 <xsl:value-of select="name"/>
</A>

Which is clearer to read and more obvious as to the intent.

I only bring this up because as I started to use XML/XSL/Sablotron I used 
your examples as commercial quality code to base other work on. I just wish 
to give beginners a good start with such a powerfull tool such as Sablotron.

Keep up the good work.

-- 
Stephen.

Reply via email to