How to tranform an XML tag value to an atrribute value

S

su

HI,

I want to tranform following
<extends>/public/a1.xml</extends>

into
<extends xlink:type="simple" xlink:href="/public/a1.xml"></extends>

using XSL.

How does the code should look like in XSL file??

Sumit
 
M

Martin Honnen

su said:
I want to tranform following
<extends>/public/a1.xml</extends>

into
<extends xlink:type="simple" xlink:href="/public/a1.xml"></extends>

using XSL.

<xsl:template match="extends">
<xsl:copy>
<xsl:attribute name="xlink:type"

namespace="http://www.w3.org/1999/xlink">simple</xsl:attribute>
<xsl:attribute name="xlink:href"

namespace="http://www.w3.org/1999/xlink"><xsl:value-of
select="."/></xsl:attribute>
</xsl:copy>
</xsl:template>

is one way that is rather generic, it might suffice to use the much shorter

<xsl:template match="extends">
<extends
xlink:type="simple"
xlink:href="{.}"
xmlns:xlink="http://www.w3.org/1999/xlink" />
</xsl:template>
 
S

su

Hi Martin, Thanks for the solution,
In the mean time I wrote this code and it worked:-

<xsl:template match="extends">
<xsl:variable name="xdbextend">
<xsl:value-of select="."/>
</xsl:variable>
<extends xlink:href="{$xdbextend}" xlink:type="simple"
xlmns:xlink="http://www.w3.org/1999/xlink">>
</extends>

Thanks .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top