Re: Expression XPath uniquement à but de localisation
"JANDIA Cyril" <[email protected]>
| Newsgroups | gmane.text.xml.french.tech |
|---|---|
| Message-ID | <0F024D01CFF65D479611485678150B37014905F3@saihopar01mx01.asnet.accorservices.net> |
> -----Original Message----- > From: [email protected] [mailto:[email protected]] > On Behalf Of Adrien Kmiecik > Sent: vendredi 24 mars 2006 16:47 > To: [email protected] > Subject: [xml-tech] Expression XPath uniquement à but de localisation > > Bonjour, > > Comment puis-je vérifier qu'une expression XPath 1.0 ne puisse renvoyer > qu'un résultat de type Node-set ? > En d'autres termes, je voudrais analyser l'expression et m'assurer > qu'elle ne retourne ni booléen, ni chaîne ou valeur numérique... > > Si quelqu'un connaissait une regle simple et générique... > > Merci d'avance...! Bonjour, Si vous utilisez MSXML, c'est assez aisé, par exemple : <?xml version="1.0" encoding="iso-8859-1" ?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:util="urn:mycompany.com:xslt-util" version="1.0"> <xsl:output method="text" encoding="iso-8859-1" /> <msxsl:script language="JScript" implements-prefix="util"><![CDATA[ function isnodeset(expr) { if(typeof(expr) == "number") return false; if(typeof(expr) == "boolean") return false; if(typeof(expr) == "string") return false; return true; } ]]></msxsl:script> <xsl:variable name="myboolean" select="true()" /> <xsl:variable name="mynumber" select="123456" /> <xsl:variable name="mystring" select="'foobar'" /> <xsl:variable name="mynodeset" select="/*" /> <xsl:template match="/"> myboolean : <xsl:value-of select="util:isnodeset($myboolean)" /> mynumber : <xsl:value-of select="util:isnodeset($mynumber)" /> mystring : <xsl:value-of select="util:isnodeset($mystring)" /> mynodeset : <xsl:value-of select="util:isnodeset($mynodeset)" /> </xsl:template> </xsl:transform> Cordialement, Cyril Jandia ______________________________________________________________________________________________________________________________ This email, the information contained within and any files transmitted with it (herein after referred as "the message") are confidential. It is intended solely for the addressees and access to this message by any other person is not permitted. If you are not the named addressee, please send it back immediately to the sender and delete it. Unauthorized disclosure, publication, use, dissemination, forwarding, printing or copying of this message, either in whole or in part, is strictly prohibited. Emails are susceptible to alteration and their integrity cannot be guaranteed. Our company shall not be liable for this message if modified or falsified.