if i'm trying to understand xslt where i'm stuck at a place where i want to add an element with a fixed value and a dynamic attribute
input:
<newsItem parentGUID="fakeGuid">
</newsItem>
desired output:
<newsItem>
<parent Key="fakeGuid">News</parent>
<newsItem>
Current Xslt (value isn't in the actual output)
<xsl:template match="NewsItem">
<xsl:element name="Parent">
<xsl:attribute name="Key">
<xsl:value-of select="@parentGUID"/>
</xsl:attribute>
<xsl:value-of select="News"/>
</xsl:element>
</xsl:template>
Can someone point me out what i'm doing wrong?
Kind regards
<parent>instead of<xsl:element name="parent">(unless you just really like typing and making the XSLT harder to read). Generally, the only time to usexsl:elementis if the name is dynamically constructed.<xsl:template match="NewsItem">will NOT match<newsItem>.