XML Functions Plugin - Macros - Create File


# CREATE FILE {output} FROM {input} BY APPLYIN XSLT {stylesheet}

What ?

This macro applies a stylesheet to a xml file in order to create a file resource and logs the result in the console at DEBUG level.

Underlying instructions :

LOAD {input} AS __input{%%r1}.xml.file
CONVERT __input{%%r1}.xml.file TO xml(structured) AS __input{%%r1}.xml

LOAD {stylesheet} AS __stylesheet{%%r1}.xslt.file
CONVERT __stylesheet{%%r1}.xslt.file TO xml(structured) AS __stylesheet{%%r1}.xslt.xml
CONVERT __stylesheet{%%r1}.xslt.xml TO xslt AS __stylesheet{%%r1}.xslt

CONVERT __input{%%r1}.xml TO file(xslt) USING __stylesheet{%%r1}.xslt AS {output}
EXECUTE log WITH {output} USING $(logLevel: DEBUG,multiline: yes) AS $()

> Input :

  • {input} : The name of the file to convert (xml type file).
  • {stylesheet} : The name of the stylesheet file (xslt type file).

> Output :

  • {output} : The name of the converted resource (file type resource).

Example :

# CREATE FILE sample-dataset-resource.xml FROM sample-dataset.xml BY APPLYIN XSLT table1n2sorted.xslt

Resources :

../../_images/xml-functions-macros-create-file-1-resources.png

SKF script :

../../_images/xml-functions-macros-create-file-1-script.png

Console output in DEBUG mode :

../../_images/xml-functions-macros-create-file-1-stacktrace.png


# CREATE FILE {output} FROM {input} BY APPLYIN XSLT {stylesheet} USING {xslt_config}

What ?

This macro applies a stylesheet and a config resource to a xml file in order to create a file resource and logs the result in the console at DEBUG level. Additional configurations can be done with a config file.

Underlying instructions :

LOAD {input} AS __input{%%r1}.xml.file
CONVERT __input{%%r1}.xml.file TO xml(structured) AS __input{%%r1}.xml

LOAD {stylesheet} AS __stylesheet{%%r1}.xslt.file
CONVERT __stylesheet{%%r1}.xslt.file TO xml(structured) AS __stylesheet{%%r1}.xslt.xml
CONVERT __stylesheet{%%r1}.xslt.xml TO xslt AS __stylesheet{%%r1}.xslt

CONVERT __input{%%r1}.xml TO file(xslt) USING __stylesheet{%%r1}.xslt,{xslt_config} AS {output}
EXECUTE log WITH {output} USING $(logLevel: DEBUG,multiline: yes) AS $()

> Input :

  • {input} : The name of the file to convert (xml type file).
  • {stylesheet} : The name of the stylesheet file (xslt type file).
  • {xslt_config} : The name of the loaded configuration resource (file type resource, from a properties type file). It can be used to normalize the output (normalize = true).

> Output :

  • {output} : The name of the converted resource (file type resource).

Example :

# CREATE FILE sample-dataset-resource.xml FROM sample-dataset.xml BY APPLYIN XSLT table1n2sorted.xslt USING config-resource.file

Resources :

../../_images/xml-functions-macros-create-file-2-resources.png

SKF script :

../../_images/xml-functions-macros-create-file-2-script.png

Console output in DEBUG mode :

../../_images/xml-functions-macros-create-file-2-stacktrace.png


# CREATE FILE {output} FROM XML RESOURCE {input} BY APPLYIN XSLT {stylesheet}

What ?

This macro applies a stylesheet to a loaded xml resource in order to create a file resource and logs the result in the console at DEBUG level.

Underlying instructions :

LOAD {stylesheet} AS __stylesheet{%%r1}.xslt.file
CONVERT __stylesheet{%%r1}.xslt.file TO xml(structured) AS __stylesheet{%%r1}.xslt.xml
CONVERT __stylesheet{%%r1}.xslt.xml TO xslt AS __stylesheet{%%r1}.xslt

CONVERT {input} TO file(xslt) USING __stylesheet{%%r1}.xslt AS {output}
EXECUTE log WITH {output} USING $(logLevel: DEBUG,multiline: yes) AS $()

> Input :

  • {input} : The name of the loaded resource to convert (xml type resource).
  • {stylesheet} : The name of the stylesheet file (xslt type file).

> Output :

  • {output} : The name of the converted resource (file type resource).

Example :

# CREATE FILE sample-dataset-resource-output.xml FROM XML RESOURCE sample-dataset-resource.xml BY APPLYIN XSLT table1n2sorted.xslt

Resources :

../../_images/xml-functions-macros-create-file-3-resources.png

SKF script :

In the SETUP phase, we load the sample-dataset.xml and replace all the occurrences of ‘${hello}’ by ‘Goodbye’ with a SUBSTITUTE KEYS macro. The resulting resource is then converted to a xml type resource and used in the CREATE FILE macro.

../../_images/xml-functions-macros-create-file-3-script.png

Console output in DEBUG mode :

../../_images/xml-functions-macros-create-file-3-stacktrace.png


# CREATE FILE {output} FROM XML RESOURCE {input} BY APPLYIN XSLT {stylesheet} USING {xslt_config}

What ?

This macro applies a stylesheet and a config resource to a loaded xml resource in order to create a file resource and logs the result in the console at DEBUG level. Additional configurations can be done with a config file.

Underlying instructions :

LOAD {stylesheet} AS __stylesheet{%%r1}.xslt.file
CONVERT __stylesheet{%%r1}.xslt.file TO xml(structured) AS __stylesheet{%%r1}.xslt.xml
CONVERT __stylesheet{%%r1}.xslt.xml TO xslt AS __stylesheet{%%r1}.xslt

CONVERT {input} TO file(xslt) USING __stylesheet{%%r1}.xslt,{xslt_config} AS {output}
EXECUTE log WITH {output} USING $(logLevel: DEBUG,multiline: yes) AS $()

> Input :

  • {input} : The name of the loaded resource to convert (xml type resource).
  • {stylesheet} : The name of the stylesheet resource (xslt type file).
  • {xslt_config} : The name of the loaded configuration resource (file type resource, from a properties type file). It can be used to normalize the output (normalize = true).

> Output :

  • {output} : The name of the converted resource (file type resource).

Example :

# CREATE FILE sample-dataset-resource-output.xml FROM XML RESOURCE sample-dataset-resource.xml BY APPLYIN XSLT table1n2sorted.xslt USING config-resource.file

Resources :

../../_images/xml-functions-macros-create-file-4-resources.png

SKF script :

In the SETUP phase, we load the sample-dataset.xml and replace all the occurrences of ‘${hello}’ by ‘Goodbye’ with a SUBSTITUTE KEYS macro. The resulting resource is then converted to a xml type resource and used in the CREATE FILE macro.

../../_images/xml-functions-macros-create-file-4-script.png

Console output in DEBUG mode :

../../_images/xml-functions-macros-create-file-4-stacktrace.png