Bonjour,
à partir d'un fichier xml , je voudrais transformer les 4 caractères de la
valeur d'un élément en code ascii dans un élément d'un fichier xml de
sortie différent.
A priori, il me semble que ni XSLT, ni XPath ne permettent ce genre de
manipulation. Aussi, je m'oriente vers une fonction javascript avec la
méthode charCodeAt(), mais je n'arrive pas à m'en sortir.
Si quelqu'un peut m'aider, je l'en remercie.
Bernols
Fichier xml en entrée : SAPinputJS
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 <?xml version="1.0" encoding="UTF-16"?> <SAP xsi:noNamespaceSchemaLocation="SAP.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ficheInformation> <fiche> <TypeDuDocument>0112</TypeDuDocument> </fiche> </ficheInformation> </SAP> Fichier de transformation : SAPjs.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> <!--modification de encoding--> <xsl:output method="xml" encoding="ISO-8859-1" indent="yes"/> <!--fonction javascript--> <xsl:template match="/SAP"> <ModeleExport> <xsl:apply-templates select="ficheInformation"/> </ModeleExport> </xsl:template> <xsl:template match="ficheInformation"> <ficheInformation> <fiche> <TypeDuDocument> <!--appel de la fonction--> <xsl:value-of select="."/> </TypeDuDocument> </fiche> </ficheInformation> </xsl:template> </xsl:stylesheet> Fichier de sortir à obtenir : SAPoutputJS.xml <?xml version="1.0" encoding="ISO-8859-1"?> <ModeleExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ficheInformation> <fiche> <!--obtenir en sortie la valeur de 0112 en ascii, chaque chiffre séparé par un point--> <TypeDuDocument>48.49.49.50</TypeDuDocument> </fiche> </ficheInformation> </ModeleExport>
Partager