473,414 Members | 1,643 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

client side xslt transformation in Firefox

Hi all,

anyone has a live example of loading an xml file from a server, an xslt
file from the server, then transforming the xml using the xslt and
outputing the results (preferably with appendChild)?

I'm trying to write a function to do just that (given url to xml, url
to xslt and elementid). Works a charm on IE. Can't get it to work with
Firefox.

Thanks in advance,
R. Green

Dec 26 '06 #1
7 7847
Zzzbla wrote:
anyone has a live example of loading an xml file from a server, an xslt
file from the server, then transforming the xml using the xslt and
outputing the results (preferably with appendChild)?
Here is an example
<http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122601.html>
tested with Mozilla, Opera 9, IE 6.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 26 '06 #2
Thank you Martin!!!
Martin Honnen wrote:
Zzzbla wrote:
anyone has a live example of loading an xml file from a server, an xslt
file from the server, then transforming the xml using the xslt and
outputing the results (preferably with appendChild)?

Here is an example
<http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122601.html>
tested with Mozilla, Opera 9, IE 6.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 26 '06 #3
Martin Honnen <ma*******@yahoo.dewrote:
Here is an example
<http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122601.html>
tested with Mozilla, Opera 9, IE 6.
Fine thanks !

this example works also on Mac OS X 10.4.8 with :

WebKit (latest nightly)
Firefox 2.0.x
Flock 0.7.8
Opera 9.10
Camino 1.1a1+

don't work with :
Safari 2.0.4
Shiira 2.0b1
SunRiseBrowser 0.895 (latest)
TrailBlazer 0.5
may be that's only a question of javascript core version ???

how to get that version number ?
--
Père Noël
Dec 26 '06 #4
VK

Zzzbla wrote:
anyone has a live example of loading an xml file from a server, an xslt
file from the server, then transforming the xml using the xslt and
outputing the results (preferably with appendChild)?

I'm trying to write a function to do just that (given url to xml, url
to xslt and elementid). Works a charm on IE. Can't get it to work with
Firefox.
(One more sample besides the one by Martin Honnen)

Full sample at <http://jsnet.sourceforge.net/tmp/xslt/dxslt.html>

That may be confusing because MSXML and Gecko are using different
patterns.

In MSXML you
1) obtaining XML data
2) obtaining XSL template
3) applying XSL template onto XML data; this automatically invokes
XSLT processor

// 1
var xml = new ActiveXObject('Microsoft.XMLDOM');
xml.async = false;
xml.load('demo.xml');
// 2
var xsl = new ActiveXObject('Microsoft.XMLDOM');
xsl.async = false;
xsl.load('demo.xsl');
// 3
document.body.
insertAdjacentHTML('beforeEnd',
xml.transformNode(xsl));

In Gecko you
1) creating an instance of XSLT processor
2) loading XML data to be processed
3) loading XSL template to be used
4) "charging" the processor with XSL template
5) passing XML data through the processor.

// 1
var XSLT = new XSLTProcessor;

// 2
var $xml = new XMLHttpRequest;
$xml.open('GET', 'demo.xml', false);
$xml.overrideMimeType('text/xml');
$xml.send(null);
var xml = $xml.responseXML;

// 3
var $xsl = new XMLHttpRequest;
$xsl.open('GET', 'demo.xsl', false);
$xsl.overrideMimeType('text/xml');
$xsl.send(null);
var xsl = $xsl.responseXML;

// 4
XSLT.importStylesheet(xsl);

// 5
document.body.
appendChild(XSLT.transformToFragment(xml, document));

Full sample at <http://jsnet.sourceforge.net/tmp/xslt/dxslt.html>

P.S. I wanted to reference a MDC source first - this raised again my
suspicion that there is some kind of sabotage by anonymous Wiki
editors. Way too many - IMHO - articles are not just not full or
erroneous. Not just that: they are rather sophistically written with a
lot of convincing code samples but with a few key errors or omissions
well hidden here and there.
<http://developer.mozilla.org/en/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Tran sformations>
is very demonstrative in this aspect.
That can a winter paranoia from my side of course.

Dec 26 '06 #5
VK <sc**********@yahoo.comwrote:
>
(One more sample besides the one by Martin Honnen)
have used the way of Martin to build a menu, here :

<www.yvon-thoraval.com/Canvas/menu.html>

a screenshot of it :

<www.yvon-thoraval.com/Canvas/menu.png>

it works with Opera 9.1 and Firefox 2 but not with WebKit (latest
nightly).

WebKit is able to work with the example of martin i've reproduced here :

<www.yvon-thoraval.com/JS/xslt>

i think for the menu case the prob comes from my xsl sheet :

<xsl:variable name="href"><xsl:value-of select="link"/></xsl:variable>
<li class="local"><a
href="javasript:setPage(&quot;{$href}&quot;);"><xs l:value-of
select="label"/></a></li>

--
Père Noël
Dec 26 '06 #6
VK

Père Noël wrote:
href="javasript:setPage(&quot;{$href}&quot;);"
OT to XSLT, but should be "javascript" - unless a typo in the post.

Also if you are not resolving entities, in HTML it will be as it is
href="javascript:setPage(&quot;URL&quot;);"
which is not a valid JavaScript call.

if you are resolving entities, then in HTML it will be
href="javasript:setPage("URL");"
with nested quotes and UA going nuts.

If entities are resolved on parsing then should be:
href="javasript:setPage(&apos;{$href}&apos;);"

Dec 26 '06 #7
VK <sc**********@yahoo.comwrote:
OT to XSLT, but should be "javascript" - unless a typo in the post.
that was a typo of me ))
if you are resolving entities, then in HTML it will be
href="javasript:setPage("URL");"
with nested quotes and UA going nuts.
i get that output in HTML : verified by DOM Inspector and Firefox.

--
Père Noël
Dec 27 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
6
by: Ben Fitzgerald | last post by:
Hi I feel I'll be asking for someone to turn water into wine before this happens, but just in case! I'd like to have a page that provides a basic xml document with an xslt that defines the...
7
by: RC | last post by:
First, let me say I couldn't find a group discuss XML/XSLT. So I only choose the closest groups to post this message. Here is part of my *.xsl file <xsl:stylesheet...
14
by: David Blickstein | last post by:
I have some XML documents that I want to open in a web browser and be automatically translated to HTML via XSLT. I'm using an xml-stylesheet processing command in a file called "girml.xml". ...
5
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an...
3
by: Simon Brooke | last post by:
I've been doing XSL transforms, converting XML to HTML, server side since 2000. In those days, clients which could do the transformation client side didn't exist, so whether to transform...
7
by: pstachy | last post by:
Hi all, I'm having problem with XSLT transformation concerned with sort and numberings at a time. I wish to have my registries sorted alfabetically and would like them to have numberings at a...
7
by: C.W.Holeman II | last post by:
For info on the context of my question see the end of this posting. From http://www.w3.org/TR/XHTMLplusMathMLplusSVG/: How can I validate the result of client-side XSLT transform which has...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.