XML/XSL embedded in HTML

XML/XSL embedded in HTML

Post by Maziar Aflatou » Mon, 16 Dec 2002 16:03:25



Hi everyone,

I have an XML file that displays a set of data using a XSL file.  Is there a
way to include this XML file in my HTML file.

So for example,

I have the following file
data.xml which calls my <?xml-stylesheet type="text/xsl" href="my.xsl"?>
file to display data

Now I have an HTML with multiple tables and in one the tables I like to
include my XML file.

Does anyone know how? (without converting my HTML file to XSL)

Thank you
Maziar A.

 
 
 

XML/XSL embedded in HTML

Post by e mc » Mon, 16 Dec 2002 22:04:04


Here are some ideas for doing it (there are probably other solutions,
maybe better than mine) :
1- include your html data (after converting it it xhtml) in data.xml and
modify the xsl template to output everything.
2- use php on the server to generate the contents of the table from the
XML + XSL. (you can probably do it with asp too)
3- use microsoft data islands (see documentation below). But beware, it
only works with Internet explorer 5.0 or mmore. I took the documentation
a bout data islands from the MDAC SDK (Microsoft data acess components
SDK) download it from microsoft.com, it contatins tons of info about
XML, XSL, XPath, DOM, etc...

Data island documentation from the MDAC SDK:

XML Data Islands
There is an increasing need to be able to embed "islands" of data inside
HTML pages. In Microsoft? Internet Explorer 5.0 and later, these data
islands can be written in XML.

The following topics describe the syntax used for embedding these data
islands within a page, and detail the object model exposed by the
browser to enable them to be used. This method of embedding XML in HTML
follows the note published by the World Wide Web Consortium (W3C) as the
"XML in HTML Meeting Report." The W3C expects to evolve the HTML
specification to include the capability of embedding XML in HTML
documents.

Embedding an XML Data Island into an HTML Page
An XML data island can be embedded using one of the following methods.

Using the Dynamic HTML (DHTML) <XML> element within the HTML document
Overloading the HTML <SCRIPT> element
Using the XML Element Within the HTML Document
This syntax is valid for Internet Explorer 5.0.

There are two syntactically correct ways of using the <XML> element
within the HTML document.

The XML data can exist inline, surrounded by <XML></XML> start and end
tags.
<XML ID="XMLID">
  <XMLDATA>
    <DATA>TEXT</DATA>
  </XMLDATA>
</XML>
The <XML> element can have a SRC attribute, the value of which is the
URL for an XML data source.
<XML SRC="http://localhost/xmlFile.xml"></XML>
The <XML> element is present in the HTML Document Object Model. It is in
the DHTML all collection and is seen by the browser as just a regular
node. The XML data within the <XML> element can then be accessed by
calling the DHTML XMLDocument property on the <XML> element.

The XMLDocument property returns the root node of the XML within the
<XML> element or the root node of the XML referenced by the value of the
SRC attribute. From this root, the XML data island can be navigated
using the XML Document Object Model (DOM). The following function
returns the data from the data island with the ID of "XMLID".

function returnXMLData(){
  return document.all("XMLID").XMLDocument.nodeValue;
  }
The <XML> element can also be referenced by ID alone. For example, the
following function has the identical functionality as the preceding
example.

function returnXMLData(){
  return XMLID.documentElement.text;
  }
Because the XMLDocument property was not used, the documentElement
property must be called to retrieve the root element of the XML.

Overloading the HTML <SCRIPT> Element
This syntax has been deprecated and is intended only for down-level
cases.

There are three syntactically correct ways of overloading the HTML
<SCRIPT> element.

The LANGUAGE attribute can be given the value "XML".
<SCRIPT LANGUAGE="XML">
The TYPE attribute can be given the value "text/xml".
<SCRIPT TYPE="text/xml">
As with the <XML> element, a SRC attribute can be added, the value of
which is the URL for an XML data source.
<SCRIPT LANGUAGE="XML" SRC="http://localhost/xmlFile.xml"></SCRIPT>
The following HTML fragment illustrates how to embed data by overloading
the <SCRIPT> element.

<SCRIPT ID="XMLID" LANGUAGE="XML">
  <XMLDATA>
    <DATA>TEXT</DATA>
  </XMLDATA>
</SCRIPT>
The <SCRIPT> element is present in the HTML page's object model. (It is
in the DHTML all collection and is seen by the browser as a regular
script node.) The XML data within the <SCRIPT> elements can be accessed
by calling the XMLDocument property on the <SCRIPT> object.

The following script accesses the XML data island in the preceding HTML
fragment, and returns the name of the root node of the XML data island.

function returnIslandRootName(){
  var islandRoot = document.all.("SCRIPT").XMLDocument;
  return islandRoot.nodeName;
  }
Note   A tag that uses the name "XML" cannot be nested within an XML
data island.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

1. Embedding HTML in a XML ; XML --> XSL --> HTML

is it possible to post a small working example (xml + xsl) with the complete
solution?

and how to store a "&nbsp;" in the HTML(XHTML)-data section of the xml-file?

For example:

<HTML_DATA><P>This is some text with &nbsp;space &nbsp;.</P></HTML_DATA>

Should come out as this:
<P>This is some text with &nbsp;space &nbsp;.</P>

Thanks in advance!
Bodo

2. Change Identitiies in outlook express

3. How can I embed HTML tags in XML and present them in XSL?

4. Crashed Partition Table | HEEEELP!!

5. is HTML embedded in XML in XSL impossible?

6. Raw IP on Windows 95 and NT

7. Embedding XML on an HTML Page when using XSL ...

8. Generating Plots for Random Data

9. XSL with XML Embedded in HTML

10. Q: How do I embed not well-formed HTML in XSL

11. XSL query - formatting HTML tags embedded in element text

12. how to embed xsl tag within an html tag

13. Embedding XSL statement in an HTML tag Attribute