PDA

View Full Version : XSL Syntax - PLEASE HELP!!


RTK
07-07-2007, 06:22 PM
I am a complete newbie to XML/XSL, but was handed a production problem.
I made a (what I thought was) a simple change to my XSL file.

I am getting the "The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document" error

Any help would be GREATLY appreciated !!


*** Here is the new file with changes highlighted in blue



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:param name="date">12/31/2000</xsl:param>
<!--xsl:param name="date">12/31/2000</xsl:param-->
<xsl:template match="/">
select
1 as Tag,
null as Parent,
<xsl:for-each select="response/element">
<xsl:choose>
<xsl:when test="compustat = 'IINT'">
IDIT as [Data!1!<xsl:value-of select="dlb"/>!element]
</xsl:when>
<xsl:when test="compustat = 'DCVSUB' or compustat = 'PCUV'">
0.0 as [Data!1!<xsl:value-of select="dlb"/>!element]
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="compustat"/> as [Data!1!<xsl:value-of select="dlb"/>!element]
</xsl:otherwise>
</xsl:choose>

<!--xsl:value-of select="compustat"/> as [Data!1!<xsl:value-of select="dlb"/>!element] -->
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:choose>
<xsl:when test="response/period = 'Y'">
from XF.dbo.co_annfund1 ca1
join XF.dbo.co_annfund2 ca2 on ca1.gvkey = ca2.gvkey and ca1.datadate = ca2.datadate and ca1.popsrc = ca2.popsrc
join XF.dbo.security s on s.gvkey = ca1.gvkey
join XF.dbo.co_ann ca on ca.gvkey = ca1.gvkey and ca.datadate = ca1.datadate and ca.popsrc = ca1.popsrc
where
s.tic = '<xsl:value-of select="response/ticker"/>'
and ca1.popsrc = 'D'
and Datepart(yyyy,ca.datadate) = Datepart(yyyy,'<xsl:value-of select="$date"/>')
</xsl:when>
<xsl:otherwise>
from XF.dbo.co_idesind cq
join XF.dbo.co_ifndq cqf on cq.gvkey = cqf.gvkey and cq.datadate = cqf.datadate and cqf.DATAFMT = 'STD' or cqf.DATAFMT = 'PRE_AMENDS' and cqf.INDFMT = 'INDL' and cqf.CONSOL <> 'N'
join XF.dbo.co_ifndytd cqy on cq.gvkey = cqy.gvkey and cq.datadate = cqy.datadate and cqy.DATAFMT = 'STD' or cqy.DATAFMT = 'PRE_AMENDS' and cqy.INDFMT = 'INDL' and cqy.CONSOL <> 'N'
join XF.dbo.security s on s.gvkey = cq.gvkey where
s.tic = '<xsl:value-of select="response/ticker"/>'
and Datepart(yyyy,cq.datadate) = Datepart(yyyy,'<xsl:value-of select="$date"/>')
and Datepart(mm,cq.datadate) = Datepart(mm,'<xsl:value-of select="$date"/>')
</xsl:otherwise>
</xsl:choose>
FOR XML EXPLICIT
if @@ROWCOUNT = 0
begin
select
1 as Tag,
null as Parent,
<xsl:for-each select="response/element">
0 as [Data!1!<xsl:value-of select="dlb"/>!element]
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
FOR XML EXPLICIT
end
</xsl:template>

</xsl:stylesheet>



THANK YOU !!!!!

RTK
07-07-2007, 07:17 PM
I get the error here in my code ...

Line 1 (works fine)
(set objXSL = CreateObject("Msxml2.FreeThreadedDOMDocument.4.0")

Line 2 (works fine)
objXSL.load sPath (works fine - spath is explicit path to my xsl file)

Line 3 (error occurs here)
set xslTemp.stylesheet = objXSL (XSLTemp is of type Msxml2.XSLTemplate.4.0)

Again ... any info would be greatly appreciated

RTK
07-07-2007, 08:34 PM
All Set - I think the problem was my use of "<>" in the SQL ..