Re: [XSLT] Sélectionner les attributs d'un espace de noms particulier
Eric van der Vlist <[email protected]>
| Newsgroups | gmane.text.xml.french.tech |
|---|---|
| Organization | Dyomedea (http://dyomedea.com) |
| Message-ID | <[email protected]> |
Le mercredi 08 novembre 2006 à 10:12 +0100, Stephane Bortzmeyer a écrit : > On Wed, Nov 08, 2006 at 12:09:33AM +0100, > Eric van der Vlist <[email protected]> wrote: > > > <xsl:template match="@xhtml:*"> (equivalent ? "attribute;;xhtml:*") > > devrait mieux fonctionner :) ... > > Non, il est accepté mais il ne semble rien "matcher", le template par > défaut s'exécute à la place (testé avec xsltproc et sablotron). > > J'ai essayé aussi "attribute::xhtml:*" et cela donne le même résultat > (ce qui est logique). Est-ce que vous avez bien tenu compte du fait que l'espace de noms par défaut ne s'appliqua pas aux attributs? match="@xhtml:*" s'applique uniquement aux attributs dont l'espace de noms est explicitement définit par un préfixe. Si vous vous intéressez aux attributs tels que src dans <img xmlns="http://www.w3.org/1999/xhtml" src="foo.png"/>, il faut écrire match="xhtml:*/@*[namespace-uri()='']" ! Si vous voulez vous en convaincre, essayer la transformation : <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0"> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{name()}" namespace="{namespace-uri()}">n'importe quel attribut</xsl:attribute> </xsl:template> <xsl:template match="@xhtml:*"> <xsl:attribute name="{name()}">espace de noms XHTML</xsl:attribute> </xsl:template> <xsl:template match="xhtml:*/@*[namespace-uri()='']"> <xsl:attribute name="{name()}">attribut sans préfixe dans l'espace de noms XHTML</xsl:attribute> </xsl:template> </xsl:stylesheet> Sur le document : <?xml version="1.0" encoding="UTF-8"?> <foo xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:bar="http://ns.xmlfr.org/exemple/" xhtml:foo="bar" foo="bat" bar:foo="baz"/> Cordialement, Eric van der Vlist > -- > Devenez redacteur <XML>fr et contribuez au developpement du > xml francophone (http://xmlfr.org/infos/redacteurs/) ! > > Liste de diffusion "[email protected]" (http://xmlfr.org). > > Cette liste est a votre disposition pour discuter en francais de > tout sujet technique lie a XML. > > Pour resilier votre abonnement, envoyez un message contenant > la commande "unsubscribe" a [email protected] > (mailto:[email protected]?Subject=unsubscribe) > > -- GPG-PGP: 2A528005 Le premier annuaire des apiculteurs 100% XML! http://apiculteurs.info/ ------------------------------------------------------------------------ Eric van der Vlist http://xmlfr.org http://dyomedea.com (ISO) RELAX NG ISBN:0-596-00421-4 http://oreilly.com/catalog/relax (W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema ------------------------------------------------------------------------ -- Attached file included as plaintext by Ecartis -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBFUaPODvn+ZCpSgAURArwnAJwOpY0S5gnkZRGiL4I+X+BJf0IEMQCeOZ0r z1lm0pnzfrgktlTWiamzdy8= =tWmT -----END PGP SIGNATURE-----