Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2007, 03:07 PM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 3D Array - Looping

I am trying to display a 3D array. I only want to display 1 level of the 3D array. So i am attempting to do this

for a=1 to 4
  for b=1 to 4
      display x[my3rdplan,a,b]
  next
next

How do I do this in xslt? Here is my data.

    <Array1 Name="MyData" >
        <Value D1="1" D2="1" D3="1">12</Value>
        <Value D1="1" D2="2" D3="1">23</Value>
        <Value D1="1" D2="3" D3="1">11</Value>
        <Value D1="1" D2="4" D3="1">11</Value>
        <Value D1="1" D2="1" D3="2">23</Value>
        <Value D1="1" D2="2" D3="2">32</Value>
        <Value D1="1" D2="3" D3="2">11</Value>
        <Value D1="1" D2="4" D3="2">3</Value>
        <Value D1="1" D2="1" D3="1">242</Value>
        <Value D1="1" D2="2" D3="1">13</Value>
        <Value D1="1" D2="3" D3="1">76</Value>
        <Value D1="1" D2="4" D3="1">49</Value>
    </Array1>

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old April 27th, 2007, 05:13 AM
Authorized User
 
Join Date: Apr 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This woks only if you have coresponding nodes in inner and outer for loop
    <xsl:for-each select =".">
        <xsl:variable name ="Rank">
            <xsl:value-of select ="position()"/>
        </xsl:variable>
        <xsl:for-each select =".">
            <Value D1="1" D2="1" D3="1">
                <xsl:attribute name ="D1" >
                    <xsl:value-of select ="1"/>
                </xsl:attribute >
                <xsl:attribute name ="D2" >
                    <xsl:value-of select ="$Rank"/>
                </xsl:attribute >
                <xsl:attribute name ="D2" >
                    <xsl:value-of select ="position()"/>
                </xsl:attribute >
                <xsl:value-of select ="12"/>
            </Value>
        </xsl:for-each>
    </xsl:for-each>

Reply With Quote
  #3 (permalink)  
Old April 27th, 2007, 06:01 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response pradeepn. I will try it out and let you know how it does.
Reply With Quote
  #4 (permalink)  
Old April 27th, 2007, 06:31 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I thought you had it, but all it is displaying is the number 12. Any idea?
Reply With Quote
  #5 (permalink)  
Old April 27th, 2007, 06:50 AM
Authorized User
 
Join Date: Apr 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<xsl:value-of select ="12"/>

read the value in above node , It is hard coded in the example.

Reply With Quote
  #6 (permalink)  
Old April 27th, 2007, 07:08 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I noticed that as soon as I sent the reply. It is working for me perfectly. Thanks again.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3d graphics meghaljani BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 1 March 26th, 2008 04:41 AM
looping through static array mister_mister XSLT 9 March 21st, 2008 01:30 PM
3D Array Looping - Formatting in table jordan23 XSLT 3 April 30th, 2007 11:57 AM
Looping through Array Values in T-SQL trufla SQL Server ASP 4 April 13th, 2007 06:14 AM
Looping controls and array redim mega Excel VBA 2 April 19th, 2005 11:57 AM



All times are GMT -4. The time now is 05:47 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.