Reputation: 20725
I am creating a table with one entry that looks like the following in XSLT 2.0:
<td class="brand">
<a href="{basic/@brand}" title="View {basic/@brand_name} information">
<xsl:copy-of select="basic/@brand_name"/>
</a>
</td>
It seems to be correct to me... but the resulting HTML looks like this:
<td class="brand">
<a href="path-to-brand/brand/123" brand_name="Coca-Cola" title="View Coca-Cola information"></a>
</td>
As we can see, the brand name was added as an attribute with the value of the attribute just like in the title.
What I was expecting is this:
<td class="brand">
<a href="path-to-brand/brand/123" title="View Coca-Cola information">Coca-Cola</a>
</td>
Is there something I'm doing wrong or is Qt that bogus?
Upvotes: 1
Views: 31
Reputation: 23637
You mixed copy-of
which copies entire node-sets to the result tree with value-of
which copies the string-value of the node. It will work if you replace:
<xsl:copy-of select="basic/@brand_name"/>
with
<xsl:value-of select="basic/@brand_name"/>
Upvotes: 1
Reputation: 31610
copy-of copies the entire attribute and since it still can it appends it to the element. Since you want just to write the value you should use
<xsl:value-of select="basic/@brand_name"/>
Upvotes: 2