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

Bibliothèques et frameworks PHP Discussion :

[XSL][PHP 5.2] Transformation XSL ne fonctionne plus


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    lr
    lr est déconnecté
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    338
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2003
    Messages : 338
    Points : 114
    Points
    114
    Par défaut [XSL][PHP 5.2] Transformation XSL ne fonctionne plus
    Salut,

    J'utilise ce code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    $xslt = new xsltProcessor ( );
    $xslt->importStyleSheet ( DomDocument::load ( "/work/myProject/data/transform/transformSchema.xsl" ) );
    $out = $xslt->transformToXML( DomDocument::loadXML( file_get_contents ( "/work/myProject/config/schema.xml" ) ) );
    file_put_contents ( $schema_filename, $out );
    pour appliquer une transformation xsl à un fichier xml. Ca fonctionne très bien avec PHP 5.0.4. Mais avec PHP 5.2.4, j'ai plein de warnings et le résultat est un fichier vide :
    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): runtime error: file /work/myProject/data/transform/transformSchema.xsl line 6 element copy in /work/myProject/testTransformation.php on line 4

    Warning: XSLTProcessor::transformToXml(): Attribute nodes must be added before any child nodes to an element. in /work/myProject/testTransformation.php on line 4
    Voilà le début de mon fichier xsl et le début de mon fichier xml.

    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
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
    	<!--Je sais pas a quoi ca sert-->
        <xsl:template match="@*|node()">
    		<xsl:copy>
    			<xsl:apply-templates select="@*|node()" />
    		</xsl:copy>
    	</xsl:template>
     
    	<!--MODIFIER LES NOEUDS "TABLE"-->
    	<!-- ajouter un attribut "phpName" -->
    	<xsl:template match="table">
    		<!--NE PAS LIMITER AUX TABLES PREFIXEES CAR IL Y A AUSSI LES TABLES GEOMETRIQUES<xsl:if test="starts-with(@name,'t_')">-->
    			<xsl:copy>
    				<xsl:attribute name="phpName">
    					<xsl:call-template name="phpNameForTableSpecial">
    						<xsl:with-param name="tableName" select="@name" />
    					</xsl:call-template>
    				</xsl:attribute>
    				<xsl:apply-templates select="@*|node()" />
    			</xsl:copy>
    		<!--</xsl:if>-->
    	</xsl:template>
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <database name="propel" package="lib.model" defaultIdMethod="native">
     
      <table name="adresses_geo">
        <column name="adresse_id" type="INTEGER" required="true" primaryKey="true" />
        <column name="rue" type="VARCHAR" />
        <column name="numero" type="VARCHAR" />
        <column name="npa" type="INTEGER" />
        <column name="localite" type="VARCHAR" />
        <column name="commune_id" type="INTEGER" required="true" />
        <column name="position" type="" />
        <column name="adresse_manuelle" type="BOOLEAN" required="true" default="" />
        <column name="quartier_id" type="INTEGER" />
        <column name="lot" type="VARCHAR" />
        <index name="adresses_geo_position_idx">
          <index-column name="position" />
        </index>
    Il faudrait vraiment que ça puisse marcher comme avant

    Merci d'avance
    Lilian

  2. #2
    Membre régulier Avatar de krapno
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    180
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 180
    Points : 74
    Points
    74
    Par défaut
    Bonjour,

    Je rencontre la même difficulté (semble-t-il) que vous.
    J'ai mis à jour PHP et mes sites ne fonctionnent plus correctement.
    Par ailleurs je trouve que la transformation prend un temps fou

    Votre sujet date un peu, peut-être avez-vous trouvé d'où provenait le problème?

    Cordialement,
    Krapno

  3. #3
    lr
    lr est déconnecté
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    338
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2003
    Messages : 338
    Points : 114
    Points
    114
    Par défaut
    Salut,

    J'ai pu régler le problème en modifiant ma feuille xsl. J'ai du supprimer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <xsl:template match="@*|node()">
    		<xsl:copy>
    			<xsl:apply-templates select="@*|node()" />
    		</xsl:copy>
    	</xsl:template>
    Bon courage

  4. #4
    Membre régulier Avatar de krapno
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    180
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 180
    Points : 74
    Points
    74
    Par défaut
    Bonjour,

    J'ai résolu mon problème également avec une correction vraiment toute bête

    En fait je faisait appel à un template via
    <xsl:call-template name="lenom">
    <xsl:with-param name="lepara1" select="$val1" />
    <xsl:with-param name="lepara2" select="$val2" />
    </xsl:call-template>

    Et j'avais une erreur dans mon template, j'avais déclaré une variable AVANT de lister les PARAM!

    INCORRECT:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <xsl:template name="lenom">
    	<xsl:variable name="mavariable1" select="'dutexte'" />
    	<xsl:param name="lepara1" select="$valeur1" />
    	<xsl:param name="lepara2" select="$valeur2" />
    </xsl:template>
    CORRECT:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <xsl:template name="lenom">
    	<xsl:param name="lepara1" />
    	<xsl:param name="lepara2" />
    	<xsl:variable name="mavariable1" select="'dutexte'" />
    </xsl:template>
    Cordialement,
    Krapno

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

Discussions similaires

  1. Différence transformations XSL+XML et XSL+XML+PHP
    Par vir2al_killer dans le forum XML/XSL et SOAP
    Réponses: 1
    Dernier message: 21/05/2007, 14h16
  2. [XSL][PHP] Attribut généré par xsl:attrbute
    Par mamat- dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 29/07/2005, 11h08
  3. PHP dans XML ou XSL
    Par mathieu dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 31/08/2003, 21h07
  4. Transformation XSL et caractères spéciaux
    Par Sylvain Leray dans le forum XMLRAD
    Réponses: 4
    Dernier message: 28/04/2003, 10h38
  5. XML + XSL + PHP
    Par ZzZerf dans le forum XSL/XSLT/XPATH
    Réponses: 5
    Dernier message: 21/03/2003, 15h54

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