Jump to content

sacha74

Members
  • Content Count

    23
  • Joined

  • Last visited

Community Reputation

0 Neutral

About sacha74

  • Rank
    Newbie
  1. Hello, I tried to put a new xsl:for each inside the treatment I already do for table (shown in the xslt file of the previous message) because the table is in a table.It doesn't work better than the first code I mentionned yesterday in the code below.Here is my new code : <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy></xsl:template> <xsl:template match="table[descendant::tr]"> <table> <tgroup> <xsl:attribute name="cols"><xsl:value-of select="count(.//th)"/></xsl:attribute> <xsl:for-each select="thead/tr"> <thead> <row> <xsl:for-each select="th"> <entry> <xsl:apply-templates/> </entry> </xsl:for-each> </row> </thead> </xsl:for-each> <xsl:for-each select="tr[(descendant::th)]"> <thead> <row> <xsl:for-each select="th"> <entry> <xsl:apply-templates/> </entry> </xsl:for-each> </row> </thead> </xsl:for-each> <xsl:for-each select="tbody/tr[(descendant::th)]"> <thead> <row> <xsl:for-each select="th"> <entry> <xsl:apply-templates/> </entry> </xsl:for-each> </row> </thead> </xsl:for-each> <tbody> <xsl:for-each select="tbody/tr[not(descendant::th)]"> <row> <xsl:for-each select="td"> <entry> <xsl:for-each select="entry//table"> <table> <tgroup> <xsl:attribute name="cols"><xsl:value-of select="count(.//th)"/></xsl:attribute> <xsl:for-each select="thead/tr"> <thead> <row> <xsl:for-each select="th"> <entry> <xsl:apply-templates/> </entry> </xsl:for-each> </row> </thead> </xsl:for-each> <tbody> <xsl:for-each select="tbody/tr"> <row> <xsl:for-each select="td"> <entry> <xsl:apply-templates/> </entry> </xsl:for-each> </row> </xsl:for-each> </tbody> </tgroup> </table> </xsl:for-each> </entry> </xsl:for-each> </row> </xsl:for-each> </tbody> </tgroup> </table></xsl:template></xsl:stylesheet> I think I'm really at a dead end. So if anyone has any idea, any indication that could help me, please tell me. Thanks in advance for the help I could find.
  2. Hello, I would like to transform those two examples : <topic><body><p><table><tgroup cols="3"><colspec colname="1" colnum="1" colwidth="25%"/><colspec colname="2" colnum="2" colwidth="55%"/><colspec colname="3" colnum="3" colwidth="20%"/><thead></thead><tbody><row><entry><p>Conditions à respecter :</p><ul><li>Renseigner ...</li> <li>Renseigner les champs "Obligatoires" : <table> <thead> <tr> <th scope="col">Code opération</th> <th scope="col">Champs</th> <th scope="col">Mot clé</th> </tr> </thead> <tbody> <tr> <td>CPS (Paiem.Coup.)</td> <td>Date EX Date Paiement Cash</td> <td> <p>DEX DPC</p> </td> </tr> </tbody> </table> </li></ul></entry></row></tbody></tgroup></table></p></body></topic> The second one : <topic><body><table> <tr> <th> </th> <th> Autre numérotation du centre 0000001 </th> <th> Racine (positions 2 à 5) à contrôler </th> <th> 0 </th> </tr><tbody> <tr> <td> </td> <td> </td> <td> </td></tr></tbody></table></body></topic> I would like to transform those file using one XSLT file : <xsl:template match="entry//table[descendant::tr]"> this one works for the first example <xsl:template match="table[descendant::tr]"> this one works for the second example.I have tried :- <xsl:template match="entry//table[descendant::tr]|table[descendant::tr]"> but it works only for the second example- <xsl:template match="*//table[descendant::tr]"> but it works only for the second example.- several other possible solutions and I can't find one that it works ! Do you have any idea to put together thes two codes. Thanks in advance for the help I could find.
  3. Thanks a lot for your answer, I made some changes in the code but it really guides me to find the code responding to my case.
  4. Hello,I'm trying to transform an XHTML file. <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta name="template" content="Modele_NexT.htt" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="topic-status" content="Complete" /> <meta name="generator" content="Adobe RoboHelp - www.adobe.com" /> <meta name="generator-major-version" content="0.1" /> <meta name="generator-minor-version" content="1" /> <meta name="filetype" content="RoboHelp" /> <meta name="filetype-version" content="1" /> <meta name="page-count" content="1" /> <meta name="layout-height" content="684" /> <meta name="layout-width" content="727" /> <title>Sans chablons</title> <link rel="StyleSheet" href="../DocNexT.css" /></head><body> <div placeholder="" id="header" style="width: 100%; position: relative;"> <p> </p> </div> <h1>Sans chablons</h1> <p>Cette fonctionnalité vous permet de saisir une transaction sans utiliser de modèle particulier.</p> <p> </p> <p><img src="TransferOperation21.jpg" style="border: none; width: 605px; height: 65px; border-style: none; border-style: none;" width="605" height="65" border="0" alt="" /></p> <p> </p> <p>Renseignez les champs obligatoires qui figurent en rouge avec un astérisque :</p> <p> </p></head> I want to do 2 transformations: Delete tags <meta> et <div> Delete namespace xmlns="http://www.w3.org/1999/xhtml"I have the two codes :the one for tags <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#default"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="meta|div"/> <xsl:template match="span"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet> the one for namespace <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template> </xsl:stylesheet> The problem is that when I combine the two codes, only the one for deleting the namespace works.Please can you help me to do the 2 codes in one stylesheet.NB: However, this is not a real problem but if I can delete the <p> </p>. All the ideas era welcomedThanks for all
  5. Once again thanks a lot for your answer, which works wonderfully. That's also really kind of you to answer so quickly.Thank you, Martin Honnen
  6. Hello,I have a xml file and what I want to do is to copy the entire file with all the tags. I've done this with : <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="node()"/> </xsl:copy></xsl:template> But I also want to replace all characters "ÁÉÍÓÚ" with"AEIOU". I managed to do this with : <xsl:variable name="Schar">ÁÉÍÓÚ</xsl:variable><xsl:variable name="Rchar">AEIOU</xsl:variable> <xsl:template match="node()"> <xsl:copy-of select="translate(normalize-space(.), $Schar, $Rchar)"></xsl:copy-of></xsl:template> The problem with this last code is that there are no more tags in the result file. But what Iwant is to combine the two features that are : copying the xml file while only changing the characters mentionned above.With an example, I would like that : <xml><table><ROW><CELL ROWSPAN="1" COLSPAN="1"><Tableau-cellule><A ID="pgfId-594128"></A>Ámbito </Tableau-cellule></CELL>......</ROW></table></xml> to become that : <xml><table><ROW><CELL ROWSPAN="1" COLSPAN="1"><Tableau-cellule><A ID="pgfId-594128"></A>Ambito </Tableau-cellule></CELL>......</ROW></table></xml> Can somebody telle me how to combine these two rules because when I tried to combine them , everytime one of two doesn't work. Thanks in advance for all the help I can find.
  7. I would like to delete the <DIV> tags while keeping all the tags that are in the <Div> tag. The problem is that in the code there are <DIV> tags in other <DIV> tags.The original code: <XML><Map-Start><A ID="pgfId-592691"/></Map-Start> <Bloc-paragraphe><A ID="pgfId-596086"/>074 is used to customise application codes for the administration of time and call fiduciary deposit orders. </Bloc-paragraphe><Map><A ID="pgfId-596087"/>information </Map> <Bloc-paragraphe> <A ID="pgfId-596106"/>ggjug guigik </Bloc-paragraphe><DIV> <IMAGE xml:link="simple" href="074-1.gif" show="embed" actuate="auto"/> </DIV> <DIV> <FM2Titre><A ID="pgfId-596112"/>access key</FM2Titre> <DIV> <FM3Titre><A ID="pgfId-596113"/></FM3Titre> <Bloc-paragraphe><A ID="pgfId-596114"/>position to: </Bloc-paragraphe> <DIV> <Liste-Puce><A ID="pgfId-596115"/>a new application code,</Liste-Puce></DIV></DIV></DIV></XML> My xslt: <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="A|T-No|T-######|IMAGE"/> <xsl:template match="DIV|DIV/DIV|DIV/DIV/DIV"> <xsl:copy-of select="node()"/> </xsl:template> What I would like to obtain: <XML><Map-Start><A ID="pgfId-592691"/></Map-Start> <Bloc-paragraphe><A ID="pgfId-596086"/>074 is used to customise application codes for the administration of time and call fiduciary deposit orders. </Bloc-paragraphe><Map><A ID="pgfId-596087"/>information </Map> <Bloc-paragraphe> <A ID="pgfId-596106"/>ggjug guigik </Bloc-paragraphe> <IMAGE xml:link="simple" href="074-1.gif" show="embed" actuate="auto"/> <FM2Titre><A ID="pgfId-596112"/>access key</FM2Titre> <FM3Titre><A ID="pgfId-596113"/></FM3Titre> <Bloc-paragraphe><A ID="pgfId-596114"/>position to: </Bloc-paragraphe> <Liste-Puce><A ID="pgfId-596115"/>a new application code,</Liste-Puce></XML> Can you help me to understand how to treat all the <DIV> tags even those which are DIV/DIV/DIV/DIV.Do you have any ideas?Thanks in advance for all the help I could find.
  8. I am so sorry to have bother you with such a stupid mistake; THE LIGHTS ARE ON BUT NOBODY'S HOMEThanks a lot for your help.
  9. If I use this code: <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xml" href="formedita.xslt"?><Paramétrage>tulo<p> </p> <table> <tr> <th> Table </th> <th> Élément </th> </tr> <tbody> <tr> <td> 900 </td> <td> 999 </td></tr><tr> <td> 900 </td> <td> 998 </td> </tr><tr> <td> 900 </td> <td> 999 </td></tr><tr> <td> 900 </td> <td> 989 </td> </tr> </tbody> </table>Règles de calcul <p> </p> <table> <tr> <th> Mode tarification </th> <th> Critère </th> <th> Calcul du résultat </th> </tr> <tbody> <tr> <td> Plafond </td> <td> Recherche du taux ou du montant à l'unité pour le critère suivant : Montant < plafond </td> <td> <ul><li> Résultat = Montant * taux / 100 </li></ul> <ul><li> Ajout ou soustraction du montant fixe au résultat ou prise en compte du montant maximum ou minimum de la tranche (zone ). </li></ul> </td> </tr> <tr> <td> Frais postaux </td> <td> Frais pour mandat postal </td> <td> <ul><li> Variante par tranche, 6 premières tranches fixes et 7ème tranche supplémentaire (zone ). </li></ul> </td> </tr> </tbody> </table> <p> Exemple de calcul par tranche (voir ) </p> <li> Montant brut de l'opération: 10'000. </li> <li> Commission par tranche en 01000. </li> <p> </p> </Paramétrage> In this file, there are two exemples of text without tags:"tulo"and "Règles de calcul" which after the transformation would be <toto>tulo</toto> and either for othersAnd if I apply this transformation: <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/" priority="1"> <body> <xsl:apply-templates/> <xsl:for-each select="body/text()[normalize-space()]"> <toto> <xsl:apply-templates select="normalize-space()"/> </toto> </xsl:for-each> </body> </xsl:template> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="*/p/p"> <xsl:apply-templates select="node()"/> </xsl:template> <xsl:template match="table"> <table> <tgroup> <xsl:attribute name="cols"><xsl:value-of select="count(.//th)"/></xsl:attribute> <xsl:for-each select="tr[1]"> <thead> <row> <xsl:for-each select="th"> <entry> <xsl:apply-templates select="node()"/> </entry> </xsl:for-each> </row></thead> </xsl:for-each> <tbody> <xsl:for-each select="tbody/tr"> <row> <xsl:for-each select="td"> <entry> <xsl:apply-templates select="node()"/> </entry> </xsl:for-each> </row> </xsl:for-each> </tbody> </tgroup> </table> </xsl:template></xsl:stylesheet> The text without tags has not changed.Perhaps it is a question of priority? Do you have any idea?
  10. Thanks a lot for the rapidity, with which you answer me.I have to try the code you propose because it does not seem to resolve the case each time it is present in the code.Whatever, thanks. I'm going to try and I tell you...
  11. Hello,The data, to be transformed, have been extracted from a database and now there is some text data without tags. Here is my xml code <body>doc simé <p> La table 050 permet de paramétrer les libellés qui doivent figurer sur les relevés de comptes et les écrans de consultation des mouvements sur les comptes imputés lors des opérations de transfert définies dans la table 049. </p> <p> La table 050 permet aussi de paramétrer les comptes sur lesquels imputer les commissions et les frais, ainsi que les comptes de contreparties aussi bien des opérations de transfert pour une racine que pour un fonds de placement. </p> <p> <p> </p> La description ci-dessus n'est valable que pour le programme des opérations de transferts AS4200. Si vous utilisez le programme AS4210, seule la désignation est utilisée, la ventilation comptable étant quant à elle définie dans la table <p> 059 </p> . </p> Here we can see that there is text without any tags ("doc simé").What I would like to obtain is: <body><toto>doc simé</toto> <p> La table 050 permet de paramétrer les libellés qui doivent figurer sur les relevés de comptes et les écrans de consultation des mouvements sur les comptes imputés lors des opérations de transfert définies dans la table 049. </p> <p> La table 050 permet aussi de paramétrer les comptes sur lesquels imputer les commissions et les frais, ainsi que les comptes de contreparties aussi bien des opérations de transfert pour une racine que pour un fonds de placement. </p> <p> <p> </p> La description ci-dessus n'est valable que pour le programme des opérations de transferts AS4200. Si vous utilisez le programme AS4210, seule la désignation est utilisée, la ventilation comptable étant quant à elle définie dans la table <p> 059 </p> . </p> Unfortunately, my xslt file does not work. There is no modification at all.Here is my code: <xsl:template match="body/string"><toto><xsl:value-of select="."/></toto></xsl:template> Could anyone help me, please, to solve that problem?Thanks in advance.
  12. Thank you for the valuable information you provided. You're really good.Once again a big thank to you.
  13. My input :<XML><FM1Titre>description</FM1Titre><p>tata</p> <TABLE>....</TABLE><FM1Titre>Codes retenus</FM1Titre><TABLE><ROW><TH><Tableau-intitulé>totot</Tableau-intitulé></TH><TH><Tableau-intitulé> [...]<ROW><CELL><Tableau-cellule-centrée-gras>ACT(802)</Tableau-cellule-centrée-gras></CELL><CELL> [...]</TABLE><TABLE>....</TABLE><TABLE>....</TABLE><TABLE>....</TABLE></XML> My xslt file is rather long so perhaps you can take the one in my previous post. Tell me if it is a problem. My output :<XML><description> <p>tata</p> <TABLE>....</TABLE></description><Codes_retenus><TABLE></TABLE></Codes_retenus></XML> In my output three tables are missing. I have tried with <xsl:for-each> but it doesn't work better. Moreover the transformation of the table works well when it is in an other xslt.So I'd like to put these two xslt in just one file. Is it possible?
  14. Hello,I'm back once again. I try to group two transformations in my xslt file but I have the impression that my xml editor don't manage to go on the second template after doing the first one.I want to treat tables. The problem is that I have 4 tables which follows one another and when i asked for the transformation just one table is transfromed and the following three have disappeared.Here is my xslt:<xsl:template match="/XML" priority="1"> <xsl:copy> <xsl:apply-templates select="FM1Titre[1]"/> </xsl:copy> </xsl:template> <xsl:variable name="Schar"> '’():/éèà,"</xsl:variable> <xsl:variable name="Rchar">_______eea__</xsl:variable> <xsl:template match="FM1Titre"> <xsl:element name="{translate(normalize-space(.), $Schar, $Rchar)}"> <xsl:apply-templates select="following-sibling::*[1][not(self::FM1Titre)]"/> </xsl:element> <xsl:apply-templates select="following-sibling::FM1Titre[1]"/> </xsl:template> <xsl:template match="/XML/*[not(self::FM1Titre)]"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> <xsl:apply-templates select="following-sibling::*[1][not(self::FM1Titre)]"/> </xsl:template> <xsl:template match="//TABLE" priority="2"> <xsl:value-of select="TABLE"/> <table> <tgroup cols="6"> <colspec colname = "1" colnum = "1" colwidth = "1.85cm"/> <colspec colname = "2" colnum = "2" colwidth = "10.9cm"/> <colspec colname = "3" colnum = "3" colwidth = "0.65cm"/> <colspec colname = "4" colnum = "4" colwidth = "0.65cm"/> <colspec colname = "5" colnum = "5" colwidth = "1cm"/> <colspec colname = "6" colnum = "6" colwidth = "1cm"/> <thead> <row> <entry colname="1"><xsl:value-of select="ROW/TH[1]/Tableau-intitulé"/></entry> <entry colname="2"><xsl:value-of select="ROW/TH[2]/Tableau-intitulé"/></entry> <entry colname="3"><xsl:value-of select="ROW/TH[3]/Tableau-intitulé"/></entry> <entry colname="4"><xsl:value-of select="ROW/TH[4]/Tableau-intitulé"/></entry> <entry colname="5"><xsl:value-of select="ROW/TH[5]/Tableau-intitulé"/></entry> <entry colname="6"><xsl:value-of select="ROW/TH[6]/Tableau-intitulé"/></entry> </row> </thead> <tbody> <xsl:for-each select="ROW[position () > 1]"> <row> <entry colname="1"><CELL><xsl:apply-templates select="CELL[1]/node()"/></CELL></entry> <entry colname="2"><CELL><xsl:apply-templates select="CELL[2]/node()"/></CELL></entry> <entry colname="3"><CELL><xsl:apply-templates select="CELL[3]/node()"/></CELL></entry> <entry colname="4"><CELL><xsl:apply-templates select="CELL[4]/node()"/></CELL></entry> <entry colname="5"><CELL><xsl:apply-templates select="CELL[5]/node()"/></CELL></entry> <entry colname="6"><CELL><xsl:apply-templates select="CELL[6]/node()"/></CELL></entry> </row> </xsl:for-each> </tbody> </tgroup> </table> </xsl:template>What am I doing wrong in the second template and that would explain that only one table on 4 is recovered ?Thanks in advance for all the help I could find.
×
×
  • Create New...