Xpath syntax to read all attributes in a generated query

Hi,

I'm again ask help to XPATH expert to get information from an XML query.

The source XML/XDS  is a query generated by the REST driver :

<nds dtdversion="3.5" ndsversion="8.x">
<source>
<product build="20181130_1107" instance="Rest Driver" version="1.0.2.0">Identity Manager REST Driver</product>
<contact>NetIQ Corporation.</contact>
</source>
<input>
<query class-name="User">
<search-class class-name="User"/>
<search-attr attr-name="cn ">
<value> *bla</value>
</search-attr>
<read-attr attr-name="CN "/>
<read-attr attr-name=" Surname "/>
<read-attr attr-name=" Given Name "/>
<read-attr attr-name=" Internet Email Address"/>
</query>
</input>
</nds>

 

And I need to get each queried attribute to make some condition, I did that :

<rule>
<description>Check query content - idsa 16 sept 2019</description>
<conditions>
<and>
<if-operation mode="nocase" op="equal">query</if-operation>
<if-xpath op="true">@class-name="User"</if-xpath>
</and>
</conditions>
<actions>
<do-set-local-variable name="ReadAttrName" scope="policy">
<arg-node-set>
<token-xpath expression="$current-op/read-attr/@attr-name[last()]"/>
</arg-node-set>
</do-set-local-variable>
<do-for-each>
<arg-node-set>
<token-xpath expression="$current-node/read-attr/@attr-name"/>
</arg-node-set>
<arg-actions>
<do-set-local-variable name="attrvalue" scope="policy">
<arg-node-set>
<token-xpath expression="$current-value"/>
</arg-node-set>
</do-set-local-variable>
</arg-actions>
</do-for-each>
</actions>
</rule>

I can see all attributes in the local variable ReadAttrName, but the "for each" does not give any value.

 

Any help ?

 

Thanks a lot.

 

Sylvain

  • Ok I made this rule :

    <rule>
    <description>Check query content - 16 sept 2019</description>
    <conditions>
    <and>
    <if-operation mode="nocase" op="equal">query</if-operation>
    <if-xpath op="true">@class-name="User"</if-xpath>
    </and>
    </conditions>
    <actions>
    <do-set-local-variable name="ReadAttrName" scope="policy">
    <arg-node-set>
    <token-xpath expression="$current-op/read-attr[@attr-name]"/>
    </arg-node-set>
    </do-set-local-variable>
    <do-for-each>
    <arg-node-set>
    <token-xpath expression="$ReadAttrName[@attr-name]"/>
    </arg-node-set>
    <arg-actions>
    <do-set-local-variable name="attrvalue" scope="policy">
    <arg-node-set>
    <token-xpath expression="$current-node/@attr-name"/>
    </arg-node-set>
    </do-set-local-variable>
    </arg-actions>
    </do-for-each>
    </actions>
    </rule>

     

    That works better and give each attribute like : Arg Value: {@attr-name = " Internet Email Address"}.

    How can I get only the attribute name , Internet Email Address" ?

     

    thanks

     

    Sylvain

  • Verified Answer

    Got it.

    Changing the variable type for "node set" to string give the right value :

    <rule>
    <description>Check query content - idsa 16 sept 2019</description>
    <conditions>
    <and>
    <if-operation mode="nocase" op="equal">query</if-operation>
    <if-xpath op="true">@class-name="User"</if-xpath>
    </and>
    </conditions>
    <actions>
    <do-set-local-variable name="ReadAttrName" scope="policy">
    <arg-node-set>
    <token-xpath expression="$current-op/read-attr[@attr-name]"/>
    </arg-node-set>
    </do-set-local-variable>
    <do-for-each>
    <arg-node-set>
    <token-xpath expression="$ReadAttrName[@attr-name]"/>
    </arg-node-set>
    <arg-actions>
    <do-set-local-variable name="attrvalue" scope="policy">
    <arg-string>
    <token-xpath expression="$current-node/@attr-name"/>
    </arg-string>
    </do-set-local-variable>
    </arg-actions>
    </do-for-each>
    </actions>
    </rule>

    The result is :

    Performing actions for local-variable(current-node) = <read-attr> @attr-name = " Internet Email Address".
    [09/16/19 16:35:21.635]:Rest Driver PT: Action: do-set-local-variable("attrvalue",scope="policy",token-xpath("$current-node/@attr-name")).
    [09/16/19 16:35:21.635]:Rest Driver PT: arg-string(token-xpath("$current-node/@attr-name"))
    [09/16/19 16:35:21.635]:Rest Driver PT: token-xpath("$current-node/@attr-name")
    [09/16/19 16:35:21.635]:Rest Driver PT: Token Value: " Internet Email Address".
    [09/16/19 16:35:21.635]:Rest Driver PT: Arg Value: " Internet Email Address".