XSL file formatting
Hi there, I need your appreciated help.
I have problem with this files xsl, the problem is the output for the field date and number:
2011-05-13T21:50:00 instead of
13/05/2001 21:50:00
.00 instead of
0
This is the output in XML:
<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-05-13T21:50:00" Net=".00" />
</rs:data>
</xml>
This output XML is generate with ASP code and saved in the csv format:
<!-- #include virtual="/_XML/adovbs.inc" -->
<%
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
%>
The XSL file:
<?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="/">
<!-- show a header by looking Schema element -->
<xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType">
<xsl:value-of select="@name"/>
<xsl:choose>
<xsl:when test="position()!=last()">
<!-- xls -->
<xsl:text>	</xsl:text>
<!-- csv -->
<!--xsl:text>,</xsl:text-->
</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<!-- row data -->
<xsl:for-each select="/xml/rs:data/z:row">
<xsl:variable name="row" select="."/>
<!-- for each column -->
<xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType">
<!-- display each column if it exists -->
<xsl:variable name="columnName" select="@name"/>
<!-- go through all columns and display something that matches-->
<xsl:value-of select="$row/@*[name()=$columnName]" />
<!--xsl:value-of select="translate($row/@*[name()=$columnName],'.',',')" /-->
<xsl:if test="position()!=last()">
<!-- xls -->
<xsl:text>	</xsl:text>
<!-- csv -->
<!--xsl:text>,</xsl:text-->
</xsl:if>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I need another output in the XML file:
<z:row myDates="13/05/2001 21:50:00" Net="0.00" />
And in the CSV file:
13/05/2001 21:50:00, 0
Can you help me?
Thanks in advance.
Cheers
Edited 1 time(s). Last edit at 08/30/2011 11:38PM by angel rivero.