[XPATH] Mauvais espace de nom pour les fonctions XPath?
Bonjour à tous,
J'ai besoin d'utiliser la fonction document-uri ou base-uri pour récupérer le nom du fichier XML actuellement transformé par le XSL.
Ces 2 fonctions appartiennant à XPath, j'ai donc ajouté le namespace correspondant en début de fichier xsl:
Mon fichier XSL:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2004/07/xpath-functions" >
<xsl:output method="text"/>
<xsl:template match=".......">
<xsl:call-template name="xyz"/>
</xsl:template>
<xsl:template name="xyz">
Doc=<xsl:value-of select="fn:document-uri(.)"/>
</xsl:template>
</xsl:stylesheet> |
Le problème, c'est qu'après avoir ajouté ce namespace, lors de la transformation, XMLSpy (et IE) me disent :
"XSL transformation failed due to following error:
Namespace 'http://www.w3.org/2004/07/xpath-functions' does not contain any functions."
J'ai d'abord cru à une mauvaise syntaxe lors de l'ajout du namespace, donc pour vérifier j'ai essayé d'ajouter d'autres namespaces (inutiles pour moi ici).
Ceci fonctionne si on enlève l'appel à la fonction fn:document-uri :
Code:
1 2 3 4 5
| <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
... |
Mais le code ci-dessous ne fonctionne pas:
Code:
1 2 3 4 5
| <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2004/07/xpath-functions"> |
Il retourne la même erreur.
Et en effet, en regardant le fichier http://www.w3.org/2004/07/xpath-functions, on voit bien qu'il est très différent de "http://www.w3.org/1999/XSL/Transform" et xmlns:xs="http://www.w3.org/2001/XMLSchema".
Par contre je ne trouve pas de "fichier de description de fonctions" (je ne sais pas si ça s'appelle comme ça) qui pourrait aller pour XPath.
W3C me renvoit à xmlns:fn="http://www.w3.org/2004/07/xpath-functions" ou "http://www.w3.org/2005/xpath-functions" (qui ne marche pas, c'est bizarre)
Merci d'avance de votre aide...