0

Apologies if the title is bit confusing, had to keep it concise.

Okay so the xml document looks like this

<students>
        <student sid="S2208">
            <fname>Ben</fname>
            <lname>Doe</lname>
            <scourses courseid="DSA" mode="full-time"/>
            <scourses courseid="INT" mode="part-time"/>
        </student>
<students>

<lecturers>
        <lecturer lid="L1101">
            <fname>Dohn</fname>
            <lname>Joe</lname>
            <lcourses courseid="DSA"/>
            <lcourses courseid="INT"/>
            <lcourses courseid="ACT"/>
        </lecturer>
<lecturers>

Using the courseid attribute of scourses in the /students/student is it possible to then retrieve the lid attribute of /lecturers/lecturer by testing whether it exists as an attribute of lcourses? I can only manage to get a 'true' evaluation with the methods I've come up with but not the actual content lid.

2
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by Anark10n
0

What are we working with here? XSLT? XPATH? Other?

As retrieving the value may differ slightly as a result

0

XSLT. Since XSLT uses XPATH to navigate the XML document, how would the result differ?

0

It wouldn't too much, just where the result came from and how the code was written to select such values.

XPath would return results directly through programming while XSLT creates a whole new XML/TXT/HTML file to which it outputs/reorders information

0

Okay, here's my xslt transformation to html.

    <xsl:template match="xt:students">
        <h1>Student Schedule</h1>
        <xsl:for-each select="xt:student">
            <p>
                <xsl:value-of select="@sid"/>
                <xsl:text> </xsl:text> 
                <xsl:value-of select="xt:fname"/> 
                <xsl:text> </xsl:text> 
                <xsl:value-of select="xt:lname"/>
            </p>
            <table border="1">
                <tr>
                    <td><b>Course</b></td>
                    <td><b>Lecturer</b></td>
                    <td><b>Time</b></td>
                    <td><b>Venue</b></td>
                </tr>
                <xsl:for-each select="xt:scourses">
                    <tr>
                        <td><xsl:value-of select="@courseid"/> - <xsl:value-of select="@mode"/></td>
                        <td>
                            <xsl:value-of select="../../../xt:lecturers/xt:lecturer/@lid"/>
                        </td>
                    </tr>
                </xsl:for-each>
            </table>
        </xsl:for-each>
    </xsl:template>

It generates a timetable for a particular student. There are going to be different subjects with one lecturer teaching one subject. The problem is, that i can't seem to find away of returning the lecturer id, by matching the attribute courseid of student/scourses to the attribute courseid of lecturer/lcourses.

Is that even possible with XSLT or XPATH?

Edited by Anark10n

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.