Hi,
I have an xsl document called 'article.xsl'
Within that document is an INCLUDE statement to include 'incNavigation.xsl'
This used to be working just fine.
Now, suddenly it's broken, I get the error:
--------------------------
----------
----------
----------
----------
----------
--
MM_XSLTransform error:
"../sitemanager/sites/shee
pdrove/xsl
/article.x
sl" is not a valid XSLT document.
Named template 'theCount' does not exist in the stylesheet.
--------------------------
----------
----------
----------
----------
----------
--
I know for sure that 'theCount' does exist, only it's in the included doc - incNavigation.xsl, so obviously that's not getting parsed.
I've read that a recent MS security patch has stopped includes from being allowed by default. Refer to article:
http://frater.wordpress.com/2007/08/23/problems-with-kb936021-xsl-parsing-variable-scopes-and-includes-oh-my/This article offers the solution that you set
xsl.resolveExternals = true
and then the include will be parsed.
My problem is I'm using the VB XSL transformation that comes with Dreamweaver 8, and I can't figure out where I should set resolveExternals to 'true'. Can anyone help, I'm getting very confused!
Many thanks!
More information:
=================
I have a simple asp page that calls the XSL transformation like this:
article.asp
-----------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="includes/MM_XSLTrans
form/MM_XS
LTransform
.classVB.a
sp" -->
<%
On Error Resume Next
Dim mm_xsl: Set mm_xsl = new MM_XSLTransform
mm_xsl.setXML theXmlFile
mm_xsl.setXSL theXsl
Response.write mm_xsl.Transform()
If Err.Number <> 0 Then
response.Redirect("
www.mydomain.com/error.htm"
)
End If
%>
Then the Dreamweaver file does the work, and looks like this:
MM_XSLTransform.classVB.as
p
--------------------------
----------
---
<%
' MM_XSLTransform version: 0.6.2
Class MM_XSLTransform
Private xmlUri ' XML source
Private xslUri ' XSL source
Private params ' processor parameters
Private errorMsg ' the error message that might be
thrown by the library
Private errorCode ' the code of the error
Private errorMessages ' a dictionary with all the codes-messages
for the possible thrown errors of the library.
' dynamic strings
are represented by the placeholders %s and rendered only when the error is actually
thrown
' objects used for transformation
Private objXMLDOM
Private objFreeDOM
Private objXSLTemplate
Private Sub Class_Initialize()
Set errorMessages = Server.CreateObject("Scrip
ting.Dicti
onary")
' Start error messages definition
errorMessages("MM_GENERIC_
MESSAGE") = "MM_XSLTransform error:<br>"
errorMessages("MM_EMPTY_XM
L_SOURCE")
= "XML source cannot be empty."
errorMessages("MM_EMPTY_XS
L_SOURCE")
= "XSLT source cannot be empty."
errorMessages("MM_MISSING_
OBJECT") = "Required object (""%s"") from Microsoft XML
Core Services (MSXML) is not installed.<br>Download and install the latest version from
http://msdn.microsoft.com/xml before continuing."
errorMessages("MM_INVALID_
PATH") = """%s"" is not a valid path.<br>Error message
was: %s"
errorMessages("MM_XML_LOAD
ING_ERROR"
) = "An error occured while loading XML
document ""%s"".<br>Error message was: %s"
errorMessages("MM_XSL_LOAD
ING_ERROR"
) = "An error occured while loading XSLT
document ""%s"".<br>Error message was: %s"
errorMessages("MM_INVALID_
XML_ERROR"
) = """%s"" is not a valid XML document.<br>"
errorMessages("MM_INVALID_
XSL_ERROR"
) = """%s"" is not a valid XSLT
document.<br>"
errorMessages("MM_LOADING_
FAILED_DET
AILS") = "reason: %s<br>error code:
%s<br>file position: %s<br>line: %s<br>character position: %s<br>"
errorMessages("MM_XSL_ERRO
R") = """%s"" is not a valid XSLT document.<br>%s"
errorMessages("MM_TRANSFOR
M_ERROR") = "Error while transforming:<br>%s"
errorMessages("MM_OPEN_FIL
E_ERROR") = "The specified file %s could not be
found.<br>"
' End error messages definition
Set params = Server.CreateObject("Scrip
ting.Dicti
onary")
End Sub
Public Sub setXML(xmlUri_param)
xmlUri = Trim(xmlUri_param)
End Sub
Public Sub setXSL(xslUri_param)
xslUri = Trim(xslUri_param)
End Sub
Public Sub addParameter(paramName, paramValue)
params(paramName) = paramValue
End Sub
Private Sub CheckInput()
If len(xmlUri) = 0 Then
setError "MM_EMPTY_XML_SOURCE", array()
Exit Sub
End If
If len(xslUri) = 0 Then
setError "MM_EMPTY_XSL_SOURCE", array()
End If
End Sub
Private Sub CreateTransformationObject
s()
On Error Resume Next
Set objXMLDOM = Server.CreateObject("MSXML
2.DOMDocum
ent")
If err.number <> 0 Then
On Error GoTo 0
setError "MM_MISSING_OBJECT", array("MSXML2.DOMDocument"
)
Exit Sub
End If
Set objFreeDOM =
Server.CreateObject("MSXML
2.FreeThre
adedDOMDoc
ument")
If err.number <> 0 Then
On Error GoTo 0
setError "MM_MISSING_OBJECT",
array("MSXML2.FreeThreaded
DOMDocumen
t")
Exit Sub
End If
Set objXSLTemplate = Server.CreateObject("MSXML
2.XSLTempl
ate")
If err.number <> 0 Then
On Error GoTo 0
setError "MM_MISSING_OBJECT", array("MSXML2.XSLTemplate"
)
Exit Sub
End If
On Error GoTo 0
End Sub
Private Function isURL(strResource)
isURL = False
If Instr(1, strResource, "
http://", 1) = 1 Or Instr(1,
strResource, "
https://", 1) = 1 Then
isURL = True
End If
End Function
Private Sub LoadFromFile(path, ByRef objdom, filetype)
objdom.async = False
objdom.resolveExternals = False
objdom.validateOnParse = False
On Error Resume Next
realPath = Server.MapPath(path)
If err.Number<> 0 Then
setError "MM_INVALID_PATH", array(path, err.Description)
On Error GoTo 0
Exit Sub
End If
Set fs=Server.CreateObject("Sc
ripting.Fi
leSystemOb
ject")
If (fs.FileExists(realPath))=
False Then
setError "MM_OPEN_FILE_ERROR", array(path)
On Error GoTo 0
Exit Sub
End If
Set fs=Nothing
loadingTest = objdom.load (realPath)
If err.Number <> 0 Then
If filetype = "xml" Then
setError "MM_XML_LOADING_ERROR", array(path,
err.Description)
Else
setError "MM_XSL_LOADING_ERROR", array(path,
err.Description)
End If
On Error GoTo 0
Exit Sub
End If
If loadingTest = false Then
If filetype = "xml" Then
setError "MM_INVALID_XML_ERROR", array(path)
Else
setError "MM_INVALID_XSL_ERROR", array(path)
End If
Set myErr = objdom.parseError
If (myErr.errorCode <> 0) Then
addError "MM_LOADING_FAILED_DETAILS
",
array(myErr.reason, myErr.errorCode, myErr.filepos, myErr.line, myErr.linepos)
End If
End If
On Error GoTo 0
End Sub
Private Sub LoadFromURL (url, ByRef objdom, filetype)
Dim objhttp
On Error Resume Next
Set objhttp = Server.CreateObject("MSXML
2.ServerXM
LHTTP")
If err.number<>0 Then
On Error GoTo 0
setError "MM_MISSING_OBJECT",
array("MSXML2.ServerXMLHTT
P")
Exit Sub
End If
objhttp.open "GET", url, False
objhttp.setRequestHeader "Content-Type","text/xml"
objhttp.send
If err.Number<> 0 Then
If filetype = "xml" Then
setError "MM_XML_LOADING_ERROR", array(url,
err.Description)
Else
setError "MM_XSL_LOADING_ERROR", array(url,
err.Description)
End If
On Error GoTo 0
Exit Sub
End If
objdom.async = False
objdom.resolveExternals = False
objdom.validateOnParse = False
loadingTest = objdom.load (objhttp.responseStream)
If err.Number <> 0 Then
If filetype = "xml" Then
setError "MM_XML_LOADING_ERROR", array(url,
err.Description)
Else
setError "MM_XSL_LOADING_ERROR", array(url,
err.Description)
End If
On Error GoTo 0
Exit Sub
End If
If loadingTest = false Then
If filetype = "xml" Then
setError "MM_INVALID_XML_ERROR", array(url)
Else
setError "MM_INVALID_XSL_ERROR", array(url)
End If
Set myErr = objdom.parseError
If (myErr.errorCode <> 0) Then
addError "MM_LOADING_FAILED_DETAILS
",
array(myErr.reason, myErr.errorCode, myErr.filepos, myErr.line, myErr.linepos)
End If
End If
On Error GoTo 0
End Sub
Public Function Transform()
CheckInput
If hasError() Then
Transform = getError()
Exit Function
End If
' Create the required objects to perform the transformation
CreateTransformationObject
s()
If hasError() Then
Transform = getError()
Exit Function
End If
' Load XML
If isURL(xmlUri) Then
LoadFromURL xmlUri, objXMLDOM, "xml"
Else
LoadFromFile xmlUri, objXMLDOM, "xml"
End If
If hasError() Then
Transform = getError()
Exit Function
End If
' Load XSL
If isURL(xslUri) Then
LoadFromURL xslUri, objFreeDOM, "xsl"
Else
LoadFromFile xslUri, objFreeDOM, "xsl"
End If
If hasError() Then
Transform = getError()
Exit Function
End If
' DO the transformation
On Error Resume Next
objXSLTemplate.stylesheet = objFreeDOM
If Err.Number <> 0 Then
setError "MM_XSL_ERROR", array(xslUri, Err.Description)
Transform = getError()
On Error GoTo 0
Exit Function
End If
On Error GoTo 0
Dim processor
Set processor = objXSLTemplate.createProce
ssor
' set source xml
processor.input = objXMLDOM
' add parameters
For each param in params
processor.addParameter param, params(param)
Next
' call transform
'processor.output = Response
'readyTest = processor.transform
On Error Resume Next
readyTest = processor.transform
If err.Number <> 0 Then
setError "MM_TRANSFORM_ERROR", array(err.description)
Transform = getError()
On Error GoTo 0
Exit Function
End If
On Error GoTo 0
Transform = processor.output
End Function
' Error handling functions
Private Sub setError(errorCode_param, ByRef arrParams)
errorCode = errorCode_param
errorMsg = sprintf(errorMessages(erro
rCode_para
m), arrParams)
End Sub
Private Sub addError(errorCode_param, ByRef arrParams)
errorMsg = errorMsg & sprintf(errorMessages(erro
rCode_para
m),
arrParams)
End Sub
Private Function hasError()
hasError = False
If errorCode <> "" Then
hasError = True
End If
End Function
Private Function getError()
getError = errorMessages("MM_GENERIC_
MESSAGE") & errorMsg
End Function
' utility function
' builds a string using a template and an array of params (C style)
Private Function sprintf (strSource, ByRef arrParams)
Dim strRest: strRest = strSource
Dim strReturn: strReturn = ""
For i = 0 To UBound(arrParams)
pos = Instr(strRest, "%s")
If pos <> 0 Then
strReturnSlice = Left(strRest, pos+1)
strReturnSlice = Replace(strReturnSlice, "%s",
arrParams(i))
strReturn = strReturn & strReturnSlice
strRest = Mid(strRest, pos+2)
End If
Next
strReturn = strReturn & strRest
sprintf = strReturn
End Function
Private Sub Class_terminate()
Set errorMessages = nothing
Set params = nothing
Set objXMLDOM = nothing
Set objFreeDOM = nothing
Set objXSLTemplate = nothing
End Sub
End Class
%>