I am in the process of updating our PeopleSoft driver and I am trying to
replace as much of the XSLT style sheets with DirXML script so it is
easier to work with. I have most of it completed but I am having a
problem with the PublisherCommandTransformSS. I am working on the parts
that set the manager and directreports attributes on the accounts.

I start by doing a query of the destination datastore for a user with a
workforceID that matches the managerworkforceID of the user we are
adding/modifying and retrieving that users directreports which I place
into a local nodeset variable. Then I try to do a for-each loop through
the nodeset and try to determine if the user is already listed in the
managers directreports. When I run it through the simulator or in the
driver itself, it does not actually loop through the entries. It looks
like it just combines all the returned results into one value.

I have never done anything with nodesets before so I can't figure out
what I am doing wrong. I have been searching all over for examples but
everything I find matches what I am doing. I am hoping fresh eyes will
show me the error of my ways. :-) The following is the rule that I am
using for testing. I have also supplied the simulation trace I get when
I try and run it.


Code:
--------------------

<rule>
<description>Set Manager on User</description>
<comment xml:space="preserve">This rule sets the users 'manager' attribute.</comment>
<conditions>
<and>
<if-op-attr name="managerWorkforceID" op="available"/>
</and>
</conditions>
<actions>
<do-set-local-variable name="ManagerDirectReports" scope="policy">
<arg-node-set>
<token-query class-name="User">
<arg-match-attr name="workforceID">
<arg-value type="string">
<token-op-attr name="managerWorkforceID"/>
</arg-value>
</arg-match-attr>
<arg-string>
<token-text xml:space="preserve">directReports</token-text>
</arg-string>
</token-query>
</arg-node-set>
</do-set-local-variable>
<do-for-each>
<arg-node-set>
<token-local-variable name="ManagerDirectReports"/>
</arg-node-set>
<arg-actions>
<do-trace-message>
<arg-string>
<token-local-variable name="current-node"/>
</arg-string>
</do-trace-message>
</arg-actions>
</do-for-each>
</actions>
</rule>

--------------------



Code:
--------------------

PeopleSoft40_Adds :Applying policy: %+C%14CPub_Command_Trans%-C.
PeopleSoft40_Adds : Applying to add #1.
PeopleSoft40_Adds : Evaluating selection criteria for rule 'Set Manager on User'.
PeopleSoft40_Adds : (if-op-attr 'managerWorkforceID' available) = TRUE.
PeopleSoft40_Adds : Rule selected.
PeopleSoft40_Adds : Applying rule 'Set Manager on User'.
PeopleSoft40_Adds : Action: do-set-local-variable("ManagerDirectReports",scope="policy",arg-node-set(token-query(class-name="User",arg-match-attr("workforceID",token-op-attr("managerWorkforceID")),"directReports"))).
PeopleSoft40_Adds : arg-node-set(token-query(class-name="User",arg-match-attr("workforceID",token-op-attr("managerWorkforceID")),"directReports"))
PeopleSoft40_Adds : token-query(class-name="User",arg-match-attr("workforceID",token-op-attr("managerWorkforceID")),"directReports")
PeopleSoft40_Adds : arg-match-attr("workforceID",token-op-attr("managerWorkforceID"))
PeopleSoft40_Adds : arg-string(token-op-attr("managerWorkforceID"))
PeopleSoft40_Adds : token-op-attr("managerWorkforceID")
PeopleSoft40_Adds : Token Value: "08484".
PeopleSoft40_Adds : Arg Value: "08484".
PeopleSoft40_Adds : arg-string("directReports")
PeopleSoft40_Adds : token-text("directReports")
PeopleSoft40_Adds : Arg Value: "directReports".
PeopleSoft40_Adds : Query from policy
PeopleSoft40_Adds :
<nds dtdversion="3.5" ndsversion="8.x">
<source>
<product version="?.?.?.?">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<query class-name="User" scope="subtree">
<search-class class-name="User"/>
<search-attr attr-name="workforceID">
<value type="string">08484</value>
</search-attr>
<read-attr attr-name="directReports"/>
</query>
</input>
</nds>
PeopleSoft40_Adds : Query from policy result
PeopleSoft40_Adds :
<nds dtdversion="3.5" ndsversion="8.x">
<source>
<product version="?.?.?.?">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<output>
<instance class-name="User">
<attr attr-name="directReports">
<value type="dn">\dirXML\Users\User1</value>
<value type="dn">\dirXML\Users\User2</value>
<value type="dn">\dirXML\Users\User3</value>
</attr>
</instance>
</output>
</nds>
PeopleSoft40_Adds : Token Value: {<instance> @class-name = "User"}.
PeopleSoft40_Adds : Arg Value: {<instance> @class-name = "User"}.
PeopleSoft40_Adds : Action: do-for-each(arg-node-set(token-local-variable("ManagerDirectReports"))).
PeopleSoft40_Adds : arg-node-set(token-local-variable("ManagerDirectReports"))
PeopleSoft40_Adds : token-local-variable("ManagerDirectReports")
PeopleSoft40_Adds : Token Value: {<instance> @class-name = "User"}.
PeopleSoft40_Adds : Arg Value: {<instance> @class-name = "User"}.
PeopleSoft40_Adds : Performing actions for local-variable(current-node) = <instance> @class-name = "User".
PeopleSoft40_Adds : Action: do-trace-message(token-local-variable("current-node")).
PeopleSoft40_Adds : arg-string(token-local-variable("current-node"))
PeopleSoft40_Adds : token-local-variable("current-node")
PeopleSoft40_Adds : Token Value: "\dirXML\Users\User1\dirXML\Users\User2\dirXML\Use rs\User3".
PeopleSoft40_Adds : Arg Value: "\dirXML\Users\User1\dirXML\Users\User2\dirXML\Use rs\User3".
PeopleSoft40_Adds :\dirXML\Users\User1\dirXML\Users\User2\dirXML\Use rs\User3
PeopleSoft40_Adds :Policy returned:
PeopleSoft40_Adds :
<nds dtdversion="1.0" ndsversion="8.5" xml:space="default">
<!-- ================================================== ==========
Input document to add a User.
================================================== =============== -->
<input>
<add class-name="User" qualified-src-dn="o=dirXML Test\ou=Users\cn=User1" src-dn="o=dirXML Test\ou=Users\cn=User1">
<association>o=dirXML Test\ou=Users\cn=User1</association>
<add-attr attr-name="cn">
<value>User1</value>
</add-attr>
<add-attr attr-name="Surname">
<value>Surname1</value>
</add-attr>
<add-attr attr-name="Given Name">
<value>Given1</value>
</add-attr>
<add-attr attr-name="Full Name">
<value>Fullname1</value>
</add-attr>
<add-attr attr-name="workforceID">
<value type="string">12317</value>
</add-attr>
<add-attr attr-name="managerWorkforceID">
<value type="string">08484</value>
</add-attr>
</add>
</input>
</nds>

--------------------


--
geistc
------------------------------------------------------------------------
geistc's Profile: http://forums.novell.com/member.php?userid=424
View this thread: http://forums.novell.com/showthread.php?t=400326