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
<?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>
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
Cette liste est a votre disposition pour discuter en francais de
tout sujet technique lie a XML.
Pour resilier votre abonnement, envoyez un message contenant
la commande "unsubscribe" a xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Received on Tue Apr 11 21:51:11 2006