title: in XSLT, How to find the namespace of an XML element attribute?
body: <p>Trying to use the function namespace-uri to find the namespace of an attribute.</p>
  
  <pre><code>&lt;xsl:template match="xse:seeAlso"&gt;
  &lt;xsd:xmlEntityReference xml:space="preserve"&gt;
      &lt;xsl:value-of select="namespace-uri()"/&gt;#E/&lt;xsl:value-of select="@ref"/&gt;
  &lt;/xsd:xmlEntityReference&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>I want the namespace for the "ref" attribute of the element. Any tip?</p>
  
  <p><strong>UPDATE 1</strong> To make it clearer, I want the namespace of the element referenced by the "ref" attribute. Sorry for any confusion.</p>
  
  <p><strong>UPDATE 2</strong> @empo: This is snippet of one of the schemas</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema xmlns:html="http://www.w3.org/1999/xhtml"
              xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
              xmlns:xse="http://schemas.microsoft.com/wix/2005/XmlSchemaExtension"
        targetNamespace="http://schemas.microsoft.com/wix/IIsExtension"
                  xmlns="http://schemas.microsoft.com/wix/IIsExtension"&gt;
  
      &lt;xs:import namespace="http://schemas.microsoft.com/wix/2006/wi" /&gt;
  
      &lt;xs:element name="Certificate"&gt;
          &lt;xs:annotation&gt;
              &lt;xs:documentation&gt;
                  Used to install and unintall certificates.
              &lt;/xs:documentation&gt;
              &lt;xs:appinfo&gt;
                  &lt;xse:seeAlso ref="CertificateRef"/&gt;
              &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
          &lt;xs:complexType&gt;
              &lt;!-- Cut off --&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
      &lt;xs:element name="CertificateRef"&gt;
          &lt;xs:annotation&gt;
              &lt;xs:documentation&gt;
                  ...
              &lt;/xs:documentation&gt;
              &lt;xs:appinfo&gt;
                  &lt;xse:seeAlso ref="Certificate"/&gt;
              &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
          &lt;xs:complexType&gt;
              &lt;!-- Cut off --&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>This is a sample of the transform</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                  xmlns:xsd="http://schemas.xsddoc.codeplex.com/schemaDoc/2009/3"
                  xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5"
                  xmlns:xlink="http://www.w3.org/1999/xlink"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
                  xmlns:xse="http://schemas.microsoft.com/wix/2005/XmlSchemaExtension"
                  xmlns:xhtml="http://www.w3.org/1999/xhtml"
                  exclude-result-prefixes="msxsl xs xse"&gt;
    &lt;xsl:output method="xml" indent="yes"/&gt;
  
    &lt;xsl:param name="parentItemType"/&gt;
    &lt;xsl:param name="parentItemNamespace"/&gt;
    &lt;xsl:param name="parentItemUri"/&gt;
  
    &lt;xsl:param name="currentItemType"/&gt;
    &lt;xsl:param name="currentItemNamespace"/&gt;
    &lt;xsl:param name="currentItemUri"/&gt;
  
    &lt;xsl:template match="*"&gt;
      &lt;xsl:apply-templates select="xs:annotation" /&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="xse:seeAlso"&gt;
      &lt;xsd:xmlEntityReference xml:space="preserve"&gt;
          &lt;xsl:value-of select="namespace-uri()"/&gt;#E/&lt;xsl:value-of select="@ref"/&gt;
      &lt;/xsd:xmlEntityReference&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>