Advertisement

06.12.2008 at 07:12AM PDT, ID: 23479515
[x]
Attachment Details

XSLT transformation problem

Asked by taus01 in Extensible Stylesheet Language Transformation (XSLT), Extensible Markup Language (XML), Extensible HTML (XHTML)

Tags: ,

I have a problem transforming a XML file with XSLT into a specific HTML file. See attached Code snippet for the XML/HTML.

The basic problem is that for the first <MODULE_RESULT> i need the child nodes to be enclosed in a <tr id="firsttalent"><td> (one table with all the children goes here) </td></tr>

For the rest of the <MODULE_RESULT> elements i need all of them enclosed in a different <tr id="moretalents"><td> (one table per MODULE_RESULT with all the children) </td></tr>

I know how to select the children etc, the problem is that i do not know how to create multiple tables for all but the first <MODULE_RESULT> enclosed in the different <tr> tag.

I tried select="MODULE_RESULT[position()&gt;1]" and such but always ran into problems applying all the tables within. It must be pretty simple but i can't seem to find the solution.

Please take a look at the Code Snippet. Can you help me writing the XSLT?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:
/* The XML File */
<OBRES name="TalentRoster">
    <MODULE_RESULT>
    	<U>http://www.xyz.com/</U>
	<Field name="id">1</Field>
    	<Field name="firstname">Elvis</Field>
    	<Field name="lastname">Crespo</Field>
	<Field name="org_label">Unassigned</Field>
	<Field name="genre">Unknown</Field>
	<Field name="ar_admin">Unassigned</Field>
	<Field name="ar_manager">Unassigned</Field>
	<Field name="prod_manager">Unassigned</Field>
	<Field name="ba_contact">Unassigned</Field>
	<Field name="ba_supervisor">Unassigned</Field>
	<Field name="status">Unassigned</Field>
    </MODULE_RESULT>
    <MODULE_RESULT>
    	<U>http://www.xyz.com/</U>
	<Field name="id">1</Field>
    	<Field name="firstname">Elvis</Field>
    	<Field name="lastname">Crespo</Field>
	<Field name="org_label">Unassigned</Field>
	<Field name="genre">Unknown</Field>
	<Field name="ar_admin">Unassigned</Field>
	<Field name="ar_manager">Unassigned</Field>
	<Field name="prod_manager">Unassigned</Field>
	<Field name="ba_contact">Unassigned</Field>
	<Field name="ba_supervisor">Unassigned</Field>
	<Field name="status">Unassigned</Field>
    </MODULE_RESULT>
</OBRES>
 
/* What the HTML has to look like (ignoring missing outer table tags) */
 
/* First <MODULE_RESULT> */
<tr id="firsttalent">
<td>
<table>
<tr>
<td>
<xsl:value-of select="Field[@name='lastname']"/>, <xsl:value-of select="Field[@name='firstname']"/>
</td>
...
</table>
</td>
</tr>
 
/* Second to last <MODULE_RESULT> */
<tr id="moretalents">
<td>
<table>
<tr>
<td>
<xsl:value-of select="Field[@name='lastname']"/>, <xsl:value-of select="Field[@name='firstname']"/>
</td>
...
</table>
<table>
<tr>
<td>
<xsl:value-of select="Field[@name='lastname']"/>, <xsl:value-of select="Field[@name='firstname']"/>
</td>
...
</table>
<table>
<tr>
<td>
<xsl:value-of select="Field[@name='lastname']"/>, <xsl:value-of select="Field[@name='firstname']"/>
</td>
...
</table>
</td>
</tr>
 
 
[+][-]06.12.2008 at 07:34AM PDT, ID: 21769872

View this solution now by starting your 7-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), Extensible HTML (XHTML)
Tags: XML, XSLT, HTML, All
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.12.2008 at 07:53AM PDT, ID: 21770104

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

 
[+][-]06.12.2008 at 08:03AM PDT, ID: 21770224

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

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628