XML-FILES-XSD Connector Guide

Design time behavior

The XML-FILES-XSD connector parses an XSD file and generates an asset describing the XSD metadata model in JSON. In addition, the connector enables you to test the model by creating an  XML output file based on the newly created asset. 

Runtime behavior

The XML-FILES-XSD connector receives from a client a JSON request (formatted according to the assets generated from the XSD file on design time).  The connector then converts the JSON request to an XML file.

Guide topics

The XML-FILES-XSD connector guide includes the following topics:

  • Create an XML-FILES-XSD asset: a detailed step-by-step tutorial on how to create an XML-FILES-XSD module and assets.
  • Connector properties: a list of all the connector properties and their explanations.

Create XML-FILES-XSD module and assets

To create an asset, perform the following steps.  

Step 1. Before you start

Before creating the XML-FILES-XSD module, ensure that you have an XSDdata source file, e.g., the restriction.xsd file:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://BRMSService"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="ConceptoBO" type="ConceptoBO"/>
    <xsd:complexType name="ConceptoBO">
        <xsd:sequence>
            <xsd:element minOccurs="0" name="clave" type="xsd:string" />
            <xsd:element minOccurs="0" name="monto" type="xsd:double" />
            <xsd:element minOccurs="0" name="tipoConcepto">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:enumeration value="DEDUCCION" />
                        <xsd:enumeration value="PERCEPCION" />
                        <xsd:enumeration value="ADEUDO" />
                        <xsd:enumeration value="DEDUCCION_FIJA" />
                        <xsd:enumeration value="DEDUCCION_ISSSTELEON" />
                        <xsd:enumeration value="DEDUCCION_VARIABLE" />
                        <xsd:enumeration value="DEDUCCION_ESPECIAL" />
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element minOccurs="0" name="numJornadas"
                         type="xsd:int" />
            <xsd:element minOccurs="0" name="subtipo"
                         type="xsd:string">

            </xsd:element>
            <xsd:element minOccurs="0" name="aplicaCapacidadPago"
                         type="xsd:boolean">
            </xsd:element>
            <xsd:element minOccurs="0" name="descripcion"
                         type="xsd:string">
            </xsd:element>
            <xsd:element minOccurs="0" name="requeridoCobranza"
                         type="xsd:boolean">
            </xsd:element>
            <xsd:element minOccurs="0" name="esVirtual"
                         type="xsd:boolean">
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Step 2. Create an XML-FILES-XSD module

First, create the XML-FILES-XSD module. 

> ol create module --connector xml-files-xsd module-xml-files-xsd
$ ol create module --connector xml-files-xsd module-xml-files-xsd

Step 3. View the properties of the XML-FILES-XSD connector

Review the connector properties. For more information on the  XML-FILES-XSD connection properties, see Properties below.

  1. Navigate to the module folder:

    > cd module-xml-files-xsd
    
    $ cd module-xml-files-xsd
    
  2. From under the module directory, display the help menu of the ol add command.

    [module-name]> ol add --help
    
    [module-name]$ ol add --help
    

The ol add help menu displays the xml-files-xsd connector property list:

Usage: ol add [OPTIONS]

  Add Asset to Module metadata

Options:
  --verbose                                             Enables verbose mode
  --verbose-debug                                       Enables debug mode
  --verbose-trace                                       Enables trace mode
  --additional VALUE                                    Additional properties
  --file-path TEXT                                      Define path to the input file
  --file-content TEXT                                   Define input data
  --out-file-path TEXT                                  Define path to the output file
  --operation-name TEXT                                 Define name for this operation
  --file-type TEXT                                      Define the file type
  --raw                                                 flag to add raw data (BYTE_ARRAY) default Asset to the module
  --csv-append-mode                                     flag to enable/disable append mode for csv producer
  --base-packages TEXT
  --live TEXT                                           (default: true)
  --prettify-xml TEXT                                   (default: true)
  --base-path TEXT
  --file-name-pattern TEXT
  --temp-extension TEXT
  --file-name-place-holder TEXT
  --encoding TEXT                                       (default: UTF-8)
  --save-file TEXT                                      (default: true)
  --line-separator TEXT                                 [OS, LF, CRLF] (default: OS)
  --generate-null-elements TEXT                         (default: false)
  --timeout TEXT                                        (default: 30000)
  --swift.block1 TEXT                                   (default: F01RZBB9155XXXX0000000000)
  --csv.has-header TEXT                                 (default: true)
  --csv.delimiter TEXT                                  (default: ,)
  --csv.skip-header-lines TEXT                          (default: 0)
  --csv.skip-footer-lines TEXT                          (default: 0)
  --csv.predefined-header TEXT
  --csv.predefined-footer TEXT
  --csv.generate-header-from-field-names TEXT           (default: false)
  --csv.generate-header-from-field-original-names TEXT  (default: true)
  --csv.field-names-line-placeholder TEXT               (default: {csv_field_names_line_placeholder})
  --csv.custom-header-footer-new-line-delimiter TEXT    (default: )
  --csv.quotations-mode TEXT                            (default: false)
  --csv.indent-collection-string TEXT
  --csv.collection-item-identifier TEXT
  --csv.null-placeholder TEXT
  --profile TEXT                                        Configuration profile
  -h, --help                                            Show this message and exit

Step 4. Test the connection to the remote server

Run the ol test connection command with the --base-path option to verify that the base directory exists and is accessible. 

[module-name]> ol test connection --base-path "/MyRootDirectory"
[module-name]$ ol test connection --base-path "/MyRootDirectory"

Step 5. Add an asset to the XML-FILES-XSD module

After you verified the connection parameters, you can create an XML-FILES-XSD asset. The ol add command generates one asset folder that contains the asset configuration file ([asset-name].json) and the asset testing resources. Set the location of the test results file in the --file-name-pattern option.    

[module-name]> ol add --file-path ./restriction.xsd --file-name-pattern ./assets/restriction/test_data/test_out/result.xml
[module-name]$ ol add --file-path ./restriction.xsd --file-name-pattern ./assets/restriction/test_data/test_out/result.xml

Step 6. Test the XML-FILES-XSD asset

Test the asset you added to verify that you can request and receive actual business data from the data source.

  1.  From your module folder root go to assets/[asset_name]/test_data/case1/:

    [module-name]> assets/[asset_name]/test_data/case1/
    
    [module-name]$ assets/[asset_name]/test_data/case1/
    
  2. Open in.json to view and edit the test input data.

    case-1> notepad in.json
    
    case-1$ notepad in.json
    

The in.json file contains the input values sent to the test.

{
  "conceptoBO" : {
    "clave" : "",
    "monto" : 0,
    "tipoConcepto" : "",
    "numJornadas" : 0,
    "subtipo" : "",
    "aplicaCapacidadPago" : "false",
    "descripcion" : "",
    "requeridoCobranza" : "false",
    "esVirtual" : "false"
  }
}
  1. In in.json, type the values of the input properties. In the example above, for the monto key, type 5 and for the numJornadas key 3.

  2. Now you are ready to run ol test asset:

    > ol test asset restriction
    
    $ ol test asset restriction
    

Step 7. Review the test result

The test result is an XML file generated at the location you passed to the --file-name-pattern option. 

  1. Go to ./assets/restriction/test_data/test_out/result.xml

The response from the remote server is displayed:

<?xml version="1.0" encoding="UTF-8"?>
<ConceptoBO>
  <monto>5</monto>
  <numJornadas>3</numJornadas>
  <aplicaCapacidadPago>false</aplicaCapacidadPago>
  <requeridoCobranza>false</requeridoCobranza>
  <esVirtual>false</esVirtual>
</ConceptoBO>

Properties

--file-path (required)

Path to a local XSD file from which the input model of the asset metadata file is generated

--file-path ../account-by-id.xsd

--out-file-path

Path to a local XSD file from which the output model of the asset metadata file is generated.

--out-file-path ../out-account-by-id

--operation-name

The name of the added asset

--operation-name "account-by-id"

--file-name-pattern

Path to the location and the name of the XML file containing the test asset output.

The file-name-pattern is required for running ol test asset since the default location is not valid for the file-xml connector.

--file-name-pattern ./assets/account-by-id/test-data/case-3/out.xml

--base-path

The root path for the business operation output XML file. When --base-path is empty the full path is expected on the --file-name-pattern option.

--base-path "/MyRootDirectory"