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
| Sub lancerAdaptationXSLT(nomFichierInitial, nomFichierFinal, nomFichierXSLT)
'déclaration et création des objets nécessaires à la fonction
Dim oXml, oXsl, sortie, xslt, xslDoc, xmlDoc, xslProc
Set oXml = CreateObject("MSXML2.DOMDocument.4.0")
Set oXsl = CreateObject("MSXML2.DOMDocument.4.0")
Set sortie = CreateObject("Scripting.FileSystemObject")
Set fichierTemporaire = sortie.CreateTextFile(nomFichierFinal, True)
oXml.validateOnParse = False
oXml.async = False
'chargement du fichier XML à transformer
oXml.Load (nomFichierInitial) 'Attention au chemin du fichier
If oXml.parseError.errorCode <> 0 Then
MsgBox "erreur chargement XML : " & oXml.parseError.reason
Else
oXsl.async = False
'chargement du fichier XSLT définissant les règles de transformation
oXsl.Load (nomFichierXSLT)
If oXsl.parseError.errorCode <> 0 Then
MsgBox "erreur chargement XsL : " & oXsl.parseError.reason
Else
'application des transformations, que l'on écrit dans le fichier temporaire créé.
fichierTemporaire.writeLine oXml.transformNode(oXsl.documentElement)
fichierTemporaire.Close
End If
End If
Set fichierTemporaire = Nothing
Set sortie = Nothing
Set oXsl = Nothing
Set oXml = Nothing
End Sub |
Partager