Advertisement

09.22.2008 at 10:14AM PDT, ID: 23752145
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.9

Having trouble getting a xsl for each working properly while inside another loop

Asked by a53mp in Active Server Pages (ASP), Extensible Markup Language (XML), Extensible Stylesheet Language Transformation (XSLT)

Tags: ,

I have an ASP page using XML. Each product gets listed based by it's attributes and inside each product has more nodes that it needs to display as well. I'm trying to loop through these results, but it only shows the first result from each node, not a loop of the results. However when I do size() it does show me to correct number of results I should be receiving in the loop


Thanks in advance.. I'm sure the solution is simple, however I'm still a beginner. Also if there is an easier way to do this or if I am not doing it in the correct way, please feel free to let me know.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
<!-- XML  ->
 
<data>
 <products>
    <product type="photo" section="everyday" layer="sdhc">
      <name><![CDATA[SanDisk Ultra&#174 II SD&trade; & SDHC&trade; Cards]]></name>
      <brief>
        <![CDATA[Upgrade to the card of choice for serious amateurs and pro photographers alike. So fast, you'll never miss a shot again.]]>
      </brief>
      <size imageurl="/img/common/products/Ultra2_SDHC_32GB.jpg" >
               <approxpictures megapixels="10">1</approxpictures>
	       <approxpictures megapixels="8">2</approxpictures>
	       <approxpictures megapixels="4">3</approxpictures>
	       <approxpictures megapixels="4">18</approxpictures>
	       <approxpictures megapixels="2">4</approxpictures>
	       5
      </size>
      <size imageurl="/img/common/products/Ultra2_SDHC_16GB.jpg" >
               <approxpictures megapixels="10">6</approxpictures>
	       <approxpictures megapixels="8">7</approxpictures>
	       <approxpictures megapixels="4">8</approxpictures>
	       <approxpictures megapixels="2">9</approxpictures>
	       10
      </size>
      <size imageurl="/img/common/products/Ultra2_SDHC_8GB.jpg ">
               <approxpictures megapixels="10">11</approxpictures>
	       <approxpictures megapixels="8">12</approxpictures>
	       <approxpictures megapixels="4">13</approxpictures>
	       <approxpictures megapixels="2">14</approxpictures>
	       15
      </size>
      <size imageurl="/img/common/products/Ultra2_SDHC_4GB.jpg" >
        <approxpictures megapixels="10">16</approxpictures>
	<approxpictures megapixels="8">17</approxpictures>
	<approxpictures megapixels="4">18</approxpictures>
	<approxpictures megapixels="4">18</approxpictures>
	<approxpictures megapixels="2">19</approxpictures>
	20
      </size>
      
      <moreinfourl/>
      <buydirecturl/>
      <printabledetailsurl/>
    </product>
    
	<product type="photo" section="everyday" layer="sdhc">
		<name><![CDATA[SanDisk Standard SD&trade; & SDHC&trade; Cards]]></name>
		<brief><![CDATA[When you need a memory card you can count on every day, trust your precious memories to one of these easy, reliable and affordable cards.]]></brief>
		<size imageurl="/img/common/products/Standard_SDHC_16GB.jpg" >
			<approxpictures megapixels="10">16gb-10</approxpictures>
			<approxpictures megapixels="8">16gb-8</approxpictures>
			16b
		</size>
		<size imageurl="/img/common/products/Standard_SDHC_8GB.jpg" >
			<approxpictures megapixels="10">8gb-10</approxpictures>
			<approxpictures megapixels="8">10600-8gb-8</approxpictures>
			8b
		</size>
		<size imageurl="/img/common/products/Standard_SDHC_4GB.jpg" >
			<approxpictures megapixels="10">4gb-10</approxpictures>
			<approxpictures megapixels="8">4gb-86</approxpictures>
			<approxpictures megapixels="10">4gb-102</approxpictures>
			<approxpictures megapixels="8">4gb-83</approxpictures>
			<approxpictures megapixels="10">4gb-10a</approxpictures>
			<approxpictures megapixels="8">4gb-81</approxpictures>
			4b
		</size>
		<size imageurl="/img/common/products/Standard_SDHC_2GB.jpg" >
			<approxpictures megapixels="10">2gb-10w</approxpictures>
			<approxpictures megapixels="8">2gb-8a</approxpictures>
			<approxpictures megapixels="10">2gb-10a</approxpictures>
			<approxpictures megapixels="8">2gb-8f</approxpictures>
			2b
		</size>
      <moreinfourl/>
      <buydirecturl/>
      <printabledetailsurl/>
    </product>
</data>
 
 
 
 
 
 
 
 
<!--  Here is the xsl that relates to the issue -->
  <xsl:template name="products">
       <h1>Products</h1>
       <table border="1">
	<tr>
	  <td>Name</td>
	  <td>Brief</td>
	  <td>Size 1</td>
	</tr>
	<xsl:for-each select="data/products/product[@type='photo' and @section='everyday' and @layer='sdhc']">
	  <tr>
	     <td><xsl:value-of select="name" /></td>
	     <td><xsl:value-of select="brief" /></td>
	     <td><xsl:for-each select="size"><xsl:value-of select="approxpictures" /><br /></xsl:for-each></td>
	  </tr>
	</xsl:for-each>
      </table>
  </xsl:template>
 
 
------------------------------
Using that code, for "approxpictures" it returns 1, 6, 11, 16 which if you look at the xml, is the first result of the <approxpictures> node.. if I call value-of select="approxpictures[1]" for example I can see the specific node.. If I do value-of select="size(approxpictures)"  then it does show me the correct number of nodes within each "size"
[+][-]09.22.2008 at 10:34AM PDT, ID: 22542101

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), Extensible Markup Language (XML), Extensible Stylesheet Language Transformation (XSLT)
Tags: ASP + XML, Looping with for each
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.22.2008 at 11:39AM PDT, ID: 22542648

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 11:52AM PDT, ID: 22542770

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 11:57AM PDT, ID: 22542807

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628