I am trying to transform 1 XML document to another using XSLT. I want to call the value from my source XML to the element in my result XML as the value of an attribute.
Source code-
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
Want output as-
<root>
<singer name=”Bob Dylan”>
<!--this name is the value of "artist"-->
<title>Empire Burlesque</title>
</singer>
<singer name=”Bonnie Tyler”/>
<title>Hide your heart</title>
</singer>
</root>
I don’t even know whether it is possible or not using XSLT. Please advise.