This:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl
![Blush :o :o](/styles/default/custom/smilies/blush.gif)
utput method="xml" indent="yes"/>
<!-- <xsl:strip-space elements="*"/> -->
<xsl:key name="k1" match="cat" use="@category"/>
<xsl:template match="DocumentElement">
<html>
<body>
<h2></h2>
<p><xsl:text><content></xsl:text></p>
<xsl:copy>
<xsl:for-each select="cat[generate-id() = generate-
id(key('k1', @category))[1]]">
<cat name="{@category}">
<xsl:apply-templates select="key('k1',
@category)/*"/>
</cat>
</xsl:for-each>
</xsl:copy>
<p><xsl:text></content></xsl:text></p>
</body>
</html>
</xsl:template>
<xsl:template match="cat/*">
<item>
<xsl:copy><xsl:value-of select="node()"/></xsl:copy>
</item>
</xsl:template>
</xsl:stylesheet>
produces the following output:
<item><name>diehard.png</name></item><item><thumbnail>/video
s/special/thumbnail/diehard.png</thumbnail></item><item><inf
o>This is a short description for my
video</info></item><item><longinfo>This is a longer
description for my
video.</longinfo></item><item><file>/videos/special/flv/live
freeordiehard-
tlr1_h640w.flv</file></item><item><name>rata.png</name></ite
m><item><thumbnail>/videos/special/thumbnail/rata.png</thumb
nail></item><item><info>This is the second short description
for my video</info></item><item><longinfo>This is the second
longer description for my
video.</longinfo></item><item><file>/videos/special/flv/rata
touille-tlr2_h640w.flv</file></item>
the problem is:
I want the output to be of this format:
<content>
<cat category="something">
<item>
<name>diehard.png</name>
<thumbnail>
/videos/special/thumbnail/diehard.png
</thumbnail>
<info>
This is a short description for my video
</info>
<longinfo>
This is a longer description for my video.
</longinfo>
<file>
/videos/special/flv/livefreeordiehard-
tlr1_h640w.flv
</file>
</item>
<item>
<name>rata.png</name>
<thumbnail>
/videos/special/thumbnail/rata.png
</thumbnail>
<info>
This is the second short description for my
video
</info>
<longinfo>
This is the second longer description for my
video.
</longinfo>
<file>
/videos/special/flv/ratatouille-tlr2_h640w.flv
</file>
</item>
</cat>
... and for any additional cat of same attribute...
<cat ...>
</cat>
</content>
I can't figure out how to make the xsl to do this, yet. Any
help is appreciated.
Mars