Altova RaptorXML+XBRL Server 2025

L'exemple VBScript ci-dessous est structuré dans les parties suivantes :

 

Configurer et initialiser l'objet COM RaptorXML

Valider un fichier XML

Effectuer une transformation XSLT, retourner le résultat en tant que string

Traiter un document XQuery, enregistrer le résultat dans un fichier

Configurer la séquence d'exécution du script et de son point d'entrée

 

' The RaptorXML COM object

dim objRaptor

 

' Initialize the RaptorXML COM object

sub Init

 objRaptor = Null

 On Error Resume Next

 ' Try to load the 32-bit COM object; do not throw exceptions if object is not found

 Set objRaptor = WScript.GetObject( "", "RaptorXML.Server" )

 On Error Goto 0

 if ( IsNull( objRaptor ) ) then

         ' Try to load the 64-bit object (exception will be thrown if not found)

         Set objRaptor = WScript.GetObject( "", "RaptorXML_x64.Server" )

 end if

 ' Configure the server: error reporting, HTTP server name and port (IPv6 localhost in this example)

 objRaptor.ErrorLimit = 1

 objRaptor.ReportOptionalWarnings = true

 objRaptor.ServerName = "::1"

 objRaptor.ServerPort = 8087

end sub

 

' Validate one file

sub ValidateXML

 ' Get a validator instance from the Server object

 dim objXMLValidator

 Set objXMLValidator = objRaptor.GetXMLValidator()

 

 ' Configure input data

 objXMLValidator.InputFileName = "MyXMLFile.xml"

 

 ' Validate; in case of invalid file report the problem returned by RaptorXML

 if ( objXMLValidator.IsValid() ) then

         MsgBox( "Input string is valid" )

 else

         MsgBox( objXMLValidator.LastErrorMessage )

 end if

end sub

 

' Perform a transformation; return the result as a string

sub RunXSLT

 ' Get an XSLT engine instance from the Server object

 dim objXSLT

 set objXSLT = objRaptor.GetXSLT

 

 ' Configure input data

 objXSLT.InputXMLFileName = "MyXMLFile.xml"

 objXSLT.XSLFileName = "MyTransformation.xsl"

 

 ' Run the transformation; in case of success the result will be returned, in case of errors the engine returns an error listing

 MsgBox( objXSLT.ExecuteAndGetResultAsString() )

end sub

 

' Execute an XQuery; save the result in a file

sub RunXQuery

 ' Get an XQuery engine instance from the Server object

 dim objXQ

 set objXQ = objRaptor.GetXQuery()

 

 ' Configure input data

 objXQ.InputXMLFileName = "MyXMLFile.xml"

 objXQ.XQueryFileName = "MyQuery.xq"

 

 ' Configure serialization (optional - for fine-tuning the result's formatting)

 objXQ.OutputEncoding = "UTF8"

 objXQ.OutputIndent = true

 objXQ.OutputMethod = "xml"

 objXQ.OutputOmitXMLDeclaration = false

 

 ' Run the query; the result will be serialized to the given path

 call objXQ.Execute( "MyQueryResult.xml" )

end sub

 

' Perform all sample functions

sub main

 Init

 ValidateXML

 RunXSLT

 RunXQuery

end sub

 

' Script entry point; run the main function

main

 

 

© 2018-2024 Altova GmbH