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 :

Transformation XML en XML [XSLT 1.0]


Sujet :

XSL/XSLT/XPATH XML

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut Transformation XML en XML
    Bonjour,

    Je galère pour modifier un fichier XSLT. J'ai un contenu de XML qui ressemble à ceci :
    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
    33
    34
          <table:table table:name="dvp_code_other_3" table:style-name="dvp_5f_code_5f_other_5f_3">
            <table:table-column table:number-columns-repeated="5" table:style-name="dvp_5f_code_5f_other_5f_3.A"/>
            <table:table-column table:style-name="dvp_5f_code_5f_other_5f_3.F"/>
            <table:table-row table:style-name="dvp_5f_code_5f_other_5f_3.1">
              <table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
                <text:p text:style-name="Table_20_Heading">other</text:p>
              </table:table-cell>
              <table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
                <text:p text:style-name="Table_20_Heading">UYFUR origuh rugh ri rjg krgkr kr krjghkr kg kg hj</text:p>
              </table:table-cell>
              <table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
                <text:p text:style-name="Table_20_Heading">Aucun</text:p>
              </table:table-cell>
              <table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
                <text:p text:style-name="Table_20_Heading">0</text:p>
              </table:table-cell>
              <table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
                <text:p text:style-name="Table_20_Heading">1</text:p>
              </table:table-cell>
              <table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.F1">
                <text:p text:style-name="Table_20_Heading">fichier</text:p>
              </table:table-cell>
            </table:table-row>
            <table:table-row table:style-name="dvp_5f_code_5f_other_5f_3.2">
              <table:table-cell office:value-type="string" table:number-columns-spanned="6" table:style-name="dvp_5f_code_5f_other_5f_3.A2">
                <text:p text:style-name="Table_20_Contents">code</text:p>
              </table:table-cell>
              <table:covered-table-cell/>
              <table:covered-table-cell/>
              <table:covered-table-cell/>
              <table:covered-table-cell/>
              <table:covered-table-cell/>
            </table:table-row>
          </table:table>
    Je souhaiterais obtenir le xml suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <code titre="other" cell2="UYFUR origuh rugh ri rjg krgkr kr krjghkr kg kg hj" cell3="Aucun" cell4="0" cell5="1" cell6="fichier">
    Voici la portion d'xslt pour le moment
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    	<xsl:template match="table:table[starts-with(@table:name, 'dvp_code_')]">
    		<code langage="{substring-before(substring-after(@table:name, 'dvp_code_'), '_')}">
    			<xsl:choose>
    				<xsl:when test="table:table-row[2]">
    					<xsl:attribute name="titre"><xsl:value-of select="table:table-row[1]/table:table-cell/text:p"/></xsl:attribute>
    					<xsl:apply-templates select="table:table-row[2]/table:table-cell/text:p" mode="code"/>
    				</xsl:when>
    				<xsl:otherwise>
    					<xsl:apply-templates select="table:table-row/table:table-cell/text:p" mode="code"/>
    				</xsl:otherwise>
    			</xsl:choose>
    		</code>
    	</xsl:template>
    J'ai essayé avant la fin du when ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    		<xsl:if test="table:table-row[2]/table:table-cell[2]">
    				<xsl:attribute name="cell2"><xsl:value-of select="table:table-row[2]/table:table-cell[2]/text:p"/></xsl:attribute>
    			</xsl:if>
    Mais ça plante. Je ne sais pas quoi faire.

    Est-ce le table:table-cell[2] qui pose souci ?
    Merci

  2. #2
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    Je me répond, mon test devait être de la sorte :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <xsl:if test="table:table-row[2]/table:table-cell[2] != ' ' ">
    				<xsl:attribute name="cell2"><xsl:value-of select="table:table-row[2]/table:table-cell[2]/text:p"/></xsl:attribute>
    			</xsl:if>
    Il m manquait un vrai test de type
    != ' '
    ou autre.

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

Discussions similaires

  1. Transformer un fichier XML en SVG
    Par LEK dans le forum ASP
    Réponses: 2
    Dernier message: 05/07/2005, 21h52
  2. Réponses: 4
    Dernier message: 23/06/2005, 12h44
  3. [XSLT][XSD>XML]transformer xsd en xml avec xslt
    Par émile-henri dans le forum XSL/XSLT/XPATH
    Réponses: 7
    Dernier message: 14/06/2005, 15h06
  4. [XSL] Transformation de document xml
    Par youbyoub dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 11/04/2005, 16h13
  5. transformer un fichire Xml en pdf
    Par SuperFoustan dans le forum XML/XSL et SOAP
    Réponses: 3
    Dernier message: 21/02/2003, 11h45

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