namespace-uri-for-prefix

O namespace associado a um prefixo, no escopo de um elemento

Descrição

A função fn:namespace-uri-for-prefix devolve o namespace ligado a $prefix, usando os namespaces em escopo de $element. Se $prefix for uma string vazia ou a sequência vazia, a função devolve o namespace padrão, se houver.

Parâmetros

Descrição

prefix:string()

o prefixo a procurar

element:element()

o elemento que define o escopo

Exemplos

Os exemplos abaixo usam este documento de entrada:

<xsl:stylesheet xmlns:pre="http://datypic.com/pre"
                xmlns:unpre="http://datypic.com/unpre">...

<xsl:variable name="in-xml" as="item()*">
  <noNamespace>
       <pre:prefixed xmlns="http://datypic.com/unpre"
                xmlns:pre="http://datypic.com/pre">
         <unprefixed pre:prefAttr="a" noNSAttr="b">123</unprefixed>
       </pre:prefixed>
     </noNamespace>

</xsl:variable>

XPath

Resultado

namespace-uri-for-prefix('', $in-xml)

()

namespace-uri-for-prefix('pre',$in-xml)

()

namespace-uri-for-prefix('pre',$in-xml//pre:prefixed)

http://datypic.com/pre

namespace-uri-for-prefix( '',$in-xml//unpre:unprefixed)

http://datypic.com/unpre

namespace-uri-for-prefix( 'pre',$in-xml//unpre:unprefixed)

http://datypic.com/pre

Veja também