[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Using XSL for Serialization with Javascript.

Subject: RE: Using XSL for Serialization with Javascript.
From: Adam Van Den Hoven <Adam.Hoven@xxxxxxxxxxxx>
Date: Tue, 14 Nov 2000 09:22:52 -0800
javascript object serialization
Thanks Robert, 

I had actually already considered this option and it is not precisely the
answer I'm hoping for. Clearly you could eval the output string and you
should end up with the required objects. What I'm hoping for is that at the
end of my transform all my objects will be populated.

Perhaps the real question is whether the script (I realize this is an MSXML
only thing) I run in my transformation is aware of the scripting context in
which its run. 

Adam

> -----Original Message-----
> From: Robert Koberg [mailto:rob@xxxxxxxxxx]
> Sent: Tuesday, November 07, 2000 6:17 PM
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: Re: Using XSL for Serialization with Javascript.
> 
> 
> > 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);
> > }
> > }
> 
> (Note: I have not tried the code below)
> you could use XSL to write out the javascript object
> 
> the XML:
> <people>
> <person>
>     <name>Someone</name>
>     <email>Someone@xxxxxxxxxxx</email>
> </person>
> 
> <person>
>     <name>Sometwo</name>
>     <email>Sometwo@xxxxxxxxxxx</email>
> </person>
> 
> <person>
>     <name>Somethree</name>
>     <email>Somethree@xxxxxxxxxxx</email>
> </person>
> </people>
> 
> the XSL:
> 
> <xsl:template match="people">
>     &lt;script&gt;
>         var list = new MailingList();
>         var aContact
>         <xsl:apply-templates/>
>         list.addContact(aContact);
>     &lt;/script&gt;
> </xsl:template>
> 
> <xsl:template match="person">
>     <xsl:variable name="i" select="position()-1"/>
>     aContact[$i].name = "<xsl:value-of select="name"/>";
>     aContact[$i].email = ""<xsl:value-of select="email"/>";
> </xsl:template>
> 
> the result could look like:
> 
> var list = new MailingList();
> var aContact
> 
> aContact[0].name = "Someone";
> aContact[0].email = "mailto:someone@xxxxxxxxxxx;
> aContact[1].name = "Sometwo";
> aContact[1].email = "mailto:sometwo@xxxxxxxxxxx;
> aContact[2].name = "Somethree";
> aContact[2].email = "mailto:somethree@xxxxxxxxxxx;
> list.addContact(aContact);
> 
> 
> 
> hth
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.