agorian Contributor.
Contributor.
140 views

Help with xpath

Hi guys,

I need some help with xPath. I need the path (1a36b8dc5faa7a4d86b8830b4eacd6ab) text when component = "\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD"


<instance class-name="User" qualified-src-dn="O=Acme\OU=Usuarios\OU=Funcionarios\CN=XXXXX" src-dn="\TREE\Acme\Usuarios\Funcionarios\XXXXX" src-entry-id="219290">
<attr attr-name="DirXML-Associations">
<value timestamp="1302221030#221" type="structured">
<component name="nameSpace">1</component>
<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\SomeDriver</component>
<component name="path">01093037</component>
</value>
<value timestamp="1302260346#93" type="structured">
<component name="nameSpace">1</component>
<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\Entitlement01</component>
<component name="path">{BEFB30D6-A4A1-435A-D492-D630FBBEA1A4}</component>
</value>
<value timestamp="1559849566#65" type="structured">
<component name="nameSpace">1</component>
<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\AnotherDriver</component>
<component name="path">\TREE\Acme\Usuarios\Funcionarios\XXXXX</component>
</value>
<value timestamp="1559849566#60" type="structured">
<component name="nameSpace">1</component>
<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD</component>
<component name="path">1a36b8dc5faa7a4d86b8830b4eacd6ab</component>
</value>
</attr>
</instance>


This instance is inside a variable. I tried $variable/value[component[@name='volume']/text()='\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD']/component[@name='path'] and others different forms, but I can't either get the value node. Someone can help me?
Labels (1)
0 Likes
3 Replies
Anonymous_User Absent Member.
Absent Member.

Re: Help with xpath

On 6/13/2019 1:24 PM, agorian wrote:
>
> Hi guys,
>
> I need some help with xPath. I need the path
> (1a36b8dc5faa7a4d86b8830b4eacd6ab) text when component =
> "\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD"
>
>
> Code:
> --------------------
>
> <instance class-name="User" qualified-src-dn="O=Acme\OU=Usuarios\OU=Funcionarios\CN=XXXXX" src-dn="\TREE\Acme\Usuarios\Funcionarios\XXXXX" src-entry-id="219290">
> <attr attr-name="DirXML-Associations">
> <value timestamp="1302221030#221" type="structured">
> <component name="nameSpace">1</component>
> <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\SomeDriver</component>
> <component name="path">01093037</component>
> </value>
> <value timestamp="1302260346#93" type="structured">
> <component name="nameSpace">1</component>
> <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\Entitlement01</component>
> <component name="path">{BEFB30D6-A4A1-435A-D492-D630FBBEA1A4}</component>
> </value>
> <value timestamp="1559849566#65" type="structured">
> <component name="nameSpace">1</component>
> <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\AnotherDriver</component>
> <component name="path">\TREE\Acme\Usuarios\Funcionarios\XXXXX</component>
> </value>
> <value timestamp="1559849566#60" type="structured">
> <component name="nameSpace">1</component>
> <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD</component>
> <component name="path">1a36b8dc5faa7a4d86b8830b4eacd6ab</component>
> </value>
> </attr>
> </instance>
>
> --------------------
>
>
> This instance is inside a variable. I tried
> $variable/value[component[@name='volume']/text()='\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD']/component[@name='path']
> and others different forms, but I can't either get the value node.


It matters if you used Source/Dest Attr to get the value into the
variable, or did you use a Query token?


Read all about it here:

https://community.microfocus.com/t5/Identity-Manager-Tips/Using-XPATH-to-examine-Association-values/ta-p/1775403


0 Likes
agorian Contributor.
Contributor.

Re: Help with xpath

Hi Geoffrey,

I'm using source attribute, but will follow the link you posted.

Thank you
0 Likes
Knowledge Partner
Knowledge Partner

Re: Help with xpath


It matters if you used Source/Dest Attr to get the value into the variable, or did you use a Query token?

Read all about it here:

https://community.microfocus.com/t5/Identity-Manager-Tips/Using-XPATH-to-examine-Association-values/ta-p/1775403

I often find it helpful to trace nodeset variables in their serialized form while developing with something like this:

 

<do-set-local-variable name="trace" scope="policy">
    <arg-string>
        <token-xml-serialize>
            <token-local-variable name="associations"/>
        </token-xml-serialize>
    </arg-string>
</do-set-local-variable>

 

This will result in the following trace:

 

Driver :      Action: do-set-local-variable("associations",scope="policy",arg-node-set(token-src-attr("DirXML-Associations"))).
Driver :        arg-node-set(token-src-attr("DirXML-Associations"))
Driver :          token-src-attr("DirXML-Associations")
Driver :            Query from policy
Driver :            
<nds dtdversion="4.0" ndsversion="8.x">
  <source>
    <product version="4.7.1.0">DirXML</product>
    <contact>NetIQ Corporation</contact>
  </source>
  <input>
    <query class-name="User" dest-dn="o=dirXML Test\ou=Users\cn=User1" scope="entry">
      <association>o=dirXML Test\ou=Users\cn=User1</association>
      <read-attr attr-name="DirXML-Associations"/>
    </query>
  </input>
</nds>
Driver :            Query from policy result
Driver :            
<nds dtdversion="4.0" ndsversion="8.x">
  <source>
    <product version="4.7.1.0">DirXML</product>
    <contact>NetIQ Corporation</contact>
  </source>
  <output>
    <instance class-name="User" qualified-src-dn="O=Acme\OU=Usuarios\OU=Funcionarios\CN=XXXXX" src-dn="\TREE\Acme\Usuarios\Funcionarios\XXXXX" src-entry-id="219290">
      <attr attr-name="DirXML-Associations">
        <value timestamp="1302221030#221" type="structured">
          <component name="nameSpace">1</component>
          <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\SomeDriver</component>
          <component name="path">01093037</component>
        </value>
        <value timestamp="1302260346#93" type="structured">
          <component name="nameSpace">1</component>
          <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\Entitlement01</component>
          <component name="path">{BEFB30D6-A4A1-435A-D492-D630FBBEA1A4}</component>
        </value>
        <value timestamp="1559849566#65" type="structured">
          <component name="nameSpace">1</component>
          <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\AnotherDriver</component>
          <component name="path">\TREE\Acme\Usuarios\Funcionarios\XXXXX</component>
        </value>
        <value timestamp="1559849566#60" type="structured">
          <component name="nameSpace">1</component>
          <component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD</component>
          <component name="path">1a36b8dc5faa7a4d86b8830b4eacd6ab</component>
        </value>
      </attr>
    </instance>
  </output>
</nds>
Driver :          Token Value: {<value> @timestamp = "1302221030#221" @type = "structured",<value> @timestamp = "1302260346#93" @type = "structured",<value> @timestamp = "1559849566#65" @type = "structured",<value> @timestamp = "1559849566#60" @type = "structured"}.
Driver :          Arg Value: {<value> @timestamp = "1302221030#221" @type = "structured",<value> @timestamp = "1302260346#93" @type = "structured",<value> @timestamp = "1559849566#65" @type = "structured",<value> @timestamp = "1559849566#60" @type = "structured"}.
Driver :      Action: do-set-local-variable("trace",scope="policy",token-xml-serialize(token-local-variable("associations"))).
Driver :        arg-string(token-xml-serialize(token-local-variable("associations")))
Driver :          token-xml-serialize(token-local-variable("associations"))
Driver :            token-xml-serialize(token-local-variable("associations"))
Driver :              token-local-variable("associations")
Driver :              Token Value: {<value> @timestamp = "1302221030#221" @type = "structured",<value> @timestamp = "1302260346#93" @type = "structured",<value> @timestamp = "1559849566#65" @type = "structured",<value> @timestamp = "1559849566#60" @type = "structured"}.
Driver :              Arg Value: {<value> @timestamp = "1302221030#221" @type = "structured",<value> @timestamp = "1302260346#93" @type = "structured",<value> @timestamp = "1559849566#65" @type = "structured",<value> @timestamp = "1559849566#60" @type = "structured"}.
Driver :            Token Value: "<value timestamp="1302221030#221" type="structured">
	<component name="nameSpace">1</component>
	<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\SomeDriver</component>
	<component name="path">01093037</component>
</value><value timestamp="1302260346#93" type="structured">
	<component name="nameSpace">1</component>
	<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\Entitlement01</component>
	<component name="path">{BEFB30D6-A4A1-435A-D492-D630FBBEA1A4}</component>
</value><value timestamp="1559849566#65" type="structured">
	<component name="nameSpace">1</component>
	<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\AnotherDriver</component>
	<component name="path">\TREE\Acme\Usuarios\Funcionarios\XXXXX</component>
</value><value timestamp="1559849566#60" type="structured">
	<component name="nameSpace">1</component>
	<component name="volume">\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD</component>
	<component name="path">1a36b8dc5faa7a4d86b8830b4eacd6ab</component>
</value>".

 

...and reveal that your variable has a set of value nodes as it's contents, it's not an instance node as you would probably expect. Therefore you'd need to treat the variable as the value node:

 

Driver :      Action: do-set-local-variable("path",scope="policy",token-xpath("$associations[component[@name='volume' and text()='\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD']]/component[@name='path']")).
Driver :        arg-string(token-xpath("$associations[component[@name='volume' and text()='\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD']]/component[@name='path']"))
Driver :          token-xpath("$associations[component[@name='volume' and text()='\TREE\Acme\Sistema\IDM\DriverSet01\IDM2AD']]/component[@name='path']")
Driver :            Token Value: "1a36b8dc5faa7a4d86b8830b4eacd6ab".
Driver :          Arg Value: "1a36b8dc5faa7a4d86b8830b4eacd6ab".

 

If you use token query, though, the variable contains one ore more instance nodes, in which case you'd have to use something like $var//value[component[...

 

Tags (2)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.