Subject: Re: [xsl] multiple XML tags -> single output From: Mike Brown <mike@xxxxxxxx> Date: Thu, 28 Dec 2000 01:05:08 -0700 (MST) |
zbrown@xxxxxxxxxxxxx wrote: > Well, I've tried but it doesn't seem to work... that part of the XSL file > doesn't produce any output at all when I use concat(). concat() *will* work, if you fix the XPath expressions. The example I posted was slightly wrong because in my haste I didn't look at your original XML; I made the mistake of assuming that the person who had suggested multiple <xsl:value-of>s had the correct expressions. I apologize for not giving you a perfect answer. The idea was to show you how to produce the text you wanted using one xsl:value-of instruction, not to do your homework for you. > <xsl:template match="a"> > <a href="<xsl:value-of select="@href"/>"><xsl:value-of select="."/></a> > </xsl:template> This is wrong because XSL is XML, and XML has rules of well-formedness that you violated when you said that an element (the first xsl:value-of) was another element's attribute value (the href="..."). XSLT offers a convenient syntax for calculating the values of attributes in a literal result element... curly braces: <a href="{@href}"> <xsl:value-of select="."/> </a> A more verbose syntax is to create the literal result element and add its attribute via a separate instruction: <a> <xsl:attribute name="href"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:value-of select="."/> </a> You are not going to get very far if you think of <xsl:value-of> as a macro that results in text string substitution. You would do well to learn what XSLT is really doing. Nodes are not tags, and tags are not literal text strings that you are serially pasting together to produce the output you want. - Mike ____________________________________________________________________ Mike J. Brown, software engineer at My XML/XSL resources: webb.net in Denver, Colorado, USA http://skew.org/xml/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] multiple XML tags -> sing, Jiri Jirat | Thread | Re: [xsl] multiple XML tags -> sing, David Carlisle |
RE: [xsl] Sortable data-table, Roel Mertens | Date | Re: [xsl] multiple XML tags -> sing, Kevin McCarthy |
Month |