Click to See Complete Forum and Search --> : XML parsing in Mozilla
FirEwAteR
01-27-2005, 01:46 PM
Hi, Im having some problems getting XML to display in Mozilla. For some reason I'll get it to display fine in IE but will not come through in mozilla. I'm also having problems linking the XML file remotely (on a different web server). Anyway, thanks for any help... Here's my XML document and below is my HTML.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE newsbox [
<!ELEMENT newsbox (news+)>
<!ELEMENT news (title,content,username,country,date)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT content (#PCDATA)>
<!ELEMENT username (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ATTLIST news id CDATA #REQUIRED>
]>
<newsbox>
<news id="12">
<title>sdfgsdfg</title>
<content>sdfgsdfgsd</content>
<username/>
<country/>
<date>2005-01-19 15:37:36</date>
</news>
<news id="14">
<title>asdfasdf</title>
<content>asdfasdfasdf</content>
<username/>
<country/>
<date>2005-01-19 15:40:04</date>
</news>
<news id="13">
<title>test</title>
<content>test</content>
<username/>
<country/>
<date>2005-01-19 15:39:28</date>
</news>
<news id="15">
<title>test</title>
<content>test</content>
<username/>
<country/>
<date>1106170888</date>
</news>
</newsbox>
HTML:
<xml id="newsData" src="testing.xml"></xml> <!-- calls for external XML file -->
<table border="0" datasrc="#newsData">
<tr>
<td><span datasrc="#newsData" datafld="TITLE"> </span></td>
<td><span datasrc="#newsData" datafld="CONTENT"> </span></td>
</tr>
</table>
*EDIT* I would also like to point out that when going to the w3c "try it yourself" XML section I cannot get them to work in firefox either, thx for any help, again.
Khalid Ali
01-28-2005, 09:06 PM
Originally posted by FirEwAteR
HTML:
<xml id="newsData" src="testing.xml"></xml> <!-- calls for external XML file -->
<table border="0" datasrc="#newsData">
<tr>
<td><span datasrc="#newsData" datafld="TITLE"> </span></td>
<td><span datasrc="#newsData" datafld="CONTENT"> </span></td>
</tr>
</table>
all of the above is IE specific code and will not work in any mozilla based or any other w3c standards based browser.
Use XSL/XSLT to display your XML in browser
FirEwAteR
01-31-2005, 01:45 PM
Ok, I have the XSL set up how I want it and now I just want to know how to include it into a HTML file. Thx for any help, this is my first XML experience :S
Charles
01-31-2005, 01:51 PM
Originally posted by Khalid Ali
Use XSL/XSLT to display your XML in browser Note, however, that the proper way to include XML from some other file is by creating an external entity. Firefox does not support this essential feature of XML.
Khalid Ali
02-01-2005, 11:32 PM
Care to elaborate a bit more Charles?
Charles
02-02-2005, 05:43 AM
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [
<!ENTITY menu SYSTEM 'http://www.saintjohns.ang-md.org/menu.html'>
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
</head>
<body>
<h3>Test</h3>
&menu;
</body>
</html>
Khalid Ali
02-02-2005, 08:58 AM
Thats interesting, that means the way an external entity is used in an XML file browsers are importing xml files like that?(to be honest I did not know that).
Now which browsers do support this import mechanism? would you know
Thanks
Charles
02-02-2005, 11:20 AM
Sadly, MSIE is the only browser that I know of that gets XML correct. You might try Amaya, though.
Khalid Ali
02-02-2005, 06:12 PM
Originally posted by Charles
<h3>Test</h3>
&menu;
Lets see, the above statement means that in a DTD an entity was defeined and &menu will place what this entity stood for.
Just wondering with this statement it should display all of the xml in the page which may not be the intent, because you want the XML to be in memory as an object so that you can work on it or you want the xml file to be displayed as described in the XSL file.
Feel free to fill me in where I messed up in here
Charles
02-02-2005, 06:47 PM
There's nothing special about entities. They're the same in XML as they are in SGML. It's just that browsers never got around to half of the SGML rules.
When you use "&trade" you are using an entity. If you look at the XHTML 1.0™ DTD you will find:
<!ENTITY trade "&#8482;">
It simply means that "&trade;" will be replaced with "&#8482;" when the document is first parsed. Now, the DTD can be in a separate document, or in the DOCTYPE tag or a combination of the two. And you can define an entity to be the contents of some external file.
In the example above, the external entity should be resolved as a part of the initial parsing. That which is substituted goes through the parser also and can also contain entities.
Khalid Ali
02-02-2005, 09:21 PM
Originally posted by Charles
There's nothing special about entities. They're the same in XML as they are in SGML. It's just that browsers never got around to half of the SGML rules.
When you use "&trade" you are using an entity. If you look at the XHTML 1.0™ DTD you will find:
<!ENTITY trade "&#8482;">
It simply means that "&trade;" will be replaced with "&#8482;" when the document is first parsed. Now, the DTD can be in a separate document, or in the DOCTYPE tag or a combination of the two. And you can define an entity to be the contents of some external file.
In the example above, the external entity should be resolved as a part of the initial parsing. That which is substituted goes through the parser also and can also contain entities.
Thats almost exactly what I stated in my post above, anyways...thanks for a constructive discussion.
Charles
02-03-2005, 05:51 AM
Originally posted by Khalid Ali
Thats almost exactly what I stated in my post above, anyways...thanks for a constructive discussion. Forgive me. I wasn't clear about just what you were asking in that post.
FirEwAteR
02-07-2005, 05:14 PM
Okay, well all I need is the code that will turn my xsl file into an html file. I have tried a couple of different javascript options but none of the ones I've found have worked in both mozilla and IE. So if anyone could let me know the code I need that'd be awesome. Thanks.
Khalid Ali
02-07-2005, 06:34 PM
XSL file itself is for turning an xml file to whatever you want(html in your case)
FirEwAteR
02-07-2005, 07:50 PM
I would like to embed the xsl into an html file, and I cannot figure out how.
Charles
02-08-2005, 05:39 AM
Originally posted by FirEwAteR
I would like to embed the xsl into an html file, and I cannot figure out how. Just use two files and call the stylesheet. Your prolog should look like:
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="calendar.html.xsl"?>
FirEwAteR
02-09-2005, 06:03 PM
I do have those in my html file but it will not display the xml.
Khalid Ali
02-09-2005, 06:15 PM
It seem slike we are back at square one after all these posts.
take a look at this link (http://www.webapplikations.com/pages/html_js/xmlstuff/cdcatalogNS.xml) and see if this is what you want.
if so look into the source and get the xsl file and see how its being done.