|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello. I've been playing around with XSLT and javascript for a couple weeks now and I am looking for anyone's expertise about a little 'issue' I'm having.
I'm trying to load xml documents into a static html page to create a 'frame' effect. Everything I've hashed out so far has worked pretty stabily until my most daring attempt -- load a javascript function to manipulate the page after an XSL transformation. I've got my main static html file: sample.htm, an xml data file: LAB.xml and a stylesheet: mod.xsl A snippet of the xsl file follows: PHP Code:
I process the XML/XSLT with IE's XML processor or Mozilla's XSLT processor depending on the browser I'm viewing the page in. The XSL files generate HTML chunks, not full HTML files. For example, after a transformation, I'll have something like: PHP Code:
In the example above, I have a couple <script> tags which are to load and subsequently call a javascript function. In Mozilla, the function is properly called and life is good. In IE, this is not the case. I've got 2 questions: 1) Is this bad practice to plop a function to run embeded in an element? I tried to add an event to call the function (a much nice approach, granted), but it wasn't working -- because the appending of the transformed elements to the body do not seem to trigger any events I can find. 2) Does anyone know when IE processes scripts? Is it only on a load of a page? This would explain the issue to me. Any insights? I appreciate it! P.S. While working on this, I realized it would probably be helpful to offer the code I'm using for the transformations. For the IE one, it looks like: PHP Code:
You will note that I am merely replacing the innerHTML with the string that is returned from xml.transformNode(). For the Mozilla implementation, the transform results in a DOM fragment of the HTML elements, so I call elem.appendChild(node); which I feel is better than replacing innerHTML. I can't seem to get the other transform methods to work with IE, though. Again, any insight would be appreciated. Thanks!! Last edited by rguilbault : August 18th, 2004 at 03:01 PM. Reason: Additional Info |
|
#2
|
||||
|
||||
|
Would you be able to provide links/samples of the xml and html as well? I work best when I have enough info to simulate your problem-then it's easier to pinpoint the problem. Thx.
|
|
#3
|
||||
|
||||
|
Okay, first thanks for the additional info-I see you were thinking/acting upon it even as I was reading/posting
![]() It's not quite enough [for me] to build a working testcase, but I've a suggestion. -Try adding a simple button/link 'onclick' to manually test your script in each browser to see if it is indeed working. That will help define where the problem lies. -Try wrapping the script call in CDATA tags: <![CDATA[ ScrollTable_initialize(); ]]> -Try using a pure xsl/xml translation and see if that has a different effect. -Use sablotron (or other translator) to turn the files into straight html (xml data included) and actually look to see if maybe something is parsing oddly. I don't know the answer to 2, and for 1, well sometimes it's the only way I can get things to work (moymmv) |
|
#4
|
|||
|
|||
|
files...
Here's the thing, see...I'm working with all of this stuff locally. I don't have a web server to stick the files (how lame, I know).
I'm going to try to attach a .zip file. Ironically, I came across an issue you were/are having with Mozilla 'crashing' when displaying your Calendar and I've come up with a way to display the info using a similar method to what I'm trying to work with here...I'll update your post shortly... THanks. as always, I forgot to mention something important: when you load up sample.htm, click the link and you will see an 'account summary' deal with a select box with LAB and MIC as the options. you need to click to MIC then back to LAB (I'm an idiot and there are no instruments for MIC) and you should see a table at the bottom of the screen...this table should be sortable by clicking the headers (all but the first column) -- in Mozilla, it seems to work...in IE, I got nothing! Last edited by rguilbault : August 18th, 2004 at 04:42 PM. Reason: I'm a dolt |
|
#5
|
||||
|
||||
|
Quote:
It's not lame. I deal with client-side only problems as well. I use sablotron's command-line program sabcmd.exe manually to translate the pages (ie: sabcmd file.xsl file.xml newfile.html), then upload the [static] html when browser conflicts arise. Eventually I'll use a perl/php wrapper and do it the fancy way ![]() Quote:
*woo!* Thank you I've ended up using sablotron to convert to html, but then have another issue with xsl:sort to deal with I'd love a fix/mod to the original idea. |
|
#6
|
|||
|
|||
|
I've never used sablotron...I'll have to look it up. Thanks!
|
|
#7
|
||||
|
||||
|
No luck yet
I have a forced break (aka commuting time) and I'll take another stab at it tonight. With luck you'll get someone to answer in the meantime. |
|
#8
|
||||
|
||||
|
Late return, so little time to debug, but I did notice (which I assume you already know) that if you type in the url with the params it works fine (or seems to) in IE6.
e.g. sample2.htm?dir=1940&xml=acct.xml&xsl=acct.xsl You have default xml/xsl of aParams["xml"] = "baseball.xml"; aParams["xsl"] = "exampleDoc.xsl"; When I changed those to files which were present (acct.xml/acct.xsl) and loaded the page w/o the params, it worked fine in IE6-it loaded the base 'choose module' set. I did encounter a problem with FireFox, however. It loaded the base 'choose' just fine, but when you selected MIC/LAB that section loaded, but the entire area was pushed down to the bottom of the page. Hope that helped. |
|
#9
|
|||||
|
|||||
|
Quote:
It's actually IE that it's not working in ;-( Quote:
Yeah, sorry about that! I have a tendency to work bottom-up and I had a whole bunch of other files for other purpose testing that weren't necessary to upload...I should have made that change though. Quote:
I think what you're describing is the way it is intended to work. I just installed Firefox and tested it and it works the way I want (as it did in Mozilla)... It's kinda convoluted, but here's sorta my goal (now that you've seen the pages it might make a little more sense): 1) The original page is loaded, the last thing on the page is "Choose Module". 2) Select MIC (thus invoking the onchange/change event with a javascript function attached). The content should have a header "Module:", should show a Specialists, Programmers and Dates box. At this point, all is well and good in each browser I've tested in. 3) At this point, you have to select LAB to load the content that breaks my page. At the bottom of the page you should see a section "Instruments" with a table 6 rows. It looks a little funny, but that's because it's supposed to be a scrollable table. Alas, the problem is that when you click the Instrument column, the rows should sort in alpabetic order. In Mozilla and Firefox, this is working (for me at least). I'm using version 0.9.2 Firefox and 1.7.1. Now, in IE, however, the table is not sortable -- hell, the ScrollTable_initialize() function is never even called (as I placed alerts and such in there that never execute -- I don't even give me an error). I think the issue lies in the XSLProcessor transform method (of my user-defined class) -- you'll noticed that for Mozilla's implementation (the else-if condition), I append a node structure to the container element, whereas for the IE implementation, I merely set the container's innerHTML property to the string returned by IE's transforming function. I have scoured MSDN to find other methods of transforming XML through javascript, but I can't find any that I can get to work. I think that assigning the string only prevents the function within the <script> tags from getting called. I'm not sure though. What do you think the likelyhood of IE adopting the Gecko engine is? ![]() |
|
#10
|
|||
|
|||
|
Aha!
http://msdn.microsoft.com/library/d...fxsltanddom.asp
It looks like I am doing things exactly as I need to for IE to be happy...now the question is: why the hell isn't my script running!? ;-) |
|
#11
|
||||
|
||||
|
By 'it works in IE' I meant, if you loaded the page passing the params (like the 'click me' link does) the page worked-the initial module loaded, and selecting LAB or MIC created a scrolltable beneath it. Changing the defaults to use those same params (acct.xml and .xsl) then reloading w/o the ?... search text also worked-the inital module loaded, you could select LAB or MIC and the scrolltable appeared.
However I attempt this on IE6 at work and it's broken The initial module will load but selecting LAB or MIC does nothing. I -did- tweak some lines last night, however I don't remember what...I'll attempt to recreate it here, else consult the files when I get home.In regards to FireFox- when I said 'pushed down' I meant just that. The initial module, which at first loads flush with the 'text manipulations' green header is 'pushed down' when LAB or MIC is selected so you have to vertically scroll the (entire) window down to see anything but the upper edge. This might be a result of my forgotten tweaking, however, if you don't see that. I'll post a screenshot when I get home. |