RE: [xsl] RE: Transformation XML to XML

Subject: RE: [xsl] RE: Transformation XML to XML
From: "Rob Merrison" <rob.merrison@xxxxxxxxxxxx>
Date: Tue, 19 Jul 2005 16:21:23 +0100
That did not work as expected

<image1 xmlns:s="uuid:bdc6e3f0-6da3-11d1-a2a3-00aa00c14882"
xmlns:z="#rowsetschema"><pdesc>hot
rod</pdesc><filename>ab_0001.jpg</filename><photoid>223</photoid><photogid>5
</photogid></image1>

I tried modifying what you had sent to this

<xsl:template match="/">
  <collection>
    <xsl:apply-templates select="//z:row"/>
  </collection>
</xsl:template>

<xsl:template match="z:row">
  <image>
    <xsl:for-each select="@*">
      <xsl:copy-of select="."/>
    </xsl:for-each>
  </image>
</xsl:template>

<collection xmlns:s="uuid:bdc6e3f0-6da3-11d1-a2a3-00aa00c14882"
xmlns:z="#rowsetschema"><image pdesc="hot rod" filename="ab_0001.jpg"
photoid="223" photogid="5"></image><image pdesc="brass headlamps"
filename="ab_0002.jpg" photoid="224" photogid="5"></image></collection>

Which seems to provide what I actually need, so thanks for your pointer,
much appreciated?

By the way, do I need to get rid of the
xmlns:s="uuid:bdc6e3f0-6da3-11d1-a2a3-00aa00c14882 in the <collection tag?

Also, I found that the tag <image> puts image place holders all over the
page, so changed that to <images>

Many Thanks, Rob.

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: 19 July 2005 15:47
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] RE: Transformation XML to XML

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/

Current Thread