Re: [xsl] Transposing matrices

Subject: Re: [xsl] Transposing matrices
From: martin@xxxxxxxx
Date: Sun, 20 Oct 2002 19:29:27 +0000 (GMT)
Nickolay -

should the 'embedded' matrices be transposed as well?
then maybe

<xsl:template match="matrix"> <!-- no need for // -->
 <xsl:variable name="matrix" select="."/>
 <matrix>
 <xsl:for-each select="row[1]/item">
 <xsl:variable name="i" select="position()"/>
 <row>
   <xsl:for-each select="$matrix/row">
     <item><xsl:apply-templates select="item[$i]/*"/></item>
   </xsl:for-each>
 </row>
 </xsl:for-each>
 </matrix>
 </xsl:template>

provided there's a template (eg the default) for text that copies
content that isn't a matrix. also, this may not work with non-text,
non-matrix items!

otherwise, replace the value-of with copy-of :
    <xsl:copy-of select="item[$i]"/>
(no enclosing <item> tags as you get them anyhow with the copy-of)

btw, you wrote: <xsl:for-each select="//row">
this will match on all rows of all matrices, probably not what you want

hth,

/m




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread