Subject: RE: [xsl] another xpath question From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Mon, 7 Jan 2002 16:35:23 -0000 |
> If I have the following simplified XML snippet: > > === > <xref xrefid="AA140110301W10AA" xidtype="TEXT"/> > <title> > Renew LP Piston Seal (Fig 5.5.1 > <xref xrefid="F5.5.1" xidtype="FIGURE">) </xref> > </title> If I modify the title template to: > > <xsl:template match="title"> > <xsl:value-of select="."/> > <xsl:apply-templates/> > </xsl:template> > > I get the output: > > (xref) > Renew LP Piston Seal (Fig 5.5.1) > (xref) The <xsl:value-of> outputs the string value of the <title> element, which is the concatenation of all the text it contains, that is "Renew LP Piston Seal (Fig 5.5.1)". The <xsl:apply-templates/> then processes all the child nodes of the <title>: a text node, an <xref> element, and another text node. I guess you have a template rule that ensures text nodes produce no output, so the only output is from processing the <xref> node, which is "(xref)". > > Whereas the output I want is > > (xref) > Renew LP Piston Seal (Fig 5.5.1(xref)) //the (xref) will be > a graphic... Remove the call on <xsl:value-of>, and use the default template rule for text nodes, which outputs the text content of the node. > And, why will > it not match the inner <xref> without calling > apply-templates? I thought it > would look for a template match whenever it encountered a tag. It won't encounter a "tag" (you should say "element" or "node", you'll understand the specs more easily if you learn the correct jargon) unless you tell it to look for that element or node. The call on xsl:apply-templates is asking it do to so. Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] another xpath question, David Carlisle | Thread | RE: [xsl] another xpath question, Andrew Welch |
Re: [xsl] another xpath question, David Carlisle | Date | Re: [xsl] xpath test suite?, Carmelo Montanez |
Month |