Event/Alien2XML definition
From PlcWiki
(Created page with 'Device events have prefix <code>workplace.device.<name>.event.</code> while alien2xml node definitions have prefix <code>node.</code> Example (alien2xml): node.product = .* nā¦') |
|||
Line 1: | Line 1: | ||
- | Device events have prefix <code>workplace.device.<name>.event.</code> while alien2xml node definitions have prefix <code>node.</code> | + | Device events have prefix '''<code>workplace.device.<name>.event.</code>''' while alien2xml node definitions have prefix '''<code>node.</code>''' |
Example (alien2xml): | Example (alien2xml): | ||
Line 5: | Line 5: | ||
node.product = .* | node.product = .* | ||
node.product.item.regex = {headend}(.*?){part} | node.product.item.regex = {headend}(.*?){part} | ||
- | node.product.item = [[:]] | + | node.product.item = <nowiki>[[8:25]]</nowiki> |
node.product.header.regex = "{head}(.*?){headend}" | node.product.header.regex = "{head}(.*?){headend}" | ||
node.product.header = <node:header=[[:]]> | node.product.header = <node:header=[[:]]> | ||
Line 14: | Line 14: | ||
node.header.title = [[:]] | node.header.title = [[:]] | ||
+ | Example input: | ||
+ | {head}msg title{headend}ignored;fixed_width_item_contents;ignored{part}partnum1{partend}not used{part}partnum2{partend} | ||
+ | |||
+ | Example output: | ||
+ | <!DOCTYPE product> | ||
+ | <product> | ||
+ | <header> | ||
+ | <title>msg title</title> | ||
+ | </header> | ||
+ | <item>fixed_width_item_contents</item> | ||
+ | <part>partnum1</part> | ||
+ | <part>partnum2</part> | ||
+ | </product> | ||
The first condition for node (or event) to be created is this: | The first condition for node (or event) to be created is this: | ||
node.<node_name> = <regex> | node.<node_name> = <regex> | ||
- | If the input (alien input or raw device input) doesn't match the regex, any other definition rules are ignored and an empty XML element <code>node_name</code> (or no event) is generated. | + | If the input (alien input or raw device input) doesn't match the regex, any other definition rules are ignored and an empty XML element '''<code>node_name</code>''' (or no event) is generated. |
+ | If the regex contains a group (enclosed in a parenthesis pair), the whole input is reduced to this group substring for later processing. | ||
+ | The node (or event) can contain any number of properties (these properties appear as subelements in alien2xml output). | ||
+ | The definition of a property is as follows: | ||
+ | node.<node_name>.<property_name> = _text_ | ||
+ | or | ||
+ | node.<node_name>.<property_name> = <node:_subnode_=_text_> | ||
+ | where '''<code>_text_</code>''' is a text constant with any number of '''<code><nowiki>[[from:length]]</nowiki></code>''' input substring expressions. | ||
+ | Input substring expression defines a substring of original input (or input reduced by any regex group definitions). Omitted '''<code>from</code>''' means index 0, omitted '''<code>length</code>''' means the rest of the input. | ||
+ | |||
+ | When '''<code><node:_subnode_=_text_></code>''' is used as a value, it tells alien2xml processor that this property is a subnode and should be expanded by using appropriate '''<code>node._subnode_</code>''' definition. | ||
+ | |||
+ | |||
+ | You can use any combination of text |
Revision as of 07:58, 10 May 2011
Device events have prefix workplace.device.<name>.event.
while alien2xml node definitions have prefix node.
Example (alien2xml):
node.product = .* node.product.item.regex = {headend}(.*?){part} node.product.item = [[8:25]] node.product.header.regex = "{head}(.*?){headend}" node.product.header = <node:header=[[:]]> node.product.part.list_member = "{part}(.*?){partend}" node.product.part = [[:]] node.header = .* node.header.title = [[:]]
Example input:
{head}msg title{headend}ignored;fixed_width_item_contents;ignored{part}partnum1{partend}not used{part}partnum2{partend}
Example output:
<!DOCTYPE product> <product> <header> <title>msg title</title> </header> <item>fixed_width_item_contents</item> <part>partnum1</part> <part>partnum2</part> </product>
The first condition for node (or event) to be created is this:
node.<node_name> = <regex>
If the input (alien input or raw device input) doesn't match the regex, any other definition rules are ignored and an empty XML element node_name
(or no event) is generated.
If the regex contains a group (enclosed in a parenthesis pair), the whole input is reduced to this group substring for later processing.
The node (or event) can contain any number of properties (these properties appear as subelements in alien2xml output).
The definition of a property is as follows:
node.<node_name>.<property_name> = _text_
or
node.<node_name>.<property_name> = <node:_subnode_=_text_>
where _text_
is a text constant with any number of [[from:length]]
input substring expressions.
Input substring expression defines a substring of original input (or input reduced by any regex group definitions). Omitted from
means index 0, omitted length
means the rest of the input.
When <node:_subnode_=_text_>
is used as a value, it tells alien2xml processor that this property is a subnode and should be expanded by using appropriate node._subnode_
definition.
You can use any combination of text