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 :

Ajout balise à une ligne ou fusion de deux lignes


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juillet 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Juillet 2022
    Messages : 4
    Points : 1
    Points
    1
    Par défaut Ajout balise à une ligne ou fusion de deux lignes
    Bonjour,

    Je suis en modification de fichier XSL et débutant !

    Le but du fichier est de créer une nomenclature dans un ERP.

    Exemple de fichier créée automatiquement
    Nom : NOM.PNG
Affichages : 278
Taille : 57,7 Ko


    Nous pouvons voir des articles créée avec un nombre de variable attribué.

    Ce qu'il me manque c'est d'ajouter une balise modify="true" dans la variable ARCTCODPLA si et seulement si la variable TYPEPDM à un valeur = "NON_TOOLBOX"

    Pour ce faire j'ai écris ceci dans le fichier .xsl
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <xsl:if test ="FIELD[@name='TYPEPDM']/@value = 'NON_TOOLBOX'">								
    		<attribute name="ARCTCODPLA" Modify="TRUE" />							
    </xsl:if>

    Malheureusement ça ne m'ajoute pas la balise modify="true" à la variable existante puisque ça me créée une seconde ligne ARCTCODPLA..

    Avez vous des idées pour ajouter directement cette balise à la ligne ? ou alors comment fusionner les deux lignes ?



    Léo

  2. #2
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 551
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    Hello,

    XSL sert à générer des XML.

    Malheureusement nous ne pouvons pas deviner quel genre de XML tu as besoin de générer (ni d'ailleurs, si ce que tu aimerais faire est possible)
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juillet 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Juillet 2022
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    Salut Thelvin,

    Merci pour ta réponse.

    Concrètement le XML que je généré ressemble à ça:

    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
     
     <XML><transactions>
      <transaction date="1311093484" type="EXPORT_NOMENCLATURE_PDM" vaultname="1LIFE">
      <document aliasset="Import XML"><configuration name="Défaut">
      <attribute name="Name" value="JEP10080" />
      <attribute name="TYPEPDM" value="NON_TOOLBOX" />
      <attribute name="ARKTCODART" value="JEP10080" />
      <attribute name="ARCTLIB01" value="ESSAI INDICE PMI" />
      <attribute name="ARCTLIB02" value="" />
      <attribute name="LIBCOMPL" value="" nature="V" langue="AR" />
      <attribute name="ARCTTYPART" value="SE" />
      <attribute name="ARCTCODFAM" value="EP" />
      <attribute name="ARCTCODPL1" value="Matériau &lt;non spécifié&gt;" />
      <attribute name="ARCTCODPLA" value="-" />
      <attribute name="ARCNPDSUNI" value="0.42" />
      <attribute name="ARCNLONGUE" value="" />
      <attribute name="ARCNLARGEU" value="" />
      <attribute name="ARCNEPAISS" value="" />
      <attribute name="NOCNQTECOM" value="" />
      <attribute name="ARCTGTRACE" value="N" />
      <attribute name="ARCJCRE" value="20220707" />
      <attribute name="ARCTUTIMOD" value="EPDM-ADM" />
      <attribute name="ARKTCOMART" value="" />
      <attribute name="ARCTCODPLA" Modify="TRUE" />
      <attribute name="ARITNATURE" value="6" />
      <attribute name="ARCTFATN" value="05" />
      <attribute name="NOCTREPFAB" value="" />
      <attribute name="ARCTUNISTO" value="P" />
      <attribute name="ARCTTRANCH" value="01" />
      <references>
      <document aliasset="Import XML">
      <configuration name="Défaut">
      <attribute name="Name" value="JAC00000" />
      <attribute name="TYPEPDM" value="RECUP_TOP" />
      <attribute name="ARKTCODART" value="JAC00000" />
      <attribute name="ARCTLIB01" value="TEST EXPORT" />
      <attribute name="ARCTLIB02" value="" />
      <attribute name="LIBCOMPL" value="" nature="V" langue="AR" />
      <attribute name="ARCTTYPART" value="PC" />
      <attribute name="ARCTCODFAM" value="AC" />
      <attribute name="ARCTCODPL" value="AISI 304" />
      <attribute name="ARCTCODPLA1" value="-" />
      <attribute name="ARCNPDSUNI" value="0.42" />
      <attribute name="ARCNLONGUE" value="" />
      <attribute name="ARCNLARGEU" value="" />

    Cette XML permet d'envoyer une nomenclature machine dans notre ERP.

    Concrètement, on y voit des articles et les variables attitré à l'article.
    Exemple JEP10080 est un article avec différente valleur.
    JAC00000 un autre article avec d'autre valeur.

    Ce dont j'ai besoins c'est de réussir à ajouter la balise : MODIFY="TRUE" à la variable ARCTCODPLA seulement si la variable TYPEPDM = NON_TOOLBOX.

    J'ai donc ajouté ceci au fichier de XSL:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <xsl:if test ="FIELD[@name='TYPEPDM']/@value = 'NON_TOOLBOX'">								
    <attribute name="ARCTCODPLA" Modify="TRUE" />							
    </xsl:if>
    La condition Si TYPEPDM = NON_TOOLBOX Fonctionne mais ça me créée une seconde ligne ARCTCODPLA à la place d'ajouter la balise modify = true à la ligne existante..

    Comme on peut voir dans l'XML précedent (sur l'article JEP10080 on retrouve deux lignes:
    <attribute name="ARCTCODPLA" value="-" />
    <attribute name="ARCTCODPLA" Modify="TRUE" />

    Alors que j'aimerai une seule ligne ecrit comme ça:
    <attribute name="ARCTCODPLA" value="-" modify="TRUE"/>



    A titre d'information le XSL complet ressemble à ça:

    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
     
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<xsl:output method="xml"  encoding="UTF-8" indent="yes"/>
     
    	<xsl:template match="BOM_MULTI">
     
    		<XML> 		
    			<transactions> 		
    				<transaction date="1311093484" type="EXPORT_NOMENCLATURE_PDM" vaultname="1LIFE">
    					<document aliasset="Import XML">
     
    						<xsl:element name="configuration">
     
    							<xsl:attribute name="name">
    								<xsl:value-of select="FIELD[@name='CONFIG']/@value" />
    							</xsl:attribute>
    							<xsl:for-each select="FIELD">
     
    								<xsl:if test ="@name != 'CONFIG'">
    									<xsl:element name="attribute">
    										<xsl:attribute name="name">
    											<xsl:value-of select="@name" />
    										</xsl:attribute>
    										<xsl:attribute name="value">
    											<xsl:value-of select="@value" />
    										</xsl:attribute>
    										<xsl:if test ="@name = 'LIBCOMPL'">
    											 <xsl:attribute name="nature">
    												<xsl:text>V</xsl:text>
    											 </xsl:attribute>
    											 <xsl:attribute name="langue">
    												<xsl:text>AR</xsl:text>
    											 </xsl:attribute>
    										 </xsl:if>
    									</xsl:element>
    								</xsl:if>
     
    							</xsl:for-each>
     
    							<!-- Ajout des attributs supplementaires propres à chaque base Cegid pour l'article pere-->
    							<attribute name="ARKTCOMART" value="" />
    							<xsl:if test ="FIELD[@name='TYPEPDM']/@value = 'NON_TOOLBOX'">								
    								<attribute name="ARCTCODPLA2" Modify="TRUE" />							
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=SF-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'SF'">								
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="05" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />								
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=SE-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'SE'">
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="05" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=PC-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'PC'">
    								<attribute name="ARITNATURE" value="1" />
    								<attribute name="ARCTFATN" value="02" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=PF-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'PF'">
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="01" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=MP-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'MP'">
    								<attribute name="ARITNATURE" value="1" />
    								<attribute name="ARCTFATN" value="02" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
     
    							<!-- Traitement des sous niveaux de nomenclatures -->
    							<xsl:apply-templates select="BOM_ITEMS_LIST"/>
     
    						</xsl:element>
     
     
     
    					</document>
    				</transaction>
    			</transactions>
     
    		</XML>
    Merci pour ton aide !

    Léo

  4. #4
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 551
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    Hello,

    OK.

    Ben fais comme avec LIBCOMPL. C'est déjà un test qui ajoute des attributs sous conditions, et ne les ajoute pas si la condition n'est pas respectée.
    C'est pareil.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  5. #5
    Nouveau Candidat au Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juillet 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Juillet 2022
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    Salut Thelvin,

    En modifiant le XSL comme suivant:

    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
     
    ?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<xsl:output method="xml"  encoding="UTF-8" indent="yes"/>
     
    	<xsl:template match="BOM_MULTI">
     
    		<XML> 		
    			<transactions> 		
    				<transaction date="1311093484" type="EXPORT_NOMENCLATURE_PDM" vaultname="1LIFE">
    					<document aliasset="Import XML">
     
    						<xsl:element name="configuration">
     
    							<xsl:attribute name="name">
    								<xsl:value-of select="FIELD[@name='CONFIG']/@value" />
    							</xsl:attribute>
    							<xsl:for-each select="FIELD">
     
    								<xsl:if test ="@name != 'CONFIG'">
    									<xsl:element name="attribute">
    										<xsl:attribute name="name">
    											<xsl:value-of select="@name" />
    										</xsl:attribute>
    										<xsl:attribute name="value">
    											<xsl:value-of select="@value" />
    										</xsl:attribute>
    										<xsl:if test ="@name = 'LIBCOMPL'">
    											 <xsl:attribute name="nature">
    												<xsl:text>V</xsl:text>
    											 </xsl:attribute>
    											 <xsl:attribute name="langue">
    												<xsl:text>AR</xsl:text>
    											 </xsl:attribute>
    										 </xsl:if>
    										<xsl:if test ="FIELD[@name='TYPEPDM']/@value = 'NON_TOOLBOX'">										 
    											<xsl:if test ="@name = 'ARCTCODPLA'">
    												<xsl:attribute name="MODIFY">
    													<xsl:text>TRUE</xsl:text>
    												</xsl:attribute>
    											</xsl:if>
    										</xsl:if>	
    									</xsl:element>
    								</xsl:if>
    							</xsl:for-each>
     
    							<!-- Ajout des attributs supplementaires propres à chaque base Cegid pour l'article pere-->
    							<attribute name="ARKTCOMART" value="" />
     
    							<!-- Champs supplémentaires : TYPE=SF-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'SF'">								
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="05" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />								
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=SE-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'SE'">
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="05" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=PC-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'PC'">
    								<attribute name="ARITNATURE" value="1" />
    								<attribute name="ARCTFATN" value="02" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=PF-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'PF'">
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="01" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=MP-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'MP'">
    								<attribute name="ARITNATURE" value="1" />
    								<attribute name="ARCTFATN" value="02" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
     
    							<!-- Traitement des sous niveaux de nomenclatures -->
    							<xsl:apply-templates select="BOM_ITEMS_LIST"/>
     
    						</xsl:element>
     
     
     
    					</document>
    				</transaction>
    			</transactions>
     
    		</XML>
     
    	</xsl:template>

    Je retrouve aucune balises créée:

    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    <?xml version="1.0" encoding="utf-8"?>
     
      <XML><transactions>
      <transaction date="1311093484" type="EXPORT_NOMENCLATURE_PDM" vaultname="1LIFE">
      <document aliasset="Import XML">
      <configuration name="Défaut">
      <attribute name="Name" value="JEP10080" />
      <attribute name="TYPEPDM" value="NON_TOOLBOX" />
      <attribute name="ARKTCODART" value="JEP10080" />
      <attribute name="ARCTLIB01" value="ESSAI INDICE PMI" />
      <attribute name="ARCTLIB02" value="" />
      <attribute name="LIBCOMPL" value="" nature="V" langue="AR" />
      <attribute name="ARCTTYPART" value="SE" />
      <attribute name="ARCTCODFAM" value="EP" />
      <attribute name="ARCTCODPL1" value="Matériau &lt;non spécifié&gt;" />
      <attribute name="ARCTCODPLA" value="-" />
      <attribute name="ARCNPDSUNI" value="0.42" />
      <attribute name="ARCNLONGUE" value="" />
      <attribute name="ARCNLARGEU" value="" />
      <attribute name="ARCNEPAISS" value="" />
      <attribute name="NOCNQTECOM" value="" />
      <attribute name="ARCTGTRACE" value="N" />
      <attribute name="ARCJCRE" value="20220707" />
      <attribute name="ARCTUTIMOD" value="EPDM-ADM" />
      <attribute name="ARKTCOMART" value="" />
      <attribute name="ARITNATURE" value="6" />
      <attribute name="ARCTFATN" value="05" />
      <attribute name="NOCTREPFAB" value="" />
      <attribute name="ARCTUNISTO" value="P" />
      <attribute name="ARCTTRANCH" value="01" />
      <references><document aliasset="Import XML">
      <configuration name="Défaut">
      <attribute name="Name" value="JAC00000" />
      <attribute name="TYPEPDM" value="RECUP_TOP" />
      <attribute name="ARKTCODART" value="JAC00000" />
      <attribute name="ARCTLIB01" value="TEST EXPORT" />
      <attribute name="ARCTLIB02" value="" />
      <attribute name="LIBCOMPL" value="" nature="V" langue="AR" />
      <attribute name="ARCTTYPART" value="PC" />
      <attribute name="ARCTCODFAM" value="AC" />
      <attribute name="ARCTCODPL1" value="AISI 304" />
      <attribute name="ARCTCODPLA" value="-" />
     
      ETC

    Par contre si je supprime le si TYPEPDM = NON_TOOLBOX la balise se crée tout le temps:

    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
     
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<xsl:output method="xml"  encoding="UTF-8" indent="yes"/>
     
    	<xsl:template match="BOM_MULTI">
     
    		<XML> 		
    			<transactions> 		
    				<transaction date="1311093484" type="EXPORT_NOMENCLATURE_PDM" vaultname="1LIFE">
    					<document aliasset="Import XML">
     
    						<xsl:element name="configuration">
     
    							<xsl:attribute name="name">
    								<xsl:value-of select="FIELD[@name='CONFIG']/@value" />
    							</xsl:attribute>
    							<xsl:for-each select="FIELD">
     
    								<xsl:if test ="@name != 'CONFIG'">
    									<xsl:element name="attribute">
    										<xsl:attribute name="name">
    											<xsl:value-of select="@name" />
    										</xsl:attribute>
    										<xsl:attribute name="value">
    											<xsl:value-of select="@value" />
    										</xsl:attribute>
    										<xsl:if test ="@name = 'LIBCOMPL'">
    											 <xsl:attribute name="nature">
    												<xsl:text>V</xsl:text>
    											 </xsl:attribute>
    											 <xsl:attribute name="langue">
    												<xsl:text>AR</xsl:text>
    											 </xsl:attribute>
    										 </xsl:if>
    					 						<xsl:if test ="@name = 'ARCTCODPLA'">
    												<xsl:attribute name="MODIFY">
    													<xsl:text>TRUE</xsl:text>
    												</xsl:attribute>
    											</xsl:if>
    									</xsl:element>
    								</xsl:if>
    							</xsl:for-each>
     
    							<!-- Ajout des attributs supplementaires propres à chaque base Cegid pour l'article pere-->
    							<attribute name="ARKTCOMART" value="" />
     
    							<!-- Champs supplémentaires : TYPE=SF-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'SF'">								
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="05" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />								
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=SE-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'SE'">
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="05" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=PC-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'PC'">
    								<attribute name="ARITNATURE" value="1" />
    								<attribute name="ARCTFATN" value="02" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=PF-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'PF'">
    								<attribute name="ARITNATURE" value="6" />
    								<attribute name="ARCTFATN" value="01" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
    							<!-- Champs supplémentaires : TYPE=MP-->
    							<xsl:if test ="FIELD[@name='ARCTTYPART']/@value = 'MP'">
    								<attribute name="ARITNATURE" value="1" />
    								<attribute name="ARCTFATN" value="02" />
    								<attribute name="NOCTREPFAB" value="" />
    								<attribute name="ARCTUNISTO" value="P" />
    								<attribute name="ARCTTRANCH" value="01" />
    							</xsl:if>
     
    							<!-- Traitement des sous niveaux de nomenclatures -->
    							<xsl:apply-templates select="BOM_ITEMS_LIST"/>
     
    						</xsl:element>
     
     
     
    					</document>
    				</transaction>
    			</transactions>
     
    		</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
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    <?xml version="1.0" encoding="utf-8"?>
     
      <XML><transactions>
      <transaction date="1311093484" type="EXPORT_NOMENCLATURE_PDM" vaultname="1LIFE">
      <document aliasset="Import XML">
      <configuration name="Défaut">
      <attribute name="Name" value="JEP10080" />
      <attribute name="TYPEPDM" value="NON_TOOLBOX" />
      <attribute name="ARKTCODART" value="JEP10080" />
      <attribute name="ARCTLIB01" value="ESSAI INDICE PMI" />
      <attribute name="ARCTLIB02" value="" />
      <attribute name="LIBCOMPL" value="" nature="V" langue="AR" />
      <attribute name="ARCTTYPART" value="SE" />
      <attribute name="ARCTCODFAM" value="EP" />
      <attribute name="ARCTCODPL1" value="Matériau &lt;non spécifié&gt;" />
      <attribute name="ARCTCODPLA" value="-" MODIFY="TRUE" />
      <attribute name="ARCNPDSUNI" value="0.42" />
      <attribute name="ARCNLONGUE" value="" />
      <attribute name="ARCNLARGEU" value="" />
      <attribute name="ARCNEPAISS" value="" />
      <attribute name="NOCNQTECOM" value="" />
      <attribute name="ARCTGTRACE" value="N" />
      <attribute name="ARCJCRE" value="20220707" />
      <attribute name="ARCTUTIMOD" value="EPDM-ADM" />
      <attribute name="ARKTCOMART" value="" />
      <attribute name="ARITNATURE" value="6" />
      <attribute name="ARCTFATN" value="05" />
      <attribute name="NOCTREPFAB" value="" />
      <attribute name="ARCTUNISTO" value="P" />
      <attribute name="ARCTTRANCH" value="01" />
      <references><document aliasset="Import XML">
      <configuration name="Défaut">
      <attribute name="Name" value="JAC00000" />
      <attribute name="TYPEPDM" value="RECUP_TOP" />
      <attribute name="ARKTCODART" value="JAC00000" />
      <attribute name="ARCTLIB01" value="TEST EXPORT" />
      <attribute name="ARCTLIB02" value="" />
      <attribute name="LIBCOMPL" value="" nature="V" langue="AR" />
      <attribute name="ARCTTYPART" value="PC" />
      <attribute name="ARCTCODFAM" value="AC" />
      <attribute name="ARCTCODPL1" value="AISI 304" />
      <attribute name="ARCTCODPLA" value="-" MODIFY="TRUE" />
     
      ETC

    En quelques sortent, ça ne respecte pas mon double IF...
    Je ne comprend pas d'ou ça viens,

    Des idées ?

    Merci

  6. #6
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 551
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    Je vois. Finalement c'est un peu plus compliqué que le cas LIBCOMPL.

    Il faut repérer l'attribut ARCTCODPLA et aussi vérifier que son frère TYPEPDM a la valeur NON_TOOLBOX.

    Bon. Ça peut s'exprimer comme ça:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:if test ="@name = 'ARCTCODPLA' and ../FIELD[@name='TYPEPDM']/@value = 'NON_TOOLBOX'">
    Repérer l'usage du ../ qui remonte au parent du nœud en cours, puis cherche un fils FIELD avec un nom précis.

    Ah ça demande un peu de boulot, 'faut reconnaître.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  7. #7
    Nouveau Candidat au Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juillet 2022
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Juillet 2022
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    Salut !

    Excellent ça fonctionne ! Merci beaucoup pour ton aide


    En fait mon double if fonctionnais c'est juste qu'il le lisait pas parce qu'il la condition était au dessus ? D'ou le ../ ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    							<xsl:if test ="FIELD[@name='TYPEPDM']/@value = 'NON_TOOLBOX'">										 
    											<xsl:if test ="@name = 'ARCTCODPLA'">
    												<xsl:attribute name="MODIFY">
    													<xsl:text>TRUE</xsl:text>
    												</xsl:attribute>
    											</xsl:if>
    										</xsl:if>

    Au plaisir, Léo

  8. #8
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 551
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    Non, c'est pas rapport à la position de la condition, ça change rien. Elle aurait marché aussi avec le ../

    C'est rapport à où se trouve le FIELD TYPEPDM, qui est au même niveau (soit devant soit après) du FIELD ARCTCODPLA en cours. Y'a pas d'axe XPATH pour "toute la fratrie du nœud en cours", donc le plus simple est de remonter au parent, et d'en prendre les enfants.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

Discussions similaires

  1. [DOM] Ajout dynamique d'une ligne dans un <table>
    Par Alzelus dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 23/05/2007, 17h05
  2. ajout/suppression d'une ligne dans une jTable
    Par amelA dans le forum Composants
    Réponses: 1
    Dernier message: 16/05/2007, 08h42
  3. balise select à une ligne (comboBox)
    Par guigui_rondat dans le forum Balisage (X)HTML et validation W3C
    Réponses: 1
    Dernier message: 04/02/2006, 23h54
  4. Ajout de d'une ligne et d'un champ input dans un tableau
    Par zetta dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 15/11/2005, 10h45
  5. TValueListEditor: Ajout automatique d'une ligne vide
    Par Patrick Seuret dans le forum C++Builder
    Réponses: 3
    Dernier message: 24/06/2005, 12h16

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