Subject: Re: [xsl] Newbie question - does the built-in template rules output the attribute node? From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 17 Oct 2005 16:53:43 -0400 |
Another newbie question, this time about XSL itself rather than xsltproc. (sorry!)
Quoting from XSLT for Dummies, it says:
------------------------------------8<---------------------------------- For text and attribute nodes, a built-in template rule copies their text through into the result tree: <xsl:template match="text()|@*"> <xsl:value-of select="."/> </xsl:template> In this rule, the match pattern returns all text nodes with text() and all attribute nodes with @*. The xsl:value-of instruction then transforms the current node to the result tree as text.
------------------------------------8<----------------------------------
However, if I run this against a blank stylesheet:
------------------------------------8<---------------------------------- <!-- miniscore.xml --> <score id="1">Text here <film name="I should see this attribute">A Little Princess</film> <composer>Patrick Doyle</composer> <year>1995</year> <grade>100</grade> </score>
------------------------------------8<---------------------------------- The result is:
------------------------------------8<---------------------------------- <?xml version="1.0" encoding="utf-8"?>Text here A Little Princess Patrick Doyle 1995 100 ------------------------------------8<----------------------------------
However, since the attribute node name is supposedly matched, I expected:
------------------------------------8<---------------------------------- <?xml version="1.0" encoding="utf-8"?>Text here I should see this attribute A Little Princess Patrick Doyle 1995 100 ------------------------------------8<----------------------------------
Can anyone tell me where I'm wrong?
<xsl:template match="*"> <xsl:apply-templates select="child::*"/> </xsl:template>
<xsl:template match="*"> <xsl:apply-templates select="child::* | attribute::*"/> </xsl:template>
I hope that helps, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Newbie question - does the bu, Paul Moloney | Thread | [xsl] Defaulting values in xsl, Mini Vatsala |
RE: [xsl] xsl:sort blocks of elemen, Michael Kay | Date | [xsl] merging the contents of conse, Annmarie Rubin \(anr |
Month |