Jump to content

d.toteva

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About d.toteva

  • Rank
    Newbie
  1. I need your help for a question about XSLT. It is part of my preparation for an exam. The information given is as follows: HTML rendering of the XML document from Figure 1. Note that groups, and staff within each group, appear in the same order as in the XML document. At the end of each staff member entry, there are the identifiers of other groups to which the academic also belongs. These are hyperlinked to the start of the corresponding group sections. The final result of applying XSLT must be as shown in the attached picture. The XML file is as follows: <?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="research.xsl"?><ResearchGroups xmlns="http://www.essex.ac.uk/ce832"><Group name="Intelligent Systems Group" id="ISG"> The IntelligentSystems Group pursues internationally-leading research in a widerange of intelligent systems. </Group><Group name="Robotics" id="RBT"> The Essex robotics group is one ofthe largest mobile robotics groups in the UK. </Group><Staff name="Callaghan, Vic" title="Professor" groups="ISG RBT">Intelligent environments and robotics. </Staff><Staff name="Gu, Dongbing" title="Dr" groups="RBT"> Multi-agentand distributed control systems. </Staff></ResearchGroups> The .xsl file I have created is as follows: <xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:rg="http://www.essex.ac.uk/ce832"xmlns="http://wwww.w3.org/1999/xhtml"version="2.0"><xsl:template match="/"><html><head> <title>Research Groups</title> </head><body> <xsl:apply-templates select="//rg:Group"/> </body></html></xsl:template><xsl:template match="rg:Group"><xsl:variable name="ID" select="@id"/><h3> <a name="{$ID}"> <xsl:value-of select="@name"/> </a> </h3><p> <xsl:value-of select="text()"/> </p> <xsl:for-each select="//rg:Staff"> <xsl:variable name="string" select="@groups" /> <xsl:value-of select="$string" /> <xsl:variable name="stringList" select="tokenize($string, ' ')" /> <xsl:variable name="staffName" select="@name" /> <xsl:variable name="description" select="text()" /> <xsl:for-each select="$stringList"> <xsl:variable name="item" select="." /> <xsl:choose> <xsl:when test="matches($item, $ID)"> <ul> <li> <xsl:value-of select="$staffName" />: <xsl:value-of select="$description" /> <xsl:value-of select="$ID" /> </li> </ul> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> The problem I have is with the part "At the end of each staff member entry, there are the identifiers of other groups to which the academic also belongs. These are hyperlinked to the start of the corresponding group sections." Because the first staff member belongs to two groups while the second does not. At the moment, the information displayed is the id of the current group, not as expected. The first person belongs to who groups - ISG and RBT. When their name appears in the first group, the id of the other group must be displayed and to contain link to the second group - Robotics. The same applies if the person appears in the second group. If the person does not belong to more than one group, there does not have to be a link displayed. I guess that I have to take each value from the stringList variable and make a comparison. The problem is that I do not know how to do it. I hope that somebody can help me! Thank you in advance.
×
×
  • Create New...