this is my first time working with XPath 2.0, but I have been stuck on this assignment that is telling me to create a template, a variable within the template ("depts.") that contains a sequence of codes, then an element which contains a for-each loop, another variable and finally says to use the doc() function to reference the "deptcurrent.xml" file, where current is the value of the "deptCurrent" variable and it says to use the concat() function to combine the text strings of "dept" and ".xml"? Not certain how exactly to use both the doc() and concat() funtions together, and not sure if I did everything else correct, either.
Here is my stylesheet:
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <html> <head> <title>Employment Report</title> <link href="horizons.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrap"> <header> <img src="horizons.png" alt="Horizons TechNet" /> </header> <h1>Employment Report</h1> </div> </body> </html> </xsl:template> <xsl:template name="getEmployees"> <xsl:variable name="depts" select="'a00, 'c01', 'd11', 'd21', 'e11', 'e21'" as="xs:string" /> <xsl:element name="departments"> <xsl:for-each select="$depts"> <xsl:value-of select="." /> </xsl:for-each> <xsl:variable name="currentDept" select="." /> <xsl:element name="department"> <xsl:attribute name="@deptID"> <xsl:value-of select="currentDept" /> </xsl:attribute> <xsl:value-of select="document('@dept', '.xml')" /> <xsl:copy-of select="employees" /> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> Any tips or advice would be greatly appreciated, thank you.
No comments:
Post a Comment