[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: another xpath question

Subject: RE: another xpath question
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 7 Jan 2002 16:35:23 -0000
xref tag xsl
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.