IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

XSL/XSLT/XPATH XML Discussion :

[XSLT]Problemende creation variable node set


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 176
    Points : 258
    Points
    258
    Par défaut [XSLT]Problemende creation variable node set
    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

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 176
    Points : 258
    Points
    258
    Par défaut
    En fait le problème venait du fait que mon processeur xslt ne gérait pas les fonctions xsl 1.1. Le problème a été résolu en intallant la dernière version de saxon.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 5
    Dernier message: 02/06/2010, 12h12
  2. [XSLT]Atteindre un node set dans xsl:param
    Par virgul dans le forum XSL/XSLT/XPATH
    Réponses: 4
    Dernier message: 02/10/2006, 11h21
  3. [XSLT] 2.0 et variables node-set
    Par luta dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 24/01/2006, 17h01
  4. [XSLT] incrémenter une variable
    Par nemya dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 26/09/2005, 17h12
  5. [XSLT]prob de variables(xpath) param d'un appel de template
    Par zerax dans le forum XSL/XSLT/XPATH
    Réponses: 15
    Dernier message: 05/04/2005, 15h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo