Re: xml & classement suivant attribut

julien TOUCHE <[email protected]>
Newsgroups gmane.text.xml.french.tech
Message-ID <[email protected]>
si ca interesse qq un (et pour les archives), le code correct est le
suivant:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               version="1.0">

  <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>

  <xsl:template match="album">
    <xsl:message>Sorting Photo</xsl:message>

      <xsl:for-each select="subalbum">
        <xsl:apply-templates>
          <xsl:sort select="@date" order="descending" data-type="text" />
        </xsl:apply-templates>
      </xsl:for-each>

  </xsl:template>

</xsl:transform>

cf.
http://www.xml.com/lpt/a/2002/07/03/transform.html

et il faut rajouter

  <xsl:template match="*">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

pour avoir une sortie xml au lieu de la sortie texte suivante:

<?xml version="1.0"?>

      /path/1.jpg
      title1
      id1
      note1
      model1

      /path/2.jpg
      title2
      id2
      note2
      model2


finalement, le mieux que j'obtient, c'est:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               version="1.0">

  <xsl:output method="xml" omit-xml-declaration="no" indent="yes"
encoding="utf8"/>

      <xsl:template match="subalbum">
          <xsl:apply-templates>
            <xsl:sort select="@date" order="ascending" data-type="text" />
          </xsl:apply-templates>
      </xsl:template>

  <xsl:template match="*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

</xsl:transform>


Cordialement

		Julien
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.