Application Delivery Management
Application Modernization & Connectivity
CyberRes
IT Operations Management
Here is the Package file attached with examples from the article.
CIS-NODE-STR_0.0.1.20141015085602.zip
One of the cool things I like about IDM is that I am constantly learning new things, new tricks, new features. There are some minor things in Designer that I only found out about, after using it for years. There are behaviors of the engine still to be learned, I would expect.
What is interesting is how much of this stuff is undocumented. Mostly this is because they are edge cases, or interestingly strange behaviors that do not normally occur. Or else the bulk of things to document is so great that 100% coverage is unlikely to ever occur. But since we have Cool Solutions, I can write about stuff I find that is missed.
One very interesting thing I have been meaning to write about for a while is the difference in how 'things' behave in a nodeset vs string context.
That does not seem like a clear concept, but if you are used to IDM it should be fairly straightforward. Mostly, when you do XPATH or use local variables, you need to know if this variable, or target of your XPATH is a nodeset or a string.
Obviously, XPATH differs if you have a string or a nodeset. A nodeset of XML you can walk by specifying nodes, with predicates and whatnot. A string you can use the various string functions on. (contains(), substring-before(), etc). But you need to know what your target looks like before approaching using or manipulating it.
Well what is you can define a target, and you get different results if you store it in a nodeset variable, or in a string variable. (Heck, how about examples of an object type variable? That would be cool!)
My plan for this article is that I will write up as many examples as I can think of, and build them all into a Package I will attach to the article. If you have additional examples, contact me (email if you can guess it, my full name using GMail, or leave a comment) and I will try to add in your example, and update the Package with an example of the difference that you can run through Simulator and play with.
Take a look at the first rule "[CIS] First example - list GCV" in the Packaged Subscriber Event Transform policy "CIS-NODE-STR-Examples by Geoffrey" for the examples I will be working through below.
The simplest example I can think of is a List type Global Configuration. This consists of multiple values, shown in the GUI. Then if you set a local variable, string type, you get the values separated, by the specified separator value. (When you define a List type GCV there is an XML attribute item-separator=","). However when you treat it like a nodeset of values that you can loop over or do tricks with.
What is even more interesting is that if you do not XML Serialize the nodeset, but just try use it again as a string (say in a Trace token) you actually only get the first value! I personally expected to get all the values concatenated together, but in fact you get only the first.
Here is my first example rule:
<rule>
<description>[CIS] First example - list GCV</description>
<comment xml:space="preserve">Run this through Simulator and look at the output.</comment>
<comment name="author" xml:space="preserve">Geoffrey Carman</comment>
<comment name="version" xml:space="preserve">1</comment>
<comment name="lastchanged" xml:space="preserve">Oct 14, 2014</comment>
<conditions>
<and/>
</conditions>
<actions>
<do-trace-message disabled="true">
<arg-string>
<token-text xml:space="preserve">No conditions, since testing in Simulator.</token-text>
</arg-string>
</do-trace-message>
<do-set-local-variable name="STRING" scope="policy">
<arg-string>
<token-global-variable name="gcv.example.list"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="NODESET" scope="policy">
<arg-node-set>
<token-global-variable name="gcv.example.list"/>
</arg-node-set>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Look at the output as a STRING:
</token-text>
<token-local-variable name="STRING"/>
<token-text xml:space="preserve">
and now as a NODESET. See what I mean?
</token-text>
<token-xml-serialize>
<token-local-variable name="NODESET"/>
</token-xml-serialize>
<token-text xml:space="preserve">
But even better! Watch what happens when you do not XML Serialize the nodeset!
</token-text>
<token-local-variable name="NODESET"/>
</arg-string>
</do-trace-message>
</actions>
</rule>
Generic Null : Arg Value: "Look at the output as a STRING:
First Example,mySAP.domain.com,1234,PRDCLNT100.Second Example,mySAP.domain.com,4321,QASCLINT200
and now as a NODESET. See what I mean?
<instance>
<definition display-name="Name" name="gcv.example.structured.name" type="string">
<description></description>
<value xml:space="preserve">First Example</value>
</definition>
<definition display-name="Hostname" name="gcv.example.structured.hostname" type="string">
<description></description>
<value xml:space="preserve">mySAP.domain.com</value>
</definition>
<definition display-name="Port" name="gcv.example.structured.port" type="string">
<description></description>
<value xml:space="preserve">1234</value>
</definition>
<definition display-name="Logical System Name" name="gcv.example.structured.lsname" type="string">
<description></description>
<value xml:space="preserve">PRDCLNT100</value>
</definition>
</instance><instance>
<definition display-name="Name" name="gcv.example.structured.name" type="string">
<description></description>
<value xml:space="preserve">Second Example</value>
</definition>
<definition display-name="Hostname" name="gcv.example.structured.hostname" type="string">
<description></description>
<value xml:space="preserve">mySAP.domain.com</value>
</definition>
<definition display-name="Port" name="gcv.example.structured.port" type="string">
<description></description>
<value xml:space="preserve">4321</value>
</definition>
<definition display-name="Logical System Name" name="gcv.example.structured.lsname" type="string">
<description></description>
<value xml:space="preserve">QASCLINT200</value>
</definition>
</instance>
But even better! Watch what happens when you do not XML Serialize the nodeset!
First ExamplemySAP.domain.com1234PRDCLNT100".
<do-for-each>
<arg-node-set>
<token-local-variable name="NODESET"/>
</arg-node-set>
<arg-actions>
<do-trace-message>
<arg-string>
<token-xpath expression='$current-node/definition[@name="gcv.example.structured.port"]/value'/>
</arg-string>
</do-trace-message>
</arg-actions>
</do-for-each>
Generic Null : Action: do-set-local-variable("NODESET",scope="policy",arg-node-set(token-global-variable("gcv.example.list"))).
Generic Null : arg-node-set(token-global-variable("gcv.example.list"))
Generic Null : token-global-variable("gcv.example.list")
Generic Null : Token Value: {"ItemTheFirst","ItemTheSecond","ItemTheThird"}.
Generic Null : Action: do-set-local-variable("NODESET",scope="policy",arg-node-set(token-global-variable("gcv.example.structured"))).
Generic Null : arg-node-set(token-global-variable("gcv.example.structured"))
Generic Null : token-global-variable("gcv.example.structured")
Generic Null : Token Value: {<instance>,<instance>}.