> -----Original Message-----
> From: xml-tech-bounce@xmlfr.org [mailto:xml-tech-bounce@xmlfr.org]
> On Behalf Of Adrien Kmiecik
> Sent: vendredi 24 mars 2006 16:47
> To: xml-tech@xmlfr.org
> 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.
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (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 xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Received on Fri Mar 24 17:46:54 2006