Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL parameter passing from ASP

Status
Not open for further replies.

Bakunin

Programmer
Dec 21, 2000
31
0
0
GB
Hi,
I am trying to get an XSL file to accept a parameter from ASP to process an XML file. However when I run the thing it fails with:

MSXML3.DLL error '80004005'

Required attribute 'version' is missing.

/test/periodic.asp, line 27


Can anyone point out where my problem is. Source below.

Thanks in advance.


<%@ Language=VBScript %>
<%

Option Explicit
'On Error Resume Next

Dim sHTML ' HTML to output to browser
Dim oXML ' XML Dom object
Dim bLoad ' Make sure the xml doc was loaded successfully


Set oXML = Server.CreateObject(&quot;MSXML2.FreeThreadedDOMDocument&quot;)
bLoad = oXML.load(Server.MapPath(&quot;periodic.xml&quot;))

If bLoad Then
Dim oXSL
Dim oTemplate
Dim oProc
Dim oResult

Set oXSL = Server.CreateObject(&quot;MSXML2.FreeThreadedDOMDocument&quot;)
Set oTemplate = Server.CreateObject(&quot;MSXML2.XSLTemplate&quot;)
Set oResult = Server.CreateObject(&quot;MSXML2.FreeThreadedDOMDocument&quot;)
oXSL.load Server.MapPath(&quot;periodic.xsl&quot;)
oTemplate.stylesheet = oXSL
Set oProc = oTemplate.createProcessor()
oProc.input = oXML
oProc.output = oResult
oProc.addParameter &quot;myatom&quot;, &quot;Carbon&quot;
oProc.transform

sHTML = oResult.xml
End If

%>

<html>

<%=sHTML%>

</html>


<?xml version=&quot;1.0&quot;?>
<PERIODIC_TABLE>

<ATOM STATE=&quot;GAS&quot;>
<NAME>Hydrogen</NAME>
<SYMBOL>H</SYMBOL>
<ATOMIC_NUMBER>1</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>1.00794</ATOMIC_WEIGHT>
<BOILING_POINT UNITS=&quot;Kelvin&quot;>20.28</BOILING_POINT>
<MELTING_POINT UNITS=&quot;Kelvin&quot;>13.81</MELTING_POINT>
<DENSITY UNITS=&quot;grams/cubic centimeter&quot;><!-- At 300K -->
0.0899
</DENSITY>
</ATOM>

<ATOM STATE=&quot;GAS&quot;>
<NAME>Helium</NAME>
<SYMBOL>He</SYMBOL>
<ATOMIC_NUMBER>2</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>4.0026</ATOMIC_WEIGHT>
<BOILING_POINT UNITS=&quot;Kelvin&quot;>4.216</BOILING_POINT>
<MELTING_POINT UNITS=&quot;Kelvin&quot;>0.95</MELTING_POINT>
<DENSITY UNITS=&quot;grams/cubic centimeter&quot;><!-- At 300K -->
0.1785
</DENSITY>
</ATOM>

<ATOM STATE=&quot;SOLID&quot;>
<NAME>Berylium</NAME>
<SYMBOL>Be</SYMBOL>
<ATOMIC_NUMBER>3</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>6.0026</ATOMIC_WEIGHT>
<BOILING_POINT UNITS=&quot;Kelvin&quot;>4.216</BOILING_POINT>
<MELTING_POINT UNITS=&quot;Kelvin&quot;>0.95</MELTING_POINT>
<DENSITY UNITS=&quot;grams/cubic centimeter&quot;><!-- At 300K -->
0.1785
</DENSITY>
</ATOM>

<ATOM STATE=&quot;SOLID&quot;>
<NAME>Boron</NAME>
<SYMBOL>B</SYMBOL>
<ATOMIC_NUMBER>4</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>8.26</ATOMIC_WEIGHT>
<BOILING_POINT UNITS=&quot;Kelvin&quot;>4.216</BOILING_POINT>
<MELTING_POINT UNITS=&quot;Kelvin&quot;>0.95</MELTING_POINT>
<DENSITY UNITS=&quot;grams/cubic centimeter&quot;><!-- At 300K -->
0.1785
</DENSITY>
</ATOM>

<ATOM STATE=&quot;SOLID&quot;>
<NAME>Carbon</NAME>
<SYMBOL>C</SYMBOL>
<ATOMIC_NUMBER>5</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>14</ATOMIC_WEIGHT>
<BOILING_POINT UNITS=&quot;Kelvin&quot;>4.216</BOILING_POINT>
<MELTING_POINT UNITS=&quot;Kelvin&quot;>0.95</MELTING_POINT>
<DENSITY UNITS=&quot;grams/cubic centimeter&quot;><!-- At 300K -->
0.1785
</DENSITY>
</ATOM>


</PERIODIC_TABLE>




<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl=&quot;
<xsl:param name=&quot;myatom&quot; />

<xsl:template match=&quot;/&quot;>
<html>
<table border=&quot;2&quot; bgcolor=&quot;yellow&quot;>
<tr>
<th>Title</th>
<th>Artist</th>
<th>State</th>
</tr>
<xsl:apply-templates/>
</table>
</html>
</xsl:template>


<xsl:template match=&quot;PERIODIC_TABLE&quot;>
<body>
<xsl:apply-templates/>
</body>
</xsl:template>

<xsl:template match=&quot;ATOM&quot;>
<xsl:if match=&quot;.[NAME = $myatom]&quot;>
<xsl:value-of select=&quot;NAME&quot;/>
<xsl:value-of select=&quot;SYMBOL&quot;/>
<xsl:value-of select=&quot;ATOMIC_NUMBER&quot;/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
 
Try this..........

<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;
Also, can you have:
<xsl:if match=&quot;.[NAME = $myatom]&quot;>

I always thought it had to be:
<xsl:if test=&quot;.[NAME = $myatom]&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top