Define variable and set value
File: Data.xml
<?xml version="1.0"?>
<addressbook>
<address>
<name>
<title>Mr.</title>
<first-name>Jason</first-name>
<last-name>Lee</last-name>
</name>
<street>1234 Main Street</street>
<city>New York</city>
<state>WI</state>
<zip>12345</zip>
</address>
</addressbook>
File: Transform.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:co="http://java2s.com/xslt">
<xsl:variable name="co:company-name"
select="'A Inc'" />
<xsl:variable name="co:copyright"
select="concat('Copyright ?', $co:company-name)" />
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
Mr.
Jason
Lee
1234 Main Street
New York
WI
12345
Related examples in the same category