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

RE: Dynamic javascript array loading in XSL page.

Subject: RE: Dynamic javascript array loading in XSL page.
From: sicaudp@xxxxxxxxxxxxxx
Date: Wed, 10 Apr 2002 12:35:53 -0700
javascript array
Rob- 
Thanks for your assist. This works well and I really appreciate you answer.
Still working on it to make it still better( hopefully!).


Patrice Sicaud
Internet Customer Care Systems
Wells Fargo Bank
45 Fremont St, Suite 1060
MAC A0104-100
San Francisco, CA 94105

Email: sicaudp@xxxxxxxxxxxxxx 
page:  email to sicaudp@xxxxxxxxxxxxxx 
       OR message at 1-877-935-5747
Phone: 415-222-4347
FAX:   415-975-7521 


-----Original Message-----
From: Robert Koberg [mailto:rob@xxxxxxxxxx]
Sent: Tuesday, April 09, 2002 9:54 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Dynamic javascript array loading in XSL page.


Hi,

[I use your online banking :)]

How about something like:

<script>
   var SRArray = new Array();
   <xsl:apply-templates select="SRSource/IndividualSR"/>
</script>

<xsl:template match="IndividualSR">
   <xsl:text>SRArray[</xsl:text>
   <xsl:value-of select="position()"/>
   <xsl:text>]  = ['</xsl:text>
   <xsl:value-of select="SrID"/>
   <xsl:text>','</xsl:text>
   <xsl:value-of select="srothervalue"/>
   <xsl:text>'];</xsl:text>
</xsl:template>

best,
-Rob

sicaudp@xxxxxxxxxxxxxx wrote:

>All:
>First of all, I am an absolute newbie for XSL but I am trying....
>
>I have been tasked with taking over a collection of XSL pages which produce
>HTML forms.
>Some of the pages contains script in CDATA blocks and I need to enhance the
>functionality for some of them.
>In particular, I need to build small matrices do be displayed in child
>browser windows.
>Given that I do not want to use hidden tags, I elected to load a javascript
>two-dimensional array.
>So...., given a XML source file similar to the one below, how can I laod
the
>data in the html page? (so I get the 'desired result' below)
>
>I have included my first (and second) attempts to do this just for laughs
>but of course, nothing works. I would really appreciate it if anybody gave
>me any pointers. In the meantime, I'll just go back to reading Michael's
>book (excellent but not easy to follow) between training bouts at Zvon.org.
>(thanks for the pointer Joerg)
>
>TIA
>
>Patrice
>
>
>XML SOURCE
>
><?xml-stylesheet type="text/xsl" href="ArrayLoadTest.xsl"?>
><SRSource>
>   <IndividualSR>
>      <SrID>srid1</SrID>
>      <srothervalue>srothervalue1</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid2</SrID>
>      <srothervalue>srothervalue2</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid3</SrID>
>      <srothervalue>srothervalue3</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid4</SrID>
>      <srothervalue>srothervalue4</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid5</SrID>
>      <srothervalue>srothervalue5</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid6</SrID>
>      <srothervalue>srothervalue6</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid7</SrID>
>   <   srothervalue>srothervalue7</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <A8SrID>srid8</A8SrID>
>      <srothervalue>srothervalue8</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid9</SrID>
>      <srothervalue>srothervalue9</srothervalue>
>   </IndividualSR>
>   <IndividualSR>
>      <SrID>srid10</SrID>
>      <srothervalue>srothervalue10</srothervalue>
>   </IndividualSR>
></SRSource>
>
>
>DESIRED RESULT 
>
><script type="text/javascript" language="JavaScript">
>
>    var SRArray = new Array[10];
>	  
>    SRArray [1] = new Array[10];
>    SRArray [2] = new Array[10];
>    SRArray [3] = new Array[10];
>    SRArray [4] = new Array[10];
>    SRArray [5] = new Array[10];
>    SRArray [6] = new Array[10];
>    SRArray [7] = new Array[10];
>    SRArray [8] = new Array[10];
>    SRArray [9] = new Array[10];
>    SRArray[10] = new Array[10];
>		   
>    SRArray [1][1] = 'srid1'
>    SRArray [1][2] = 'srothervalue1'
>    SRArray [2][1] = 'srid2'
>    SRArray [2][2] = 'srothervalue2'
>    SRArray [3][1] = 'srid3'
>    SRArray [3][2] = 'srothervalue3'
>      .
>      .
>      .
>   
></script>
>
>
>MY FIRST LAUGHABLE ATTEMPT AT RESOLVING THE PROBLEM.
>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>xmlns:fo="http://www.w3.org/1999/XSL/Format">
>   <xsl:template match="/">
>      <!-- *** Sicaud  04-03-02 Start Changes -->
>      <html>
>         <head>
>            <title>
>               <xsl:value-of select="title"/>
>            </title>
>            <script type="text/javascript" language="JavaScript">
>
>	  var SRArray = new Array[10];
>	  
>	  SRArray [1] = new Array[10];
>	  SRArray [2] = new Array[10];
>	  SRArray [3] = new Array[10];
>	  SRArray [4] = new Array[10];
>	  SRArray [5] = new Array[10];
>	  SRArray [6] = new Array[10];
>	  SRArray [7] = new Array[10];
>	  SRArray [8] = new Array[10];
>	  SRArray [9] = new Array[10];
>	  SRArray[10] = new Array[10];
>		   
>	  <xsl:variable name="NodeToProcess" select="//"/>
>            <xsl:variable name="outerArrayCount"
>select="count($NodeToProcess)"/> -->
>               <xsl:for-each select="//SRSource/*">-->
>	               <xsl:apply-templates select="//SrSource"/>
>  		            	<xsl:variable name="outerArrayIndex"
>select="position()"/>
>     	          <xsl:for-each select="$NodeToProcess[$outerArrayIndex]/*">
>                 		<xsl:variable name="innerArrayIndex"
>select="position()"/>
>
>               	</xsl:for-each>
>               </xsl:for-each>
>
>               <!-- *** Sicaud  04-03-02 End Changes -->
>            </script>
>         </head>
>         <body/>
>      </html>
>   </xsl:template>
>   
>   <xsl:template match="SrSource">
>      <xsl:for-each select="./*"> 
>         <xsl:apply-templates select="//innerProcessing"
>mode="javascript"/>-->
>         <xsl:param name="node" select="."/>
>       </xsl:for-each>
>   
>      SRArray [<xsl:value-of select="$node"/>] = "<xsl:value-of
>select="."/>";
>
>       SRArray [<xsl:value-of select="$node"/>][<xsl:value-of
>select="position()"/>] = "<xsl:value-of select="."/>";
>   </xsl:template>
>   
>   <xsl:template name="innerProcessing" match="IndividualSR">
>      <xsl:param name="node" select="."/>
>      <xsl:for-each select="./*">
>          SRArray [<xsl:value-of select="$node"/>][<xsl:value-of
>select="position()"/>] = <xsl:value-of select="."/>
>      </xsl:for-each>
>   </xsl:template>
></xsl:stylesheet>
>
>
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>




 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.