Advertisement

07.22.2008 at 04:37PM PDT, ID: 23586948
[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.3

trying to use for-each. can't achieve desired result

Asked by toymachiner62 in Extensible Stylesheet Language Transformation (XSLT), Extensible Markup Language (XML)

I'm trying to convert the original xml file to another xml file so i can learn it. I am trying to only select the course's in my original xml that have the delivery attribute = to 'Classroom'. I got that part but then i'm trying to set the "credits" attribute of class in the new xml to the "credits" attribute of course in the original xml.

I'm using <xsl:for-each> and the problem seems to be that i'm not sure how to reference nodes which are parents of where the <xsl:for-each> begins. The title and number elements also don't come out right. It seems as if my xpath is not right and that it just starts at the beginning of the file and finds the first delivery = to 'Classroom' and then uses that title and number.

Any suggestions?

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:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
*****************************original .xml*********************
<?xml version="1.0" encoding="UTF-8"?>
 
 
<courses>
	<course number = "CS341" credits = "4.0">
    <title>Data Structures</title>
    <section number = "01" id = "X001780" delivery = "Classroom">
      <enrollment>4</enrollment>
      <date>
        <start_date>08/26/2008</start_date>
        <end_date>12/11/2008</end_date>
      </date>
      <days>T TH</days>
      <time>
        <start_time>4:00pm </start_time>
        <end_time>5:50pm</end_time>
      </time>
      <room campus = "Rochester">EA244</room>
      <instructor>
        <first>Nicole</first>
        <last>Anderson</last>
      </instructor>
	  </section>
	  <section number = "CS341" id = "X001788" delivery = "On-line">
      <enrollment>0</enrollment>
      <date>
        <start_date>08/29/2008</start_date>
        <end_date>12/12/2008</end_date>
      </date>
      <days></days>
      <time>
        <start_time></start_time>
        <end_time></end_time>
      </time>
      <room campus = "Rochester"></room>
      <instructor>
        <first>Nicole</first>
        <last>Anderson</last>
      </instructor>
      <instructor>
        <first>Chi-Cheng</first>
        <last>Lin</last>
      </instructor>
	  </section>
  </course>
  <course number = "CS368" credits = "3.0">
    <title>Introduction to Bioinformatics</title>
    <section number = "01" id = "X001781" delivery = "ITV">
      <enrollment>3</enrollment>
      <date>
        <start_date>08/27/2008</start_date>
        <end_date>12/10/2008</end_date>
      </date>
      <days>W</days>
      <time>
        <start_time>6:00pm </start_time>
        <end_time>8:40pm</end_time>
      </time>
      <room campus = "Rochester">AT102</room>
      <instructor>
        <first>Chi-Cheng</first>
        <last>Lin</last>
      </instructor>
      <instructor>
        <first>Mingrui</first>
        <last>Zhang</last>
      </instructor>
	    </section>
    </course>
  <course number = "CS375" credits = "4.0">
    <title>Computer Systems</title>
    <section number = "01" id = "X001782" delivery = "Classroom">
     <enrollment>12</enrollment>
     <date>
       <start_date>08/25/2008</start_date>
       <end_date>12/10/2008</end_date>
     </date>
     <days>M W</days>
     <time>
       <start_time>4:00pm </start_time>
       <end_time>5:50pm</end_time>
     </time>
     <room campus = "Rochester">EA244</room>
     <instructor>
       <first>Nicole</first>
       <last>Anderson</last>
     </instructor>
	  </section>
  </course>
  <course number = "CS415" credits = "3.0">
    <title>Principles of Programming Languages</title>
    <section number = "01" id = "X001784" delivery = "Classroom">
      <enrollment>13</enrollment>
      <date>
        <start_date>08/26/2008</start_date>
        <end_date>12/11/2008</end_date>
      </date>
      <days>T TH</days>
      <time>
        <start_time>4:00pm </start_time>
        <end_time>5:20pm</end_time>
      </time>
      <room campus = "Rochester">EA246</room>
      <instructor>
        <first>Hugh</first>
        <last>Ouellette</last>
      </instructor>
	  </section>
  </course>
</courses>
 
****************************.xslt*****************************
 
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:template match="/">
  <xsl:element name="classes">
    <xsl:attribute name="count"><xsl:value-of select="count(/courses/course/section[@delivery='Classroom'])" />
    </xsl:attribute>
 
<xsl:for-each select="/courses/course/section[@delivery='Classroom']">
 
 
    <xsl:element name="class">
     <xsl:attribute name="credits"><xsl:value-of select="//course/@credits" /></xsl:attribute>
      
     <xsl:element name="number">
     <xsl:value-of select="//course/@number" />
    </xsl:element>    
  
    <xsl:element name="title">
    <xsl:value-of select="//title" />
    </xsl:element>
      
    <xsl:element name="time">
    <xsl:attribute name="days"><xsl:value-of select="days" /></xsl:attribute>
    </xsl:element>
      
    <xsl:copy-of select="room" />
      
    <xsl:copy-of select="instructor" />
      
    </xsl:element>
 
    </xsl:for-each>      
</xsl:element>
 
</xsl:template>
</xsl:stylesheet>
[+][-]07.22.2008 at 04:39PM PDT, ID: 22064693

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:43PM PDT, ID: 22064712

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:45PM PDT, ID: 22064733

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:50PM PDT, ID: 22064756

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:03PM PDT, ID: 22064844

View this solution now by starting your 30-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: Extensible Stylesheet Language Transformation (XSLT), Extensible Markup Language (XML)
Sign Up Now!
Solution Provided By: abel
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.22.2008 at 05:09PM PDT, ID: 22064876

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:11PM PDT, ID: 22064893

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:11PM PDT, ID: 22064894

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:13PM PDT, ID: 22064902

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 30-day free trial to view this Expert Comment or ask the Experts your question.

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