Difference between revisions of "OS4X plugin os4xplugin manipulate xml"
Jump to navigation
Jump to search
(New page: Category:Plugins == Purpose == Manipulate job XML nodes via regular expressions, based on the content of the same or other XML nodes of the job XML. == Requirements == *OS4X Enterpris...) |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
*Target XPath: the target XPath expression, where the target extrapolated information is stored. | *Target XPath: the target XPath expression, where the target extrapolated information is stored. | ||
*Create non-existing target XPath: if the last node of the target XPath is not-existant, the plugin will create it. | *Create non-existing target XPath: if the last node of the target XPath is not-existant, the plugin will create it. | ||
+ | *Replace node with modification value as fix value: If enabled, the modification regular expression is the fix value which is being used for replacement, not the result of the regular expression itself. | ||
+ | |||
+ | == Behaviour == | ||
+ | *The exact same amount of source XPath results must exist as the amount of target XPath results | ||
+ | **If you modify files in a job, you can only modify target XPaths of the same amount, which is normally a file target XPath. | ||
+ | *The source XPath must be a XML node containing text. Empty text sources lead to a plugin error which aborts the job. | ||
+ | *If the target text is empty, the plugin exits with an error and the job aborts. | ||
+ | *When dealing with multiple XML results for source and target XPath expressions, the calculated target value is always put in the same XML structure where source source is located (but with calculated values of the corresponding node, see examples below). | ||
+ | |||
+ | == Examples == | ||
+ | === Scenario 1: change virtual filename based on real filename === | ||
+ | Filename example in job: | ||
+ | Yanfeng_DESADV.dat | ||
+ | |||
+ | *Source XPath: /OS4X_job/job_information/job_file/real_filename | ||
+ | *Modification regular expression: .*_(.*)..* | ||
+ | *Target XPath: /OS4X_job/job_information/job_file/virtual_filename | ||
+ | |||
+ | Plugin output: | ||
+ | <pre> | ||
+ | Source XPath: '/OS4X_job/job_information/job_file/real_filename'. | ||
+ | Modifying regular expression: '.*_(.*)\..*'. | ||
+ | Target XPath: '/OS4X_job/job_information/job_file/virtual_filename'. | ||
+ | |||
+ | Source information #1: [Yanfeng_DESADV.dat] | ||
+ | Replacement of regular expression #1: [DESADV] | ||
+ | Target XPath expression found with one resultset. | ||
+ | </pre> | ||
+ | |||
+ | === Scenario 2: change virtual filename based on real filename (multiple files in job) === | ||
+ | Filename examples in job: | ||
+ | Yanfeng_DESADV.dat | ||
+ | Other_DELIVERY.dat | ||
+ | |||
+ | *Source XPath: /OS4X_job/job_information/job_file/real_filename | ||
+ | *Modification regular expression: .*_(.*)..* | ||
+ | *Target XPath: /OS4X_job/job_information/job_file/virtual_filename | ||
+ | |||
+ | Plugin output: | ||
+ | <pre> | ||
+ | Source XPath: '/OS4X_job/job_information/job_file/real_filename'. | ||
+ | Modifying regular expression: '.*_(.*)\..*'. | ||
+ | Target XPath: '/OS4X_job/job_information/job_file/virtual_filename'. | ||
+ | Creating non-existing target XPath has been configured as true. | ||
+ | |||
+ | Source information #1: [Other_DELIVERY.dat] | ||
+ | Replacement of regular expression #1: [DELIVERY] | ||
+ | Target XPath expression found with 2 resultsets. | ||
+ | |||
+ | Source information #2: [Yanfeng_DESADV.dat] | ||
+ | Replacement of regular expression #2: [DESADV] | ||
+ | Target XPath expression found with 2 resultsets. | ||
+ | </pre> | ||
+ | |||
+ | Relevant job XML nodes changed (after plugin exection): | ||
+ | <pre> | ||
+ | <job_file> | ||
+ | <real_filename>Other_DELIVERY.dat</real_filename> | ||
+ | <virtual_filename>DELIVERY</virtual_filename> | ||
+ | </job_file> | ||
+ | <job_file> | ||
+ | <real_filename>Yanfeng_DESADV.dat</real_filename> | ||
+ | <virtual_filename>DESADV</virtual_filename> | ||
+ | </job_file> | ||
+ | </pre> | ||
+ | |||
+ | === Scenario 3: create new XML node based on real filename === | ||
+ | Filename examples in job: | ||
+ | Yanfeng_DESADV.dat | ||
+ | |||
+ | *Source XPath: /OS4X_job/job_information/job_file/real_filename | ||
+ | *Modification regular expression: .*_(.*)..* | ||
+ | *Target XPath: /OS4X_job/job_information/job_file/my_own_node | ||
+ | |||
+ | Plugin output: | ||
+ | <pre> | ||
+ | Source XPath: '/OS4X_job/job_information/job_file/real_filename'. | ||
+ | Modifying regular expression: '.*_(.*)\..*'. | ||
+ | Target XPath: '/OS4X_job/job_information/job_file/my_own_node'. | ||
+ | Creating non-existing target XPath has been configured as true. | ||
+ | |||
+ | Source information #1: [Yanfeng_DESADV.dat] | ||
+ | Replacement of regular expression #1: [DESADV] | ||
+ | Retrying with XPath [/OS4X_job/job_information/job_file]... | ||
+ | Target XPath expression found with one resultset. | ||
+ | Appending XML node: [my_own_node] | ||
+ | </pre> | ||
+ | |||
+ | Relevant job XML nodes changed (after plugin exection): | ||
+ | <pre> | ||
+ | <job_file> | ||
+ | ... | ||
+ | <my_own_node>DESADV</my_own_node> | ||
+ | </job_file> | ||
+ | </pre> |
Latest revision as of 14:33, 24 September 2019
Purpose
Manipulate job XML nodes via regular expressions, based on the content of the same or other XML nodes of the job XML.
Requirements
- OS4X Enterprise license
Configuration
- Source XPath: the source XPath expression of a XML node which contains the source text information.
- Modification regular expression: the Perl regular expression (preg) rule which defines the result text, based on the source XML node text.
- Target XPath: the target XPath expression, where the target extrapolated information is stored.
- Create non-existing target XPath: if the last node of the target XPath is not-existant, the plugin will create it.
- Replace node with modification value as fix value: If enabled, the modification regular expression is the fix value which is being used for replacement, not the result of the regular expression itself.
Behaviour
- The exact same amount of source XPath results must exist as the amount of target XPath results
- If you modify files in a job, you can only modify target XPaths of the same amount, which is normally a file target XPath.
- The source XPath must be a XML node containing text. Empty text sources lead to a plugin error which aborts the job.
- If the target text is empty, the plugin exits with an error and the job aborts.
- When dealing with multiple XML results for source and target XPath expressions, the calculated target value is always put in the same XML structure where source source is located (but with calculated values of the corresponding node, see examples below).
Examples
Scenario 1: change virtual filename based on real filename
Filename example in job:
Yanfeng_DESADV.dat
- Source XPath: /OS4X_job/job_information/job_file/real_filename
- Modification regular expression: .*_(.*)..*
- Target XPath: /OS4X_job/job_information/job_file/virtual_filename
Plugin output:
Source XPath: '/OS4X_job/job_information/job_file/real_filename'. Modifying regular expression: '.*_(.*)\..*'. Target XPath: '/OS4X_job/job_information/job_file/virtual_filename'. Source information #1: [Yanfeng_DESADV.dat] Replacement of regular expression #1: [DESADV] Target XPath expression found with one resultset.
Scenario 2: change virtual filename based on real filename (multiple files in job)
Filename examples in job:
Yanfeng_DESADV.dat Other_DELIVERY.dat
- Source XPath: /OS4X_job/job_information/job_file/real_filename
- Modification regular expression: .*_(.*)..*
- Target XPath: /OS4X_job/job_information/job_file/virtual_filename
Plugin output:
Source XPath: '/OS4X_job/job_information/job_file/real_filename'. Modifying regular expression: '.*_(.*)\..*'. Target XPath: '/OS4X_job/job_information/job_file/virtual_filename'. Creating non-existing target XPath has been configured as true. Source information #1: [Other_DELIVERY.dat] Replacement of regular expression #1: [DELIVERY] Target XPath expression found with 2 resultsets. Source information #2: [Yanfeng_DESADV.dat] Replacement of regular expression #2: [DESADV] Target XPath expression found with 2 resultsets.
Relevant job XML nodes changed (after plugin exection):
<job_file> <real_filename>Other_DELIVERY.dat</real_filename> <virtual_filename>DELIVERY</virtual_filename> </job_file> <job_file> <real_filename>Yanfeng_DESADV.dat</real_filename> <virtual_filename>DESADV</virtual_filename> </job_file>
Scenario 3: create new XML node based on real filename
Filename examples in job:
Yanfeng_DESADV.dat
- Source XPath: /OS4X_job/job_information/job_file/real_filename
- Modification regular expression: .*_(.*)..*
- Target XPath: /OS4X_job/job_information/job_file/my_own_node
Plugin output:
Source XPath: '/OS4X_job/job_information/job_file/real_filename'. Modifying regular expression: '.*_(.*)\..*'. Target XPath: '/OS4X_job/job_information/job_file/my_own_node'. Creating non-existing target XPath has been configured as true. Source information #1: [Yanfeng_DESADV.dat] Replacement of regular expression #1: [DESADV] Retrying with XPath [/OS4X_job/job_information/job_file]... Target XPath expression found with one resultset. Appending XML node: [my_own_node]
Relevant job XML nodes changed (after plugin exection):
<job_file> ... <my_own_node>DESADV</my_own_node> </job_file>