namespace_3-input.xml
<?xml version="1.0"?>
<price>23.50</price>
namespace_3-stylesheet.xsl
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output
indent="yes"/>
<xsl:template
match="price">
<xsl:element
name="price">
<xsl:attribute
name="xsi:type" select="'xs:decimal'" namespace="http://www.w3.org/2001/XMLSchema-instance"/>
<xsl:namespace
name="xs" select="'http://www.w3.org/2001/XMLSchema'"/>
<xsl:value-of
select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
namespace_3-output.xml
<?xml version="1.0"?>
<price
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:decimal">23.50</price>
The above example show how xsl:namespace can be used to create the namespace for a QName as part of content. In our example, a QName, "xs:decimal", is the value of the "xsi:attribute". We have a similar example in the spec. See my tutorial xsl:namespace in XSLT 2.0.
Updated 2009-03-19