...

View Full Version : IE 7 Error - Works fine in FF | Javascript with XSL, XML



Papaphreaky
12-05-2006, 07:02 PM
This page will not display properly in IE7:
http://www.puzuki.com/nuzuki/motion_art/video_index.xml
This is the XSL file with the JavaScript:
http://www.puzuki.com/nuzuki/motion_art/motion_art.xsl

It works fine and dandy in FF. I just don't understand. I know it's a JS error, but I've spent HOURS trying to figure it out with no luck. Can anybody that is a little more advanced help me with this.

A1ien51
12-05-2006, 09:37 PM
Add semicolons after the brackets.

};function

Eric

david_kw
12-05-2006, 10:27 PM
I'm not sure why it works in FF. Typically you need

<![CDATA[ ... ]]>

Around reserved characters otherwise it escapes them and

if (i < 0) {

becomes

if (i &lt; 0) {

which has errors in compilation time.

I've never tried what you are doing where the js is created by xsl. Looks like it might be browser dependent though.

david_kw

david_kw
12-05-2006, 10:54 PM
It's not pretty but try this test out. It seems to work in FF2 and IE7. I have no idea if this example helps in your situation but it sure is interesting. :)

note: notice I didn't put the "if (" in CDATA and it worked anyway since it has no reserved characters.

js_create_test.xsl


<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Test JS from XSL</title>
<script type="text/javascript">
<![CDATA[
function doIt(s) {
var adiv = document.getElementById("adiv");
adiv.innerHTML = s;
}
function olderThan5() {
var s = "";
]]>

<xsl:for-each select="dogs/dog">
if ( <xsl:value-of select="@age" /> <![CDATA[ >= 5 ) {
s += "]]><xsl:value-of select="@name" /><![CDATA[ is at least 5<br>";
}]]>
</xsl:for-each>

<![CDATA[
doIt(s);
}
]]>
</script>
</head>
<body>
<button onclick="olderThan5()">Do it</button>
<div id="adiv"> </div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


js_create_test.xml


<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet href="js_create_test.xsl" type="text/xsl" ?>
<dogs>
<dog name="Spot" age="3" />
<dog name="Rover" age="5" />
<dog name="Fido" age="7" />
</dogs>


and in FF2 generates this code



<html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><title>Test JS from XSL</title><script type="text/javascript">

function doIt(s) {
var adiv = document.getElementById("adiv");
adiv.innerHTML = s;
}
function olderThan5() {
var s = "";



if ( 3 >= 5 ) {
s += "Spot is at least 5<br>";
}

if ( 5 >= 5 ) {
s += "Rover is at least 5<br>";
}

if ( 7 >= 5 ) {
s += "Fido is at least 5<br>";
}



doIt(s);
}

</script></head><body><button onclick="olderThan5()">Do it</button><div id="adiv">Rover is at least 5<br>Fido is at least 5<br></div></body></html>


david_kw

Papaphreaky
12-05-2006, 11:33 PM
I will try each of these suggestions in turn and get back to everybody. Thank you SOOOO much. I am an amateur programmer (art is my expertise) and I have NO idea what I'm doing. I'm surprised I got this far, honestly. Thanks!

Papaphreaky
12-05-2006, 11:55 PM
I am sorry to say this did not work, as it was the easiest solution. I did leave the semicolons after the brackets, as this seems good practice. Perhaps there is something else wrong?


Add semicolons after the brackets.

};function

Eric

Papaphreaky
12-06-2006, 12:15 AM
Unfortunately, this solution did not work for either FF or IE. Perhaps something else will work. I'm stumped.


It's not pretty but try this test out. It seems to work in FF2 and IE7. I have no idea if this example helps in your situation but it sure is interesting. :)

note: notice I didn't put the "if (" in CDATA and it worked anyway since it has no reserved characters.

js_create_test.xsl


<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Test JS from XSL</title>
<script type="text/javascript">
<![CDATA[
function doIt(s) {
var adiv = document.getElementById("adiv");
adiv.innerHTML = s;
}
function olderThan5() {
var s = "";
]]>

<xsl:for-each select="dogs/dog">
if ( <xsl:value-of select="@age" /> <![CDATA[ >= 5 ) {
s += "]]><xsl:value-of select="@name" /><![CDATA[ is at least 5<br>";
}]]>
</xsl:for-each>

<![CDATA[
doIt(s);
}
]]>
</script>
</head>
<body>
<button onclick="olderThan5()">Do it</button>
<div id="adiv"> </div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


js_create_test.xml


<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet href="js_create_test.xsl" type="text/xsl" ?>
<dogs>
<dog name="Spot" age="3" />
<dog name="Rover" age="5" />
<dog name="Fido" age="7" />
</dogs>


and in FF2 generates this code



<html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><title>Test JS from XSL</title><script type="text/javascript">

function doIt(s) {
var adiv = document.getElementById("adiv");
adiv.innerHTML = s;
}
function olderThan5() {
var s = "";



if ( 3 >= 5 ) {
s += "Spot is at least 5<br>";
}

if ( 5 >= 5 ) {
s += "Rover is at least 5<br>";
}

if ( 7 >= 5 ) {
s += "Fido is at least 5<br>";
}



doIt(s);
}

</script></head><body><button onclick="olderThan5()">Do it</button><div id="adiv">Rover is at least 5<br>Fido is at least 5<br></div></body></html>


david_kw

Papaphreaky
12-06-2006, 12:57 AM
Tried all these solutions and none of them worked. :(
I still need help with this. Thanks SO much in advance.

Basscyst
12-06-2006, 01:04 AM
I can view the page just fine in IE 7. What exactly is it that is not working.

Ehh, NM I see the js error.

It's be wise to update your examples with your attempts at resolving the issue. The problems mentioned thus far are still most likely what is causing it to break, so seeing how you went about implementing the suggestions given might clue someone in.

Basscyst

Papaphreaky
12-06-2006, 01:07 AM
Basscyst:

I cannot get the video to load as it does in FF. Does the video load for you?

***
---
NM - just read your NM. ;)

Papaphreaky
12-06-2006, 01:31 AM
Basscyst:

So I've posted the solutions used so far.

Solution #1:
Works fine in FF but not in IE
Adding semicolons after brackets:
http://www.puzuki.com/nuzuki/motion_art/video_index.xml

Solution #2:
Does not work for FF or IE
Adding CDATA tags
http://www.puzuki.com/nuzuki/motion_art/video_index-cdata_fix.xml

david_kw
12-06-2006, 07:44 AM
Weird. My tests suggest that this line is the culprit:

<html xmlns="http://www.w3.org/1999/xhtml">

Try changing that to:

<html>

I had to make a lot of changes to narrow it down. I'm still not totally clear why that would be a problem.

Plus I doubt this clears up all the problems. But it does appear to stop escaping the javascript code in IE this way. So hopefully it is a step in the right direction. :)

david_kw

Papaphreaky
12-06-2006, 08:08 AM
david_kw:

This didn't fix the problem that I could see, but it seems best practice to leave out the xmlns="http://www.w3.org/1999/xhtml". The page is still functional in FF, but not IE. :

http://www.puzuki.com/nuzuki/motion_art/video_index-no_xmlns.xml




Weird. My tests suggest that this line is the culprit:

<html xmlns="http://www.w3.org/1999/xhtml">

Try changing that to:

<html>

I had to make a lot of changes to narrow it down. I'm still not totally clear why that would be a problem.

Plus I doubt this clears up all the problems. But it does appear to stop escaping the javascript code in IE this way. So hopefully it is a step in the right direction. :)

david_kw

david_kw
12-06-2006, 04:54 PM
When I click on that link I see:

<html xmlns="http://www.w3.org/1999/xhtml">

and I don't see the CDATA. It looks like your original source again.

david_kw

Papaphreaky
12-06-2006, 05:03 PM
david_kw:

The correct page is up now. I must have done something in error. IE & FF are both displaying empty white boxes where there is supposed to be content. Now this seems like a step in the right direction.

http://www.puzuki.com/nuzuki/motion_art/video_index-no_xmlns.xml

http://www.puzuki.com/nuzuki/motion_art/motion_art-no_xmlns.xsl

david_kw
12-06-2006, 05:30 PM
You have some xsl commands in the CDATA



<xsl:for-each select="videos/video">

<xsl:sort data-type="text" order="descending" select="publishDate"/>
<![CDATA[
i++;
clipCategory[i]="<xsl:value-of select='category'/>";
clipSubcategory[i]="<xsl:value-of select='subcategory'/>";
clipTags[i]="<xsl:value-of select='tags'/>";
clipDownloads[i]="<xsl:value-of select='downloads'/>";
clipPublishDate[i]="<xsl:value-of select='publishDate'/>";
clipTitle[i]="<xsl:value-of select='title'/>";
clipPreview[i]="<xsl:value-of select='previewClip'/>";
]]>
</xsl:for-each>


That is the main problem at the moment. I actually think you don't need CDATA around this section since it doesn't have any > or < or & in it. I think quote and double quotes are ok when you aren't inside the tag.

So I recommend going through your code. Make sure the CDATA isn't around XSL commands and maybe even remove CDATA commands that aren't specifically necessary. Otherwise you are going to need tons of them.

david_kw

david_kw
12-06-2006, 05:40 PM
In fact, it looks like you only need CDATA around that last chunk of code that has if and for statements. The others don't use < > & symbols that I saw.

david_kw

Papaphreaky
12-06-2006, 06:23 PM
The problem appears to be fixed in IE :D , but no longer works in FF :confused: .

http://www.puzuki.com/nuzuki/motion_art/video_index-no_xmlns-mod.xml

http://www.puzuki.com/nuzuki/motion_art/motion_art-no_xmlns-mod.xsl

david_kw
12-06-2006, 06:46 PM
So the only two changes I've suggested (I think) are to remove the xmlns from the <html> tag and to add CDATA around that last chunk of code. Have you tried putting those back in to see if FF still works when that is undone?

david_kw

david_kw
12-06-2006, 06:54 PM
Or start with the one that still works in FF

http://www.puzuki.com/nuzuki/motion_art/video_index.xml
http://www.puzuki.com/nuzuki/motion_art/motion_art.xsl

duplicate them then make those two changes and see if it breaks FF.

david_kw

Papaphreaky
12-06-2006, 08:30 PM
Still breaks FF, but works in IE.

http://www.puzuki.com/nuzuki/motion_art/video_index-01.xml
http://www.puzuki.com/nuzuki/motion_art/motion_art-01.xsl

Papaphreaky
12-06-2006, 09:11 PM
Yes! This problem is solved -

http://www.puzuki.com/nuzuki/motion_art/video_index-02.xml

The ultimate solution to this problem was to remove the xmlns declaration from the html tage THEN extend CDATA around the last 4 functions in the javascript:



<![CDATA[
function advanceCarousel(advValue){
if((currentResultPage+advValue)>resultPages){
}else if((currentResultPage+advValue)<1){
}else{
clearClipSlots();
currentResultPage=currentResultPage+advValue;
loadPreviewClips();
};
};


function loadPreviewClips(){
if(clipPreview.length<=8){
for(i=1;i<clipPreview.length;i++){
loadClip('previewWindow0'+i,clipPreview[((currentResultPage*8)-8)+i]);
};
}else if((8+(clipPreview.length-(currentResultPage*8)))<8){
for(i=1;i<(8+(clipPreview.length-(currentResultPage*8)));i++){
loadClip('previewWindow0'+i,clipPreview[((currentResultPage*8)-8)+i]);
};
}else{
for(i=1;i<=8;i++){
loadClip('previewWindow0'+i,clipPreview[((currentResultPage*8)-8)+i]);
};
};
};

function clearClipSlots(){
for(i=1;i<=8;i++){
document.getElementById('previewWindow0'+i).innerHTML=' ';
};
};


function loadClip(clipSlot,clipLoc){
var clipBox=document.getElementById(clipSlot);
clipBox.innerHTML='<div class="videoPlacard"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab&#163;version=7,0,19,0" width="100" height="56"><param name="movie" value="'+clipLoc+'" /><param name="quality" value="high" /><embed src="'+clipLoc+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100" height="56"></embed></object></div>';
};
]]>


David_kw - thanks for all your help. I cannot express my gratitude enough in words.

There is a new strange thing happening in IE7. When clicking through the categories the "#" symbol begins to appear as the page Title for the explorer window. Why would that happen?

david_kw
12-06-2006, 10:57 PM
You are welcome. I'm glad it worked for you. I had thought about using xsl to create javascript but never done it. I learned a lot so thank you too. :)

david_kw



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum