Article View: fr.comp.text.xml
Article #9112Re: [Schema et XPath] namespace en valeur d'attribut
From: Joel Fillon
Date: Wed, 30 May 2001 13:03
Date: Wed, 30 May 2001 13:03
31 lines
2167 bytes
2167 bytes
> A vue de nez : 1) extraire le prefixe avec substring-before(), 2)
> chercher dans l'axe namespace le noeud dont local-name() renvoie le
> prefixe extrait en 1), 3) utilisez namespace-uri sur ce noeud pour
> recuperer et comparer l'uri. Donc quelque chose comme :
>
> <!-- Dans le contexte de l'element element -->
> <xsl:variable name="p" select="substring-before(@type,':')"/>
> <xsl:variable name="n" select="namespace::*[local-name()=$p"/>
> <xsl:variable name="u" select="namespace-uri($n)"/>
>
> Et tu devrais pouvoir comparer $u a l'uri xs.
>
> (Est-il utile de preciser que je n'ai pas teste ? :-).
>
> -- Alain.
J'ai teste :oD
En fait, inutile d'utiliser namespace-uri(), car l'uri est la
valeur du noeud n (son prefixe etant xmlns, qqch comme
<xmlns:xsd>http://www.w3.org/2000/10/XMLSchema</xmlns:xsd>).
Il suffit donc d'ecrire :
<xsl:template match="xsd:element">
<xsl:variable name="p" select="substring-before(@type,':')"/>
<xsl:variable name="n" select="//namespace::*[local-name()=$p]"/>
<xsl:if test="$n='http://www.w3.org/2000/10/XMLSchema'">
C'est un type predefini dans les schemas.
</xsl:if>
</xsl:template>
Joel
Technical Details
Message-ID:
<3B14EF90.2D923AA6@sophia.inria.fr>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!skynet.be!fr.clara.net!heighliner.fr.clara.net!teaser.fr!enst!univ-angers.fr!univ-rennes1.fr!irisa.fr!news-rocq!news-sop.inria.fr!not-for-mailReferences:
<3B14AEFD.74AB37D4@sophia.inria.fr> <wy4ru3ruk3.fsf@polya.u-strasbg.fr>Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII-7-bit X-Google-Thread: 114f60,7abfc4ebedcb9df4 X-Google-Attributes: gid114f60,public X-Google-ArrivalTime: 2001-05-30 06:19:03 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!skynet.be!fr.clara.net!heighliner.fr.clara.net!teaser.fr!enst!univ-angers.fr!univ-rennes1.fr!irisa.fr!news-rocq!news-sop.inria.fr!not-for-mail From: Joel Fillon <Joel.Fillon@sophia.inria.fr> Newsgroups: fr.comp.text.xml Subject: Re: [Schema et XPath] namespace en valeur d'attribut Date: Wed, 30 May 2001 15:03:12 +0200 Organization: INRIA Sophia Antipolis Lines: 31 Message-ID: <3B14EF90.2D923AA6@sophia.inria.fr> References: <3B14AEFD.74AB37D4@sophia.inria.fr> <wy4ru3ruk3.fsf@polya.u-strasbg.fr> NNTP-Posting-Host: flambis.inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.75 [fr] (Windows NT 5.0; U) X-Accept-Language: fr-FR,en