Solved

Merging Data into HTML

Posted on 2002-06-18
12
200 Views
Last Modified: 2010-05-18
Hi,

I want to define a class structure with associated data in one document, then define the html in another with suitable links into the first, and have it all parsed when the html is loaded into the browser. An example follows:

1st doc.

<Class definition : Person>
<Name> John Smith
<Age> 34
<Name> Sally Johnson
<Age> 29
...

2nd doc

...
<TABLE>
<TH>Name
<TD><Person.Name>
<TH>Age
<TD><Person.Age>
...

It seems such an obvious problem, but I can't find the solution anywhere.
0
Comment
Question by:ahmad_zaman
12 Comments
 
LVL 19

Expert Comment

by:webwoman
ID: 7090400
It's not done with HTML. It's done either with XML, or a database.
0
 

Author Comment

by:ahmad_zaman
ID: 7090481
Arrrrrrrrrrrrrrrrrrrrrgggggggggghhhhhhh !!!!!
0
 

Author Comment

by:ahmad_zaman
ID: 7090492
Hi,

I don't want to burden my users with an XSL parser (since it will be an open environment) and I don't know the server side specification, so I don't know if I can use PHP/ASP or something else - The ISP may not use a  webserver with a suitable language processor.
0
 
LVL 1

Expert Comment

by:isilver
ID: 7090539
You may not need to use php/asp to get this working.  I would suggest to visit the link http://www.w3schools.com/xsl/ and specfically review the XSL <xsl:template> and XSL <xsl:for-each> documentation.  Please note that if you do decide to take the route of xsl you will probably find that it is only compatible with IE.

You can also do this in javascript but it would not be a good idea to use xml in that case.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7090833
> .. I don't know the server side specification,

could you then please post the specifications you know, and will accept.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7090884
Based on what I know so far it may be possible to use XML data islands (IE only).  Whether the data pages are static or dynamically generated, the data can be put into islands and the islands linked to the table content with textboxes.  Because it is IE only the textboxes can be styled to look like the data is in a table if that look is essential.  Depending on the nature and use of the data you could also go to css styled and possition divs and spans.  

You can also go to table cells directly, but that is the most complex to program and difficult to get working right.

It takes scripting on the client to manage the page, but the only thing that has to be done server side is to correctly format the data islands.

Because the data is separate pages, they need to be loaded through either a hidden frame or a 1x1 iframe. the hidden frame may be the better option as xml hidden in a 1x1 iframe may trigger a virus alert for clients running active scanning.

Cd&
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:bruno
ID: 7091629
ahmad,

you need either XML/XSL as has been mentioned, or do a search on "data binding" which might also be close, but might be an IE only solution.


BRUNO
0
 
LVL 14

Accepted Solution

by:
avner earned 50 total points
ID: 7091832
No problem to do that with JS , will work on every browser version :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Dyanmic Table from Data </TITLE>
<META NAME="Author" CONTENT="(C)Avner Cohen">
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
var oMeta=["Class","Name","Age"];
var data0=["Person","Animal","Car"]
var data1=["Ahmed","Tiger","Volvo"];
var data2=["33","12","2"];
var oData=[data0,data1,data2];

function dataToTable(meta,data)
{
var s="";
       s+="<TABLE BORDER='1'>";
       s+="<TR>";
          for (var i=0;i<meta.length;i++)
               {
               s+="<TH> "+meta[i]+"</TH>"
               }
     s+="</TR>";
          for (var i=0;i<data.length;i++)
               {
               s+="<TR>";
                    for (var t=0;t<data[i].length;t++)
                         {
                         s+="<TD> "+data[i][t]+"</TD>";
                         }
               s+="</TR>";
               }
s+="</TABLE>";

return s;
     
}
-->
</SCRIPT>
</HEAD>

<BODY>
<script>document.write(dataToTable(oMeta,oData))</script>
</BODY>
</HTML>
0
 
LVL 10

Expert Comment

by:dij8
ID: 7092146
A variation on what avner has written could allow for your "1st doc" to be a JavaScript array.  It wouldn't take on the exact format you have.  But if it did then it would be XML right!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7182689
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
   In the absence of responses, I may recommend DELETE unless it is clear
   to me that it has value as a PAQ.  Silence = you don't care
</note>

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7211783
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to avner

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7237589
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now