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

RE: xhtml xslt file: populating javascript array with

Subject: RE: xhtml xslt file: populating javascript array with data from xml file?
From: "Dominic J. Blythe" <Dominic.Blythe@xxxxxxxxxxxxxxx>
Date: Fri, 29 Jun 2001 09:32:02 +0100
javascript xml to array
this works fine in ie5 to get the answer attribute
into position [id attribute] in an array called questions.

<?xml version="1.0"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/TR/WD-xsl"
  xmlns="http://www.w3.org/TR/REC-html40"
  result-ns="">

<output method="html" version="4.0" encoding="ISO-8859-1"
media-type="text/html"/>
<xsl:template match="/">
	<script><![CDATA[ questions = new Array(); ]]></script>
	<xsl:apply-templates select = "question"/>
</xsl:template>
<xsl:template match="question">
	<script>questions[<xsl:value-of select="@id"/>]
		=<xsl:value-of select="@answer" />;</script>
</xsl:template>
</xsl:stylesheet>

I expect something similar is possible in any xslt interpreter. 


Anthony E wrote:
> 
> any ideas on how i can set the variables/arrays in my
> javascript with data from my xml file?
> 

<question id="1" answer="2">
What time is it?
  <choice id="1">a) daytime</choice> **(close the tag you openened)
  <choice id="2">b) nighttime</choice> **
  <explanation>answer is "b" because it is dark
outside.</explanation>
</question>



______________________________________________________________________
Dominic Blythe
Programmer
BCP Ltd

BCP House, 151 Charles St, Stockport, SK1 3JY  UK
t: 0161 355 3000 f: 0161 355 3001
e: dominic.blythe@xxxxxxxxxxxxxxx
_____________________________________________________________________
/*  It's nice to be important, but it's more important to be nice  */
> 
> 

 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.