A
asim
Hi All
i m transforming a simple XSL file on Server side using MSXML Parser ...
and writting resultant HTML directly on browser .. is there any way to get
this HTML in a variable ???
i seen the article on MSDN but it makes my page blank ... plz edit my code
to make is work in this manner, if possible
Thankx in advance
Plz Help
'MY ASP FILE CODE
strxml = "<data><name>Asim</name></data>"
XSLFilePath = "C:\Emaples\test.xsl"
call TransformDocument(strXMl,XSLFilePath)
function TransformDocument(srcXML, srcXSL)
Dim sourceFile, styleFile, source
'the xsl file path
styleFile = srcXSL
set source = Server.CreateObject("MSXML2.DOMDocument")
source.async = false
source.loadXML srcXML
'Get The Style Object
set style = Server.CreateObject("MSXML2.DOMDocument")
style.async = false
style.load styleFile
'Error Handaling
if (source.parseError.errorCode <> 0) then
'result = reportParseError(source.parseError)
set oerr = source.parseError
sErrMsg = "XML Parsing Error. File: " & oErr.url & " Reason : " &
oErr.reason & " Line: " & oErr.line & ", Character: " & oErr.linepos & ",
Text: " & oErr.srcText
Response.Write sErrMsg
elseif (style.parseError.errorCode <> 0) then
'result = reportParseError(style.parseError)
set oerr = style.parseError
sErrMsg = "XML Parsing Error. File: " & oErr.url & " Reason : " &
oErr.reason & " Line: " & oErr.line & ", Character: " & oErr.linepos & ",
Text: " & oErr.srcText
Response.Write sErrMsg
else
source.transformNodeToObject style,Response
end if
End Function
'MY XSL FILE CODE
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="html" version="4.0" encoding="utf-8"/>
<xsl:variable name="name">??!</xsl:variable>
<xsl:template match="data">
<html>
<head><META http-equiv="Content-Type" content="text/html;
charset=utf-8"/></head>
<body>
<hr/>
Name from XML is : <xsl:value-of select="//name"/>
<hr/>
Variable/Contant Value from XSL is : <xsl:value-of select="$name"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
i m transforming a simple XSL file on Server side using MSXML Parser ...
and writting resultant HTML directly on browser .. is there any way to get
this HTML in a variable ???
i seen the article on MSDN but it makes my page blank ... plz edit my code
to make is work in this manner, if possible
Thankx in advance
Plz Help
'MY ASP FILE CODE
strxml = "<data><name>Asim</name></data>"
XSLFilePath = "C:\Emaples\test.xsl"
call TransformDocument(strXMl,XSLFilePath)
function TransformDocument(srcXML, srcXSL)
Dim sourceFile, styleFile, source
'the xsl file path
styleFile = srcXSL
set source = Server.CreateObject("MSXML2.DOMDocument")
source.async = false
source.loadXML srcXML
'Get The Style Object
set style = Server.CreateObject("MSXML2.DOMDocument")
style.async = false
style.load styleFile
'Error Handaling
if (source.parseError.errorCode <> 0) then
'result = reportParseError(source.parseError)
set oerr = source.parseError
sErrMsg = "XML Parsing Error. File: " & oErr.url & " Reason : " &
oErr.reason & " Line: " & oErr.line & ", Character: " & oErr.linepos & ",
Text: " & oErr.srcText
Response.Write sErrMsg
elseif (style.parseError.errorCode <> 0) then
'result = reportParseError(style.parseError)
set oerr = style.parseError
sErrMsg = "XML Parsing Error. File: " & oErr.url & " Reason : " &
oErr.reason & " Line: " & oErr.line & ", Character: " & oErr.linepos & ",
Text: " & oErr.srcText
Response.Write sErrMsg
else
source.transformNodeToObject style,Response
end if
End Function
'MY XSL FILE CODE
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="html" version="4.0" encoding="utf-8"/>
<xsl:variable name="name">??!</xsl:variable>
<xsl:template match="data">
<html>
<head><META http-equiv="Content-Type" content="text/html;
charset=utf-8"/></head>
<body>
<hr/>
Name from XML is : <xsl:value-of select="//name"/>
<hr/>
Variable/Contant Value from XSL is : <xsl:value-of select="$name"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>