Hola a todos,
despues de pelearme bastante con la version 1 he visto que con la version 2 hay cosas que pueden facilitar el trabajo mucho. He probado el ejemplo que pongo a continuacion pero no logro que funcione.
xml:
Código:
<?xml version="1.0" encoding="UTF-8"?>
<company>
<employee name="Matt" quarter="q1" amount="700"/>
<employee name="Matt" quarter="q2" amount="200"/>
<employee name="Matt" quarter="q1" amount="300"/>
<employee name="SamosaMan" quarter="q1" amount="400"/>
<employee name="SamosaMan" quarter="q2" amount="60"/>
</company>
xsl:
Código:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="h t t p : //w w w.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match=" / ">
<xsl:for-each- group select = "company/employee" group-by = "[arroba]name" >
<tr>
<td><xsl : value-of select="[arroba]name" / ></ td>
<td>
<table>
<xsl:for-each-group select="current-group()" group-by="[arroba]quarter">
<tr>
<td><xsl:value-of select="[arroba]quarter" />=<xsl:value-of select="sum(current-group() / [arroba]amount)" /></ td>
</ tr>
</ xsl:for-each-group>
</ table>
</ td>
</ tr>
</ xsl:for-each-group>
</ xsl:template>
</ xsl:stylesheet>
asp que procesa xsl y xml
Código:
<%
Dim objXML
Dim objXSL
Dim strHTML
'Load the XML File
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.load(Server.MapPath("mafufo.xml"))
'Load the XSL File
Set objXSL = Server.CreateObject("Microsoft.XMLDOM")
objXSL.async = False
objXSL.load(Server.MapPath("mafufo.xsl"))
' Transform the XML file using the XSL stylesheet
strHTML = objXML.transformNode(objXSL)
Set objXML = Nothing
Set objXSL = Nothing
' Spit out the resulting HTML... the data comes from the
' .xml file, but the formatting of the results depends
' completely upon the .xsl file.
Response.Write strHTML
%>
En el navegador pongo la dirección del asp para que procese el resultado pero me saca este erro:
msxml3.dll error '80004005'
La palabra clave xsl:template no puede contener xsl:for-each-group.
/prueba/mafufo.asp, línea 17
Alguien sabria decirme donde me estoy equivocando, gracias de antemano a todos.
P.D Como os imaginareis los [arroba] las pongo ya que no me deja poner el simbolo como tal