By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

applying 2 xslt to an xml via script?

P: n/a
Hi All

I am completely new to this, but I was wondering if I can apply 2 xslt's
subsequently to an xml, via the (client side) scripting method:

http://www.w3schools.com/xsl/xsl_client.asp

Like maybe:

<html>
<body>

<script type="text/javascript">

// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("cdcatalog.xml")

// Load XSL ---- 1 ----
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cdcatalog.xsl")

// Transform ---- 1 ----
document.write(xml.transformNode(xsl))

// Load XSL ---- 2 -----
var xsl2 = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cdcatalog2.xsl")

// Transform ---- 2 -----
document.write(xml.transformNode(xsl2))

</script>

</body>
</html>

Thaks for letting me know some scripting hints if anyone came across similar
situation.

Toby
Sep 20 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

to*****@hotpop.com wrote:
I am completely new to this, but I was wondering if I can apply 2 xslt's
subsequently to an xml, via the (client side) scripting method:
[Explictly coded client-side JavaScript transforms via MSXML]
Yes, this is dead easy. Use two XSL documents and apply them one after
the other.

Remember to get the _results_ of the first transform as returned by the
..transformNode() method into a variable, rather than writing it back
directly. Then apply the second transform to _this_, not to your
original XML source.

Sep 21 '06 #2

P: n/a
Andy Dingley wrote:
to*****@hotpop.com wrote:

>>I am completely new to this, but I was wondering if I can apply 2 xslt's
subsequently to an xml, via the (client side) scripting method:
[Explictly coded client-side JavaScript transforms via MSXML]


Yes, this is dead easy. Use two XSL documents and apply them one after
the other.

Remember to get the _results_ of the first transform as returned by the
.transformNode() method into a variable, rather than writing it back
directly. Then apply the second transform to _this_, not to your
original XML source.
OK, I think I will be able to do this. However, from what I know, the script
would work only for MS IE and not for Firefox. Actually I think the entire
approach is useless, if it doesnt work for Firefox.
Sep 21 '06 #3

P: n/a

to*****@hotpop.com wrote:
However, from what I know, the script
would work only for MS IE and not for Firefox. Actually I think the entire
approach is useless, if it doesnt work for Firefox.
If you read the right tutorials (recent ones, probably mentioning AJAX)
then some slightly more sophisticated code will work on either.

It's not entirely web-portable, but it's usefully so.

Sep 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.