Bonjour,

D'après mon livre (xslt fondamental) le code ci dessous devrait marcher :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
  <xsl:output method='html' encoding='ISO-8859-1' />
 
  <xsl:template name="test">
    <xsl:variable name="result">
      <first>
        <xsl:value-of select="'toto'"/>
      </first>
      <second>
        <xsl:value-of select="'titi'"/>
      </second>
    </xsl:variable>
    <xsl:copy-of select="$result"/>
  </xsl:template>
 
  <xsl:variable name="testIt">
    <xsl:call-template name="test"/>
  </xsl:variable>
 
  <xsl:template match="/"> 
    <html>
      <head>
      </head>
      <body>
        <xsl:value-of select="$testIt/first"/>
      </body>
    </html>
  </xsl:template>
 
</xsl:stylesheet>
le but est de récupérer un node set dans la variable 'testIt' avec 2 childs (first et second), mais quand j'essaye de générer le html, cooktop me dit
ERROR: Description: Expression must evaluate to a node-set.

-->$testIt<--/first
Ci dessous le log d'xsltproc -v :
creating dictionary for stylesheet
reusing dictionary from test.xsl for stylesheet
Added namespace: xsl mapped to http://www.w3.org/1999/XSL/Transform
xsltPrecomputeStylesheet: removing ignorable blank node
xsltParseStylesheetProcess : found stylesheet
Registering global variable testIt
Defining global variable testIt
xsltCompilePattern : parsing '/'
xsltCompilePattern : parsed /, default priority 0.500000
added pattern : '/' priority 0.500000
parsed 2 templates
Resolving attribute sets references
Registered 0 modules
Creating sub-dictionary from stylesheet for transformation
reusing transformation dict for output
Registering global variables
Registering global variables from test.xsl
Evaluating global variable testIt
reusing transformation dict for RVT
call-template: name test
applying template 'test'
Registering variable result
Building variable result
Evaluating variable result
reusing transformation dict for RVT
xsltApplyOneTemplate: copy node first
xsltValueOf: select 'toto'
xsltCopyTextString: copy text toto
xsltValueOf: result toto
xsltApplyOneTemplate: copy node second
xsltValueOf: select 'titi'
xsltCopyTextString: copy text titi
xsltValueOf: result titi
Object is an XSLT value tree :
1 ELEMENT first
ELEMENT second
xsltCopyOf: select $result
Lookup variable result
found variable result
xsltCopyOf: result is a result tree fragment
xsltCopyTextString: copy text toto
xsltCopyTextString: copy text titi
call-template returned: name test
Object is an XSLT value tree :
1 ELEMENT first
ELEMENT second
xsltProcessOneNode: applying template '/' for /
xsltApplyOneTemplate: copy node html
xsltApplyOneTemplate: copy node head
xsltApplyOneTemplate: copy node body
xsltValueOf: select $testIt/first
Lookup variable testIt
found variable testIt
XPath error : Invalid type
runtime error: file test.xsl line 27 element value-of
xsltValueOf: text copy failed
freeing transformation dictionnary
no result for CardImage037A.xml
freeing dictionary from stylesheet
Si vous avez une idée.... je suis preneur.

Merci d'avance