xsl-list
[Top] [All Lists]

Re: [xsl] MSXML DOCTYPE error

2008-06-24 07:10:01
Thanks Martin,

The fix worked perfectly.

For anyone interested the fix was to change...
--------------
xslFile = win32com.client.Dispatch("MSXML2.FreeThreadedDOMDocument")
if not xslFile.Load(xslFileName):
                raise ValueError("Failed to load file '%s'" % (xslFileName))
--------------

To:
--------------
xslFile = win32com.client.Dispatch("MSXML2.FreeThreadedDOMDocument")
xslFile.validateOnParse = False
if not xslFile.Load(xslFileName):
                raise ValueError("Failed to load file '%s'" % (xslFileName))
--------------

Thanks a lot!
Luke

2008/6/24 Martin Honnen <Martin(_dot_)Honnen(_at_)gmx(_dot_)de>:
Luke Stedman wrote:

When the dtd's are defined in the XSL file:

<!DOCTYPE xsl:stylesheet [
    <!ENTITY SYSTEM "./det_1.dtd">
    <!ENTITY SYSTEM "./det_2.dtd">
]>

The MSXML parser fails and gives the following error (The MSXML Parser
is being accessed via win32com):

File "C:\Python25\Lib\site-packages
\win32com\client\dynamic.py", line 538,
 in __setattr__ self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0,
value)
   pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
u'msxml3.dll', u'The stylesheet does not contain a document element.
The stylesheet may be empty, or it may not be a well-formed XML
document.\r\n', None, 0, -2147467259), None)

When I remove the DOCTYPE section the parser loads the XSL's fine but
error's when it comes across an unreferenced entity.

The DOMDocument of MSXML has a property validateOnParse which is true by
default so MSXML tries to validate against the DTD it encounters but as that
is not a complete DTD for your XSLT stylesheet the validation fails and the
DOMDocument for the stylesheet is not built.
So try to set
 stylesheetDoc.validateOnParse = false
(that is JScript syntax, you will have to transcribe to Python) on the
stylesheet DOM document, that should help I think.

--

       Martin Honnen
       http://JavaScript.FAQTs.com/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>