[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Dynamic Index?
Hi Ben, > I am trying to create an index.html file that is created by applying > testfile.xml to index.xsl through a cocoon processor. After the > index.html is created there should be a list of links that go to a > "details" document. The "details" document is created by parsing: > testfile.xml to an XSLT Producer called MSDWProducer using a > variable $testsuite_name. This variable $testsuite_name passed to > detail.xsl should indicate the node from the testfile.xml that > should be rendered using detail.xsl and the cocoon processor. There are just a few things that are wrong in your code which are probably messing things up. The name of the parameter $testsuite_name is 'testsuite_name' - you only use the '$' at the beginning when you're referring to the value of the parameter, not when you're creating it or passing values to it. So the link in index.xsl: > <A> > <xsl:attribute > name="HREF">testfile.xml?producer=MSDWProducer&XSL=detail.xsl&$testsuite_nam > e=<xsl:value-of select="@name"/> > </xsl:attribute> > <xsl:value-of select="@name"/> > </A> Should be: <A HREF="testfile.xml?producer=MSDWProducer&XSL=detail.xsl&testsuite_name={@name}"> <xsl:value-of select="@name" /> </A> Note, no $ before the string testsuite_name. Similarly, in detail.xsl, the parameter declaration: > <xsl:variable name="$testsuite_name"/> Should be a parameter (so that you can pass values into it from the outside world) and the name shouldn't have a '$' in it: <xsl:param name="testsuite_name" /> Now, you want to apply templates to the testsuite whose 'name' attribute is the same as $testsuite_name. So change your xsl:apply-templates: > <xsl:apply-templates > select="all-junit-reports/testsuite[@name='test.com.msdw.online.aba.MetroBat > chLoadTestSuite']"/> to: <xsl:apply-templates select="all-junit-reports/testsuite[@name = $testsuite_name]" /> That means that only the testsuite that you're interested in will have templates applied to it. You then need a general template that matches any testsuite and gives output for it. So instead of: > <xsl:template match="all-junit-reports/testsuite[@name='$testsuite_name']"> > ... > </xsl:template> You want just: <xsl:template match="testsuite"> ... </xsl:template> [Note: in the above template you're matching any testsuite that is a child of all-junit-reports (which they all are, so there's no point testing for that) and whose 'name' attribute equals the string '$testsuite_name'. For one thing, you don't want to be testing for that string, but rather the parameter value, so you don't want quotes. But for another, it's illegal in XSLT to have parameter or variable references in the match attribute of xsl:template. That doesn't matter, though - if the testsuite that you're interested in is the only one that's having templates applied to it, there's no need to have a template that only matches that testsuite - it's like doing the same test twice.] I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|