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

Okay so the xml document looks like this

        <student sid="S2208">
            <scourses courseid="DSA" mode="full-time"/>
            <scourses courseid="INT" mode="part-time"/>

        <lecturer lid="L1101">
            <lcourses courseid="DSA"/>
            <lcourses courseid="INT"/>
            <lcourses courseid="ACT"/>

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.

Recommended Answers

All 4 Replies

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

As retrieving the value may differ slightly as a result

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

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

Okay, here's my xslt transformation to html.

    <xsl:template match="xt:students">
        <h1>Student Schedule</h1>
        <xsl:for-each select="xt:student">
                <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"/>
            <table border="1">
                <xsl:for-each select="xt:scourses">
                        <td><xsl:value-of select="@courseid"/> - <xsl:value-of select="@mode"/></td>
                            <xsl:value-of select="../../../xt:lecturers/xt:lecturer/@lid"/>

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.