Discussion:
Strange MSXML4 behaviour
(too old to reply)
Mark Thompson
2006-04-08 10:45:08 UTC
Permalink
Hoping somebody can point me in the right direction with this problem
that is driving me nuts.

I'm using javascript to transform a range of different xml data files
using different xslt files. All the transforms work in xmlspy. I'm using
Sarissa and all the transforms work on Firefox, but get to IE6 and a
couple don't emit anything.

I can't figure out the common element behind the ones that don't work
except perhaps multiple nested apply-templates and more complex xml
files but can't believe there are those sort of restrictions to msxml4.
Though I changed this to for-each in one template and it still didn't do
anything.

I have no idea where to go from here.
Martin Honnen
2006-04-08 11:32:19 UTC
Permalink
Post by Mark Thompson
I can't figure out the common element behind the ones that don't work
except perhaps multiple nested apply-templates and more complex xml
files but can't believe there are those sort of restrictions to msxml4.
Though I changed this to for-each in one template and it still didn't do
anything.
I have no idea where to go from here.
Well try to reduce one of the problematic XML files and of the
stylesheets to a minimum and then post the URLs so we can check that
out. Does Sarissa use MSXML 4 at all? I would rather check the files
with some lines of JScript or VBScript running MSXML 4 explictly or
simply try the transformation with the msxsl tool you can get here:
<http://msdn.microsoft.com/XML/XMLDownloads/default.aspx>
Then you know whether it is an MSXML 4 problem.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mark Thompson
2006-04-08 14:36:13 UTC
Permalink
Post by Martin Honnen
Post by Mark Thompson
I can't figure out the common element behind the ones that don't work
except perhaps multiple nested apply-templates and more complex xml
files but can't believe there are those sort of restrictions to
msxml4. Though I changed this to for-each in one template and it still
didn't do anything.
I have no idea where to go from here.
Well try to reduce one of the problematic XML files and of the
stylesheets to a minimum and then post the URLs so we can check that
out. Does Sarissa use MSXML 4 at all? I would rather check the files
with some lines of JScript or VBScript running MSXML 4 explictly or
<http://msdn.microsoft.com/XML/XMLDownloads/default.aspx>
Then you know whether it is an MSXML 4 problem.
Thanks for the reply Martin.

Internally Sarissa registers which browser is in use and then which XML
components are available and invokes the most recent (in this case
msxml4). Even so I had tried invoking the activexobject directly using
code I found here on this newsgroup, and got the same result.

I've tried that msxsl application and it works fine. Thinking my browser
was messed up I have tried from another XP machine with the same results.

I've put two versions up on my webserver - one with the for each, and
the original xslt with the apply-templates.

http://pafl.game-server.cc/data/league5/test/WebSite1/test8.htm

http://pafl.game-server.cc/data/league5/test/WebSite1/test9.htm

Any help would be appreciated.
Martin Honnen
2006-04-09 11:56:12 UTC
Permalink
Post by Mark Thompson
I've tried that msxsl application and it works fine. Thinking my browser
was messed up I have tried from another XP machine with the same results.
I've put two versions up on my webserver - one with the for each, and
the original xslt with the apply-templates.
http://pafl.game-server.cc/data/league5/test/WebSite1/test8.htm
http://pafl.game-server.cc/data/league5/test/WebSite1/test9.htm
Any help would be appreciated.
The problem in the example is that you use transformNodeToObject which
tries to create an XML result document but your main template
<http://pafl.game-server.cc/data/league5/test/WebSite1/xslt/test2.xsl>
creates two root elements
<TABLE>...</TABLE>
<I>...</I>
That is not allowed with XML. So if you want to use
transformNodeToObject then you need to make sure that your templates
create exactly one root element e.g. in you example doing
<DIV>
<TABLE>...</TABLE>
<I>...</I>
</DIV>
is one way.

On the other hand if you want to have HTML snippets as the
transformation results then using transformNode simply gives you a
string which you can then insert somewhere with the IE HTML DOM e.g.
someDiv.innerHTML = xmlDocument.transformNode(xslDocument);
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mark Thompson
2006-04-09 12:34:04 UTC
Permalink
Post by Martin Honnen
The problem in the example is that you use transformNodeToObject which
tries to create an XML result document but your main template
<http://pafl.game-server.cc/data/league5/test/WebSite1/xslt/test2.xsl>
creates two root elements
<TABLE>...</TABLE>
<I>...</I>
That is not allowed with XML. So if you want to use
transformNodeToObject then you need to make sure that your templates
create exactly one root element e.g. in you example doing
<DIV>
<TABLE>...</TABLE>
<I>...</I>
</DIV>
is one way.
On the other hand if you want to have HTML snippets as the
transformation results then using transformNode simply gives you a
string which you can then insert somewhere with the IE HTML DOM e.g.
someDiv.innerHTML = xmlDocument.transformNode(xslDocument);
Thank you so much Martin. Moved that element into the table itself and
all is working now.

That would never have occurred to me as the root of the problem (ahem).
Shouldn't that have raised a parsing error somewhere in the transform
process seeing as it was invalid?
Martin Honnen
2006-04-09 12:44:06 UTC
Permalink
Post by Mark Thompson
Shouldn't that have raised a parsing error somewhere in the transform
process seeing as it was invalid?
It does, if you checked
resultDocument.parseError.errorCode/reason
etc. (where resultDocument is the document you passed in as the second
parameter to transformNodeToObject) then I am sure it shows you the error.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mark Thompson
2006-04-09 13:06:18 UTC
Permalink
Post by Martin Honnen
Post by Mark Thompson
Shouldn't that have raised a parsing error somewhere in the transform
process seeing as it was invalid?
It does, if you checked
resultDocument.parseError.errorCode/reason
etc. (where resultDocument is the document you passed in as the second
parameter to transformNodeToObject) then I am sure it shows you the error.
So it is. In plain english too. I should have seen that. Thanks again.
Loading...