Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1457 connectés 

  FORUM HardWare.fr
  Programmation
  XML/XSL

  [XSL] add attribute into existing XML

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[XSL] add attribute into existing XML

n°1029358
Ngok
Posté le 30-03-2005 à 08:42:53  profilanswer
 

voici mon  autre  probleme
 
I need to add the attribute "version" in the wap-provisioningdoc node. How can I do this using the following XSL? This XSL gets rid of the node characteristic of type SETTINGSET.
 
current XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl  utput method="xml" indent="yes"/>
 
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()[not(@type='SETTINGSET')]"/>
</xsl:copy>
</xsl:template>
 
</xsl:stylesheet>
 
 
 
Input XML
<wap-provisioningdoc>
<characteristic type="SETTINGSET">
<parm name="NAME" value="NOKIA-6170"/>
<parm name="STATE" value="2"/>
<parm name="SERVICE" value="WAPGPRS"/>
</characteristic>
<characteristic type="PXLOGICAL">
<parm name="TRUST"/>
<parm name="MASTER"/>
<parm name="STARTPAGE" value="http://www.bank.com/startpage.wml"/>
</characteristic>
<characteristic type="NAPDEF1">
<parm name="INTERNET"/>
</characteristic>
<characteristic type="APPLICATION">
<characteristic type="RESOURCE">
<parm name="STARTPAGE"/>
</characteristic>
</characteristic>
<characteristic type="ACCESS">
<parm name="RULE"/>
</characteristic>
</wap-provisioningdoc>
 
 
Result expected:
<wap-provisioningdoc version="1.0">
<characteristic type="PXLOGICAL">
<parm name="TRUST"/>
<parm name="MASTER"/>
<parm name="STARTPAGE" value="http://www.bank.com/startpage.wml"/>
</characteristic>
<characteristic type="NAPDEF1">
<parm name="INTERNET"/>
</characteristic>
<characteristic type="APPLICATION">
<characteristic type="RESOURCE">
<parm name="STARTPAGE"/>
</characteristic>
</characteristic>
<characteristic type="ACCESS">
<parm name="RULE"/>
</characteristic>
</wap-provisioningdoc>
 
 
Thanks

mood
Publicité
Posté le 30-03-2005 à 08:42:53  profilanswer
 

n°1034418
avander
Posté le 04-04-2005 à 15:51:17  profilanswer
 

Code :
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3.   <xsl:output method="xml" indent="yes"/>
  4.   <xsl:template match="@*|node()">
  5.     <xsl:copy>
  6.       <xsl:if test="name()='wap-provisioningdoc'">
  7.           <xsl:attribute name="version">1</xsl:attribute>
  8.       </xsl:if>
  9.       <xsl:apply-templates select="@*|node()[not(@type='SETTINGSET')]"/>
  10.     </xsl:copy>
  11.   </xsl:template>
  12. </xsl:stylesheet>
  13. <!-- eof -->


 
testé avec MSXML 4 :jap:


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  XML/XSL

  [XSL] add attribute into existing XML

 

Sujets relatifs
[XSL] sort elementXml avec .. ?
XML - Actionscript...[XML/PHP/SQL] Formulaire dynamique + base de données: quel logiciel
XML et SPIP[XML/XSL] tri dynamique [résolu]
besoin d'aide en XMLGénérer des data form HTML a partir d'un XML ou d'un XSD
Plus de sujets relatifs à : [XSL] add attribute into existing XML


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR