Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Anonymous_User Absent Member.
Absent Member.
121 views

Delimited text output has no value for attrs with remove-all-valuesfollowed by real attrs

I'm sure others have hit this, but I've never had to really fix it before
and I am not as good at XPath or XSLT as I should be, so this is probably
trivial. Searching for solutions is not turning up much for me so far. A
simple trace causing me pain and suffering (and weeping, and wailing) follows:

Code:
--------------------
<nds dtdversion="4.0" ndsversion="8.x">
<source>
<product edition="Advanced" version="4.0.1.0">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<modify class-name="User" from-merge="true"
qualified-src-dn="O=tstidm\OU=Users\OU=Empl\CN=sann"
src-dn="\TEST_IDM\tstidm\Users\Empl\sann" src-entry-id="98089">
<association>30992</association>
<modify-attr attr-name="workforceID">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="middleName">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="lenelinternalid">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="Surname">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="imgdatatype">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="lenelobjecttype">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="imgobjtype">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="Given Name">
<remove-all-values/>
</modify-attr>
<modify-attr attr-name="Surname">
<add-value>
<value timestamp="1377877424#1564" type="string">Ann</value>
</add-value>
</modify-attr>
<modify-attr attr-name="Given Name">
<add-value>
<value timestamp="1377877424#1562" type="string">Sunny</value>
</add-value>
</modify-attr>
<operation-data/>
</modify>
</input>
</nds>
--------------------

The problem is that the XSLT in the output transformation policyset is
matching on the first instance of the attribute which has no value, so the
CSV has no value in that field when I want it to skip over the
remove-all-values bit and instead get the attribute that actually has a
value. A possible solution is to strip out the remove-all-values portion
so that the only possible match is the one with a real value. Any good
ideas on how to implement this? It can be XSLT, or XPath, or something in
policy that I haven't remembered... whatever.

Thx.
Labels (1)
0 Likes
3 Replies
Knowledge Partner
Knowledge Partner

Re: Delimited text output has no value for attrs with remove-all-values followed by real attrs

ab wrote:

> The problem is that the XSLT in the output transformation policyset is
> matching on the first instance of the attribute which has no value, so the
> CSV has no value in that field when I want it to skip over the
> remove-all-values bit and instead get the attribute that actually has a
> value. A possible solution is to strip out the remove-all-values portion
> so that the only possible match is the one with a real value. Any good
> ideas on how to implement this? It can be XSLT, or XPath, or something in
> policy that I haven't remembered... whatever.


stripping is trivial, indeed:

<do-strip-xpath expression='modify-attr[remove-all-values and not(add-attr)]'/>

but you could as well merge the attr nodes instead (assuming only the first
node of every attr has a remove-all-values subnode):

<do-for-each>
<arg-node-set>
<token-text xml:space="preserve">Given Name</token-text>
<token-text xml:space="preserve">Surname</token-text>
</arg-node-set>
<arg-actions>
<do-append-xml-element expression='modify-attr[@attr-name=$current-node and
remove-all-values and not(add-value)]' name="add-value"/>
<do-clone-xpath dest-expression='modify-attr[@attr-name=$current-node and
remove-all-values]/add-value'
src-expression='modify-attr[@attr-name="~aie.driver.managedValuesAttr~" and
not(remove-all-values)]//value'/>
<do-strip-xpath expression='modify-attr[@attr-name=$current-node and
not(remove-all-values)]'/>
</arg-actions>
</do-for-each>

Don't forget to clean up empty remaining nodes:

<rule>
<description>Strip Empty Nodes</description>
<conditions>
<or>
<if-operation mode="regex" op="equal">add|modify|instance</if-operation>
</or>
</conditions>
<actions>
<do-strip-xpath expression=".//value[not(*) and (not(text()) or
text()='')]"/>
<do-strip-xpath expression="self::modify/modify-attr/remove-value[not(*)]"/>
<do-strip-xpath expression="self::modify/modify-attr/add-value[not(*)]"/>
<do-strip-xpath expression="*[@attr-name and not(*)]"/>
</actions>
</rule>
______________________________________________
https://www.is4it.de/identity-access-management
0 Likes
Knowledge Partner
Knowledge Partner

Re: Delimited text output has no value for attrs with remove-all-values followed by real attrs

Lothar Haeger wrote:

> <do-strip-xpath expression='modify-attr[remove-all-values and

not(add-attr)]'/>

should be "not(add-value)", though. So much for trivial...
______________________________________________
https://www.is4it.de/identity-access-management
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Delimited text output has no value for attrs with remove-all-valuesfollowed by real attrs


Hi Aaron,
This small xpath will help you:

<do-strip-xpath
expression="self::modify/modify-attr/remove-all-values[not(*)]"/>

your doc will be transformed to

<nds dtdversion="4.0" ndsversion="8.x">
<source>
<product version="?.?.?.?">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<modify class-name="User" from-merge="true"
qualified-src-dn="O=tstidm\OU=Users\OU=Empl\CN=sann"
src-dn="\TEST_IDM\tstidm\Users\Empl\sann" src-entry-id="98089">
<association>30992</association>
<modify-attr attr-name="Surname">
<add-value>
<value timestamp="1377877424#1564" type="string">Ann</value>
</add-value>
</modify-attr>
<modify-attr attr-name="Given Name">
<add-value>
<value timestamp="1377877424#1562"
type="string">Sunny</value>
</add-value>
</modify-attr>
</modify>
</input>
</nds>

ab;233366 Wrote:
> I'm sure others have hit this, but I've never had to really fix it
> before
> and I am not as good at XPath or XSLT as I should be, so this is
> probably
> trivial. Searching for solutions is not turning up much for me so far.
> A
> simple trace causing me pain and suffering (and weeping, and wailing)
> follows:
>
> Code:
> --------------------
> <nds dtdversion="4.0" ndsversion="8.x">
> <source>
> <product edition="Advanced" version="4.0.1.0">DirXML</product>
> <contact>Novell, Inc.</contact>
> </source>
> <input>
> <modify class-name="User" from-merge="true"
> qualified-src-dn="O=tstidm\OU=Users\OU=Empl\CN=sann"
> src-dn="\TEST_IDM\tstidm\Users\Empl\sann" src-entry-id="98089">
> <association>30992</association>
> <modify-attr attr-name="workforceID">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="middleName">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="lenelinternalid">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="Surname">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="imgdatatype">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="lenelobjecttype">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="imgobjtype">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="Given Name">
> <remove-all-values/>
> </modify-attr>
> <modify-attr attr-name="Surname">
> <add-value>
> <value timestamp="1377877424#1564" type="string">Ann</value>
> </add-value>
> </modify-attr>
> <modify-attr attr-name="Given Name">
> <add-value>
> <value timestamp="1377877424#1562" type="string">Sunny</value>
> </add-value>
> </modify-attr>
> <operation-data/>
> </modify>
> </input>
> </nds>
> --------------------
>
> The problem is that the XSLT in the output transformation policyset is
> matching on the first instance of the attribute which has no value, so
> the
> CSV has no value in that field when I want it to skip over the
> remove-all-values bit and instead get the attribute that actually has a
> value. A possible solution is to strip out the remove-all-values
> portion
> so that the only possible match is the one with a real value. Any good
> ideas on how to implement this? It can be XSLT, or XPath, or something
> in
> policy that I haven't remembered... whatever.
>
> Thx.



--
al_b
------------------------------------------------------------------------
al_b's Profile: https://forums.netiq.com/member.php?userid=209
View this thread: https://forums.netiq.com/showthread.php?t=48554

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.