arst06d
Programmer
- Nov 29, 2002
- 324
Hi
I have a well-formed XML doc and a XSL doc to display it.
Doing the transformation server side in an asp page as follows:
<%
ShowContactCard("HCS")
function ShowContactCard(RegionCode)
on error resume next
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
'response.write server.mappath("contactCards.xml") & "<br>"
xml.load(server.mappath("contactCards.xml"))
if err then
response.write "An error has occurred at Pos 1 -- " & err.description
err.clear
end if
'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
'response.write server.mappath("contactCards.xsl") & "<br>"
xsl.load(server.mappath("contactCards.xsl"))
if err then
response.write "An error has occurred at Pos 2 -- " & err.description
err.clear
end if
'Transform file
Response.Write(xml.transformNode(xsl))
if err then
response.write "An error has occurred at Pos 3 -- " & err.description
err.clear
end if
end function
%>
Within the XSL I use <xsl:if ...> to test for a value, which I have at present hardcoded into a <xsl:variable ...> as below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:template match="/">
<html>
<head>
<title>Contact Cards</title>
</head>
<body>
<xsl:variable name="RegCode" select='"HCC"'/>
<xsl:for-each select="contactCards/Region">
<xsl:if test="RegionCode=$RegCode">
<xsl:value-of select="RegionName"/><br/>
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
What I would like to do is pass the variable from the asp function when I do the transformation.
Can anyone help, please?
I have a well-formed XML doc and a XSL doc to display it.
Doing the transformation server side in an asp page as follows:
<%
ShowContactCard("HCS")
function ShowContactCard(RegionCode)
on error resume next
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
'response.write server.mappath("contactCards.xml") & "<br>"
xml.load(server.mappath("contactCards.xml"))
if err then
response.write "An error has occurred at Pos 1 -- " & err.description
err.clear
end if
'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
'response.write server.mappath("contactCards.xsl") & "<br>"
xsl.load(server.mappath("contactCards.xsl"))
if err then
response.write "An error has occurred at Pos 2 -- " & err.description
err.clear
end if
'Transform file
Response.Write(xml.transformNode(xsl))
if err then
response.write "An error has occurred at Pos 3 -- " & err.description
err.clear
end if
end function
%>
Within the XSL I use <xsl:if ...> to test for a value, which I have at present hardcoded into a <xsl:variable ...> as below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:template match="/">
<html>
<head>
<title>Contact Cards</title>
</head>
<body>
<xsl:variable name="RegCode" select='"HCC"'/>
<xsl:for-each select="contactCards/Region">
<xsl:if test="RegionCode=$RegCode">
<xsl:value-of select="RegionName"/><br/>
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
What I would like to do is pass the variable from the asp function when I do the transformation.
Can anyone help, please?