Ciao, spero possiate aiutarmi.
Ho un problema con la formattazione di alcuni campi esportati da un db in XML, trasformati in XSL e salvati in formato CSV.
Questo è l'output in XML:
Generato tramite ASP, trasformato in XSL e salvato in formato CSV:codice:<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"> <s:Schema id="RowsetSchema"> <s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30"> <s:AttributeType name="myDates" rs:number="6" rs:nullable="true" rs:writeunknown="true"> <s:datatype dt:type="dateTime" rs:dbtype="timestamp" dt:maxLength="16" rs:scale="0" rs:precision="19" rs:fixedlength="true"/> </s:AttributeType> <s:AttributeType name="Net" rs:number="29" rs:nullable="true" rs:writeunknown="true"> <s:datatype dt:type="number" rs:dbtype="numeric" dt:maxLength="19" rs:scale="2" rs:precision="10" rs:fixedlength="true"/> </s:AttributeType> <s:extends type="rs:rowbase"/> </s:ElementType> </s:Schema> <rs:data> <z:row myDates="2011-08-22T03:03:52" Net=".00" /> </rs:data> </xml>
Avrei necessità di questo output nel file XML:codice:<% filename = "titty.xml" Set xmlDoc = CreateObject("MSXML2.DOMDocument.4.0") Set xslDoc = CreateObject("MSXML2.DOMDocument.4.0") %> <% sql = "SELECT * FROM tbl_login" Set rs = objConn.Execute(sql) rs.Save xmlDoc, 1 xmlDoc.Save Server.MapPath(filename) rs.Close Set rs = Nothing %> <% Set oDOM = CreateObject("MSXML2.DOMDocument.4.0") oDOM.async = False oDOM.Load Server.Mappath(filename) Set oXSL = CreateObject("MSXML2.DOMDocument.4.0") oXSL.async = False oXSL.Load Server.Mappath("Trasform_csv.xsl") strTransform = oDOM.transformNode(oXSL) Set fso = CreateObject("Scripting.FileSystemObject") strPath = Server.Mappath("testme.csv") Set file = fso.opentextfile(strPath, 2, True) file.write strTransform file.Close Set file = Nothing Set fso = Nothing Set oDOM = Nothing Set oXML = Nothing Set oXSL = Nothing %>
ed anche nel file CSV:codice:<z:row myDates="13/05/2001 21:50:00" Net="0.00" />
Ho provato così, ma dà questo errore:codice:13/05/2001 21:50:00, 0
Tipo di errore:
msxml4.dll (0x80004005)
Impossibile risolvere un riferimento alla variabile o al parametro "myDates". La variabile o il parametro non sono definiti oppure non sono inclusi nell'ambito valido.
XSL file:
codice:<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"> <xsl:output omit-xml-declaration="yes"/> <xsl:template match="/"> <xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType"> <xsl:value-of select="@name"/> <xsl:choose> <xsl:when test="position()!=last()"> <xsl:text>	</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>
</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:for-each select="/xml/rs:data/z:row"> <xsl:variable name="row" select="."/> <xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType"> <xsl:variable name="columnName" select="@name"/> <xsl:value-of select="$row/@*[name()=$columnName]" /> <xsl:value-of select="concat(substring($myDates, 6,2), '/', substring($myDates, 9,2), '/', substring($myDates, 1,4), ' ', substring($DataInterr, 12))" /> <xsl:if test="position()!=last()"> <xsl:text>	</xsl:text> </xsl:if> </xsl:for-each> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>

Rispondi quotando