[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

XSL transformation stopped parsing, probably due to MS security patch

Asked by nigelhayler in Extensible Stylesheet Language Transformation (XSLT), Extensible Markup Language (XML)

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/sheepdrove/xsl/article.xsl" 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_XSLTransform/MM_XSLTransform.classVB.asp" -->
<%
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.asp
---------------------------------------

<%
      ' 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("Scripting.Dictionary")
                                                                    

      
' Start error messages definition
      errorMessages("MM_GENERIC_MESSAGE") = "MM_XSLTransform error:<br>"
      errorMessages("MM_EMPTY_XML_SOURCE") = "XML source cannot be empty."
      errorMessages("MM_EMPTY_XSL_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_LOADING_ERROR") = "An error occured while loading XML

document ""%s"".<br>Error message was: %s"
      errorMessages("MM_XSL_LOADING_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_DETAILS") = "reason: %s<br>error code:

%s<br>file position: %s<br>line: %s<br>character position: %s<br>"
      errorMessages("MM_XSL_ERROR") = """%s"" is not a valid XSLT document.<br>%s"
      errorMessages("MM_TRANSFORM_ERROR") = "Error while transforming:<br>%s"
      errorMessages("MM_OPEN_FILE_ERROR") = "The specified file %s could not be

found.<br>"
' End error messages definition                                    

                  
                  Set params = Server.CreateObject("Scripting.Dictionary")
            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 CreateTransformationObjects()
                  On Error Resume Next
                  Set objXMLDOM = Server.CreateObject("MSXML2.DOMDocument")
                  If err.number <> 0 Then
                        On Error GoTo 0
                        setError "MM_MISSING_OBJECT", array("MSXML2.DOMDocument")
                        Exit Sub                        
                  End If
                  
                  Set objFreeDOM =

Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
                  If err.number <> 0 Then
                        On Error GoTo 0
                        setError "MM_MISSING_OBJECT",

array("MSXML2.FreeThreadedDOMDocument")
                        Exit Sub                        
                  End If

                  Set objXSLTemplate = Server.CreateObject("MSXML2.XSLTemplate")
                  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("Scripting.FileSystemObject")
                  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("MSXML2.ServerXMLHTTP")
                  If err.number<>0 Then
                        On Error GoTo 0
                        setError "MM_MISSING_OBJECT",

array("MSXML2.ServerXMLHTTP")
                        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
                  CreateTransformationObjects()
                  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.createProcessor
                  
                  ' 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(errorCode_param), arrParams)
            End Sub
            
            Private Sub addError(errorCode_param, ByRef arrParams)
                  errorMsg = errorMsg & sprintf(errorMessages(errorCode_param),

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
%>
 
Loading Advertisement...
 
[+][-]09/25/07 01:15 PM, ID: 19958673Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Extensible Stylesheet Language Transformation (XSLT), Extensible Markup Language (XML)
Sign Up Now!
Solution Provided By: abel
Participating Experts: 1
Solution Grade: A
 
[+][-]09/24/07 12:02 PM, ID: 19950763Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/07 01:46 AM, ID: 19954166Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/07 04:05 AM, ID: 19954652Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/07 12:05 PM, ID: 19958152Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/07 12:58 PM, ID: 19958556Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/27/07 08:50 AM, ID: 19972237Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/27/07 08:56 AM, ID: 19972308Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/02/07 06:21 AM, ID: 19998299Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/02/07 10:13 AM, ID: 20000254Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 / EE_QW_1_20070628