EnexoOnoma
EnexoOnoma

Reputation: 8836

XSLT transformation to move an element into another or set it as attribute

What is a XSLT template that will get the <title></title> that contains the name of a blog and put it in every <entry></entry> or as an attribute in every <entry> ?

from

<feed>
<title>title of feed</title>
<entry>...</entry>
<entry>...</entry>
</feed>

to

<feed>
<entry><blog>title of feed</blog>...</entry>
<entry><blog>title of feed</blog>...</entry>
</feed>

or

<feed>
<entry blog="title of blog">...</entry>
<entry blog="title of blog">...</entry>
</feed>

Upvotes: 0

Views: 100

Answers (1)

Laurent Legrand
Laurent Legrand

Reputation: 1144

for the attribute solution, something like this should work :

<xsl:template match="entry">
    <entry blog="{/feed/title}">
        <xsl:apply-templates/>
    </entry>
</xsl:template>

Upvotes: 2

Related Questions