xsl-list
[Top] [All Lists]

RE: RE: Transformation XML to XML

2005-07-19 07:46:53
This is just horrible. disable-output-escaping should never be used to
construct markup in the serialized output. And in this case, there's no
possible excuse because the correct code is dead easy:

<xsl:template match="z:row">   
<xsl:text disable-output-escaping="no">&lt;image&gt;</xsl:text>
<xsl:for-each select="@*">
   <xsl:text disable-output-escaping="no">&lt;</xsl:text>
   <xsl:value-of select="name()"/>
   <xsl:text disable-output-escaping="no">&gt;</xsl:text>
 <xsl:value-of select="."/>
 <xsl:text disable-output-escaping="no">&lt;/</xsl:text>
 <xsl:value-of select="name()"/>
 <xsl:text disable-output-escaping="no">&gt;</xsl:text>
</xsl:for-each>
<xsl:text disable-output-escaping="no">&lt;/image&gt;</xsl:text>
</xsl:template>

What's wrong with:

<xsl:template match="z:row">
<image>
  <xsl:for-each select="@*">
    <xsl:element name="{name()}">
      <xsl:value-of select="."/>
    </xsl:element>
  </xsl:for-each>
</image>
</xsl:template>

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



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