Subject: Re: [xsl] Writing a stylesheet to create another XML Document From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 8 Apr 2002 09:52:20 +0100 |
Hi Kunal, > However, in VS.NET which uses MSXML 3.0, there is no output at all > if the "EXTRA STUFF" is there in the stylesheet, else all works out > well. The "EXTRA STUFF" is a template matching the root node: <xsl:template match="/"> <xsl:for-each select="Tutorial/AuthorList/Author"> <xsl:value-of select="Name" /> </xsl:for-each> </xsl:template> When the processor starts its work, it begins at the root node of the source document (in your case Tutorial.xml) and tries to find a template that matches that root node. You've provided one for it here, so this is the template that gets used to generate the output of the transformation. This template tells the processor to find all the Author elements within the AuthorList within the Tutorial document element of Tutorial.xml, then, for each of them, give the Name element child of that Author. However, in Tutorial.xml, the Author elements don't have Name element children. So for each of the Author elements, you generate nothing. And the output is therefore empty. In other words, this "EXTRA STUFF" template is overriding everything else in your stylesheet because it matches the root node of the source document, and completely determines the result of the transformation. I'm not sure what you wanted to achieve with this template. Possibly you wanted to apply templates to the Author elements in Author.xml (rather than copying them), and retrieve their Name element children in that way. To do so, apply templates rather than copying the Author elements, in a different mode than usual ('details' mode, say): <xsl:template match="Author"> <xsl:variable name="id" select="@id" /> <xsl:for-each select="$authors"> <xsl:apply-templates select="key('authors', $id)" mode="details" /> </xsl:for-each> </xsl:template> and then have a template that matches Author elements in 'details' mode, and gives their names: <xsl:template match="Author" mode="details"> <xsl:value-of select="Name" /> </xsl:template> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Writing a stylesheet to c, Kunal H. Parikh | Thread | [xsl] using jsp within xsl, Hanumaiahgari, Srini |
Re: [xsl] Conditional indentation?, Jeni Tennison | Date | Re: [xsl] Getting Attribute names i, Jeni Tennison |
Month |