Using XSL for Serialization with Javascript.

Subject: Using XSL for Serialization with Javascript.
From: Adam Van Den Hoven <Adam.Hoven@xxxxxxxxxxxx>
Date: Tue, 7 Nov 2000 16:05:52 -0800
Hi, 

We have a webbased UI for one of our applications where we have decided to
create Javascript classes to represent our various data types. These objects
would then be passed to various other UI classes for display.  We use XML
for serialization and since we're in a homogenous Microsoft envirnoment,
we're going to make use of MSXML 3.0. 

What I'm wondering is whether I can take an XML I've retrieved from where
ever and apply a template to it such that we end up with properly populated
Javascript objects. 

Here's an example of what I mean. Lets say that I have a mailinglist object
that is a collection of contact objects. We might create such a object in
Javascript with something like:

function setup() {
	var list = new MailingList();
	var aContact
	for(var x = 0; x<20; x++) {
		aContact = new Contact();
		aContact.name = "Someone";
		aContact.email = "someone@xxxxxxxxxxx";
		list.addContact(aContact);
	}
}

Obviously that is a pointless piece of script but you all know what I mean. 

Lets also assume that somehow I've serialized my MailingList into something
like:

<MailingList>
	<Contact id="001">
		<email>someone@xxxxxxxxxxx</email>
		<name>someone</name>
	</Contact>
	<Contact id="002">
		<email>someone@xxxxxxxxxxx</email>
		<name>someone</name>
	</Contact>
	<Contact id="003">
		<email>someone@xxxxxxxxxxx</email>
		<name>someone</name>
	</Contact>
	<Contact id="004">
		<email>someone@xxxxxxxxxxx</email>
		<name>someone</name>
	</Contact>
	<Contact id="005">
		<email>someone@xxxxxxxxxxx</email>
		<name>someone</name>
	</Contact>
	<Contact id="006">
		<email>someone@xxxxxxxxxxx</email>
		<name>someone</name>
	</Contact>
</MailingList>

Now, I know that for serialization, I can simply load the XML and navigate
the hierarchy using the DOM. However, I was wondering if it was possible for
me to use an XSL stylesheet to create the Contact objects. I suppose it
would be possible for the XSL to generate a string that could be eval'ed in
javascript to create the objects but I'm looking for the XSL to actually
generate the objects themselves.

Thanks,
> 		Adam van den Hoven
> 		Internet Application Developer
> 		Blue Zone
> 		tel. 604.685.4310
> 		fax. 604.685.4391
> 
> Blue Zone makes news interactive. http://www.bluezone.net/
> 
> 
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread