Namespace alias : Namespace « XSLT stylesheet « XML






Namespace alias


File: Data.xml

<test xmlns:snee="http://www.java2s.com/dtds/test"
      xmlns:demo2s="http://www.demo2s.com/dtds/test"
      xmlns:domain="http://www.domain.com/dtds/test">
this is a test.
</test>


File: Transform.xslt 
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xslt="output.xsl">

  <xsl:param name="variable-name">v</xsl:param>
  <xsl:param name="default-value" />
  <xsl:output indent="yes" />

  <xsl:namespace-alias stylesheet-prefix="xslt" result-prefix="xsl" />

  <xsl:template match="/" name="main">
    <xslt:stylesheet version="1.0">
      <xslt:variable name="{$variable-name}">
        <xsl:value-of select="$default-value" />
      </xslt:variable>
    </xslt:stylesheet>
  </xsl:template>

</xsl:stylesheet>

Output:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:variable name="v"/>
</xsl:stylesheet>

 








Related examples in the same category

1.namespace axis
2.Deal with the node with namespace