Subject: Data Island vs. XSL?
Posted By: hbcontract Post Date: 10/30/2003 2:02:12 PM
I am having problem displaying data using Data Island ... When the user first enter data and the XML file is first craeted, it will display the data. But if the XML file already existed and user enter data to update the XML file, data island seem can't get all the data and display in html form. However, that works fine in XSL. I am not sure why ... Data island suppose to get data from the generated XML file and display the data ... :( Reason I hope to use Data Island is because I really just want to display it only, and not have any fancy layout, so I try to avoid using XSL. To my understanding, Data Island and XSL are same to display data ... I hope I am right.

In my form (profile.html, it will generate XML file in process.asp, then redirect to profile.html). I assume that I have to "reload" the window everytime I visit profile.html, but it doens't work either.


Display data using Data Island (not working)
=============================================
<xml id="name" src="name.xml"></xml>

<table border="0" datasrc="#name">
<tr>
<td><td><span datafld="Name"></span></td></td>
</tr>
</table>
=============================================

Display data using XSL (works prefectly)
=========================================

  <XML id="source" src="name.xml"></XML>
    <XML id="style" src="name.xsl"></XML>
  
    <SCRIPT FOR="window" EVENT="onload">
        xslTarget2.innerHTML = source.transformNode(style.XMLDocument);
    </SCRIPT>
 <DIV id="xslTarget2"></DIV>

=========================================

Reply By: joefawcett Reply Date: 10/31/2003 4:46:57 AM
Sounds like the data may be cached on the client. Try ctrl+F5 as a manual test after an update, if this works then you need to stop caching. There are not any guaranteed ways to do this in HTML pages but it's easier with dynamic pages such as ASP. One trick is to use a different url each time. When you redirect to profile.html how do you do it? If using Response.Redirect try:


Response.Redirect"profile.html?" & Rnd()


--

Joe
Reply By: hbcontract Reply Date: 11/4/2003 12:01:48 PM
Hi Joe, it doesn't work either I redirect and produce diff URL (&Rnd) or press the ctrl f5 ... :( I really not sure why it doesn't work like that. If I put a simple example and it just works well. But not in my application while it generate xml file in ASP page and redirect to display all the data from the generated xml file :(

Reply By: joefawcett Reply Date: 11/5/2003 12:56:18 PM
Show us the code when you use data island, are you saving the changes?

--

Joe
Reply By: hbcontract Reply Date: 11/5/2003 6:54:36 PM
My code is very straight forward ... here is the code:
=========================================================
<html>
<body>

<xml id="data" src="name.xml"></xml>

<table border="1" datasrc="#data">
<tr>
<td><span datafld="Name"></span></td>
<td><span datafld="Phone"></span></td>
</tr>
</table>

</body>
</html>

=========================================
My XML file:
=========================================
<?xml version="1.0"?>
<Data>
  <Each_Person>
      <Name>Professor Mike</Name>
      <Phone>905-992-0293</Phone>
  </Each_Person>
  
  <Each_Person>
      <Name>Professor Satton</Name>
      <Phone>416-991-9999</Phone>
  </Each_Person>
</Data>
==================================================

Reply By: joefawcett Reply Date: 11/7/2003 3:25:23 AM
A really simple test like this works. Send me your files via email, click icon above message and I'll have a proper look.

<html>
<head><title>Simple Data Bind</title>
<script type="text/javascript">

function addPerson()
{
  var oDoc = document.getElementById("data").XMLDocument;
  var oPerson = oDoc.createElement("Each_Person");
  (oPerson.appendChild(oDoc.createElement("Name"))).text = document.getElementById("txtName").value;
  (oPerson.appendChild(oDoc.createElement("Phone"))).text = document.getElementById("txtPhone").value;
  oDoc.documentElement.appendChild(oPerson);
}
</script>
<xml id="data" src="name.xml"></xml>
</head>
<body>
Name:&nbsp;<input type="text" id="txtName" size="20">
Phone:<input type="text" id="txtPhone" size="20">
<input type="button" onclick="addPerson();" value="Add Person">


<table border="1" datasrc="#data">
<tr>
<td><span datafld="Name"></span></td>
<td><span datafld="Phone"></span></td>
</tr>
</table>

</body>
</html>


Joe (MVP - xml)
Reply By: hbcontract Reply Date: 11/11/2003 3:04:03 PM
Hi Joe, did you received my files? Have you get a chance to take a look at it? Thanks.

Reply By: joefawcett Reply Date: 11/12/2003 3:35:42 AM
I'm afraid I haven't. Send them again and I'll be extra careful. I was getting so much rubbish with sobig etc. taht I deleted quite a few legitimate emails.

--

Joe
Reply By: hbcontract Reply Date: 11/12/2003 11:08:15 AM
Hi Joe, I just send you my codes. Kindly check it out. Thanks, looking forward to hear from you soon.

Reply By: joefawcett Reply Date: 11/19/2003 4:35:59 AM
Two things appear to be wrong, firstly your tables and stuff are incorrect, this means IE is struggling to parse the document, make sure that td tags match, input elements do not have closing tag, head is ended etc.
Secondly the structure of your xml is strange, a stray name element surrounds the details. IE can only cope with very tabular xml docs.

Joe (MVP - xml)

Go to topic 6675

Return to index page 1002
Return to index page 1001
Return to index page 1000
Return to index page 999
Return to index page 998
Return to index page 997
Return to index page 996
Return to index page 995
Return to index page 994
Return to index page 993