XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
S RSubject: looping problem
Author: S R
Date: 18 Oct 2005 03:27 PM
Hi !

The xml file contains information of 3 students. I'm trying to display the firstname, lastname, id, exam, version and examdate. I'm able to display the information of the first student only. How do I get to display for all the 3 students?

Any suggestion or help is appreciated.

-SR


***************************************
xsl file ******************************
***************************************
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<html>
<body>
<h2>Student Responses</h2>


<table border="0" CELLSPACING="25" >
<xsl:for-each select="AIXRESULT/results">

<tr>
<td><b>FirstName:</b></td>
<td><xsl:value-of select="studentInfo/contact/firstname" /></td>
</tr>
<tr>
<td><b>LastName:</b></td>
<td><xsl:value-of select="studentInfo/contact/lastname" /></td>
</tr>

<tr>
<td><b>Id:</b></td>
<td><xsl:value-of select="studentInfo/contact/id" /></td>
</tr>


<xsl:for-each select="formInfo">

<tr>
<td><b>Exam:</b></td>
<td><xsl:value-of select="exam" /></td>
</tr>

<tr>

<td><b>Version:</b></td>
<td><xsl:value-of select="version" /></td>
</tr>

<tr>
<td><b>ExamDate: </b></td>
<td><xsl:value-of select="examDate" /></td>
</tr>

</xsl:for-each>

</xsl:for-each>

</table>
</body>
</html>


</xsl:template>
</xsl:stylesheet>




****************************************
xml file *******************************
****************************************

<?xml-stylesheet type="text/xsl" href="NameAns1.xsl" ?>

<AIXRESULT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.00">
<results date_generated="10/17/05">
<studentInfo>
<contact>
<id>12345678</id>
<firstname>Robert</firstname>
<lastname>Fulton</lastname>
</contact>
</studentInfo>
<formInfo>
<exam>HS1</exam>
<version>Z1</version>
<lang>English (US)</lang>
<examDate>13-OCT-05</examDate>
<center>S9957</center>
<formId>25605</formId>
<quesCnt>150</quesCnt>
<pretestCnt>0</pretestCnt>
<asgnCnt>1</asgnCnt>
</formInfo>

<studentInfo>
<contact>
<id>44444444</id>
<firstname>Justin</firstname>
<lastname>Jacob</lastname>
</contact>
</studentInfo>
<formInfo>
<exam>HS3</exam>
<version>Z1</version>
<lang>English (US)</lang>
<examDate>13-OCT-05</examDate>
<center>S9957</center>
<formId>25606</formId>
<quesCnt>194</quesCnt>
<pretestCnt>0</pretestCnt>
<asgnCnt>1</asgnCnt>
</formInfo>

<studentInfo>
<contact>
<id>33333333</id>
<firstname>TURNER</firstname>
<lastname>DEANE</lastname>
</contact>
</studentInfo>
<formInfo>
<exam>HS1</exam>
<version>Z1</version>
<lang>English (US)</lang>
<examDate>29-AUG-05</examDate>
<center>S9957</center>
<formId>25605</formId>
<quesCnt>150</quesCnt>
<pretestCnt>0</pretestCnt>
<asgnCnt>1</asgnCnt>
</formInfo>
</results>
</AIXRESULT>

Postnext
(Deleted User) Subject: looping problem
Author: (Deleted User)
Date: 18 Oct 2005 03:51 PM
Assuming that <formInfo> following <studentInfo> corresponds to the same student:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<html>
<body>
<h2>Student Responses</h2>


<table border="0" CELLSPACING="25">
<xsl:for-each select="AIXRESULT/results/studentInfo">

<tr>
<td>
<b>FirstName:</b>
</td>
<td>
<xsl:value-of select="contact/firstname"/>
</td>
</tr>
<tr>
<td>
<b>LastName:</b>
</td>
<td>
<xsl:value-of select="contact/lastname"/>
</td>
</tr>

<tr>
<td>
<b>Id:</b>
</td>
<td>
<xsl:value-of select="contact/id"/>
</td>
</tr>



<tr>
<td>
<b>Exam:</b>
</td>
<td>
<xsl:value-of select="following-sibling::formInfo/exam"/>
</td>
</tr>

<tr>

<td>
<b>Version:</b>
</td>
<td>
<xsl:value-of select="following-sibling::formInfo/version"/>
</td>
</tr>

<tr>
<td>
<b>ExamDate:</b>
</td>
<td>
<xsl:value-of select="following-sibling::formInfo/examDate"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Posttop
S RSubject: looping problem
Author: S R
Date: 19 Oct 2005 02:59 PM
Thanks Yuriy.

I have been able to tackle this problem.

Also, how do I view the xml file in a word document, without the xml tags? The xml file also refers to an xsl.

In simple words, I would like to see my xml file in a word doc, in the same way as I see it being displayed in Internet Explorer.

thanks !
-SR

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.