Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2007, 03:07 PM
Registered User
 
Join Date: Apr 2007
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.
 
Old April 27th, 2007, 05:13 AM
Authorized User
 
Join Date: Apr 2007
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>

 
Old April 27th, 2007, 06:01 AM
Registered User
 
Join Date: Apr 2007
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.
 
Old April 27th, 2007, 06:31 AM
Registered User
 
Join Date: Apr 2007
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?
 
Old April 27th, 2007, 06:50 AM
Authorized User
 
Join Date: Apr 2007
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.

 
Old April 27th, 2007, 07:08 AM
Registered User
 
Join Date: Apr 2007
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.





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





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