Click to See Complete Forum and Search --> : (XML + XSLT) -> into a <div> whithout javascript


perlmonk
07-11-2008, 03:58 AM
Hi All

Is it possible to do something like

<html>
<body>
....
<div ....>
<include xml-file>
</div>
....

So, I want to include the XML file (which defines a xslt) into an html page.
I have seen many examples of transforming XML files into complete pages but not how to create just a piece of a whole page!
Currently I use javascript to do what I want, but I prefer a solution without js

Thnx a lot
LuCa

bogocles
07-11-2008, 12:45 PM
Without using JS, the only thing I can think of is using XML data islands, which I'm pretty sure is something exclusive to Internet Explorer.

I'm also not sure if processing instructions are recognized inside of the data islands, so something like:

<?xml-stylesheet type="text/xsl" href="style.xsl"?>
might not even work.

Here's a quote from the first few lines of the w3schools insert on XMl data islands (actual link below):


What is it? An XML data island is XML data embedded into an HTML page.

Why avoid it? XML Data Islands only works with Internet Explorer browsers.

What to use instead? You should use JavaScript and XML DOM to parse and display XML in HTML.
http://www.w3schools.com/Xml/xml_dont.asp

Note, however, that JS does not actually have to do the parsing. Using JS to invoke XSLT fragments on XML fragments is also an option, assuming you haven't tried this yet. Consider the following link:

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

More advanced developers may have other ways to achieve fragment transformations without JS--and, I'm assuming, any other client-side scripting language. IMO, though, if you have frequent XML chunks embedded into your HTML, you might just be better off making your entire page XML (using the XHTML namespace and any custom namespaces for your fragments).

perlmonk
07-14-2008, 12:56 PM
thnx a lot. Now I know that I have to use javascript in order to populate my <div>s with xml data!