Discussion:
How to implement a Parser for "work entry" with XML output but not to a file system object
(too old to reply)
Naipaul Ojar
2012-10-24 12:46:10 UTC
Permalink
Raw Message
Dear All,

I have an example of a XML Parser, an XLS file, that can parse some attributes in "work entry" and write the output to the file system.

I need a code snip on how to setup a XML Parser, using the same XLS but we need to process some attributes in "work entry" the resultant XML object further.

This should not be too difficult, but I am missing a trick right now ...

Thanks in Advance
Eddie Hartman
2012-10-25 08:24:18 UTC
Permalink
Raw Message
Post by Naipaul Ojar
Dear All,
I have an example of a XML Parser, an XLS file, that can parse some attributes in "work entry" and write the output to the file system.
I need a code snip on how to setup a XML Parser, using the same XLS but we need to process some attributes in "work entry" the resultant XML object further.
This should not be too difficult, but I am missing a trick right now ...
Thanks in Advance
Hi Naipaul,

Let me get this straight: you are first pushing your xml through XSL transformation and then want to parse the resulting XML again?

I would use the system.xslTransform() method for the first step:
http://www.stephen-swann.co.uk/javadoc/tdi7.1/com/ibm/di/function/UserFunctions.html#xslTransform(java.lang.Object, java.lang.Object)

Our XSL Parser is designed to first transform the XML to our pre-7.0 simple XML format and then read it using the simple XML parser. If your stylesheet does not do this then I'd suggest scripting the call to xslTransform() instead.

That method call returns another xml encoded bytestream. You could then apply the XML Parser, for example using the Parser FC. Or you could script this as well. If you are using TDI 7.1.1 then you can just do this:

xmlEntry = work.fromXML(xmlString)

The fromXML() function is a static method of the Entry class, so any Entry will do. Or you can use the class itself:

xmlEntry = com.ibm.di.entry.Entry.fromXML(xmlString)

Or am I missing something in your question?

-Eddie
Max Steel
2016-09-07 19:51:54 UTC
Permalink
Raw Message
I'm trying to do something similar in 7.1.1.. so I added on to this thread. I've been searching a while now, and I'm missing the big picture I think.

What I'm trying to do, is read my ITIM LDAP for my provisioning policies and grab the entitlements (this part I have accomplished).

Now one of the work attributes I pulled from the ldap connector is an array caller erEntitlements.

When I pull the first value erEntitlements[0] it looks like what I will paste at the bottom of this post.

What I'd like to do is parse this work attribute so that is is more legible!
I'm trying to use the ParserFunctionComponent, but I can't seem to get a straight googled answer on how to use it! I have the parser set to XML parser...but I'm mixed up with the input vs output... and how to input the work attribute, reformat it, and output it perhaps into new attributes..

Any insight is appreciated... I'm a noob, and am tinkering.. If there is a post/video on how to accomplish this please feel free to make that the answer. I saw Eddie's JSON post and thought I could use that as an example, but that brought me down more! hahah..

and yes there is javascript in that attribute...

---work attribute content---

erLabel,itim_RoleScope,erRoleName,erEntitlements
"Provisioning Policy as per GROUP Access Profile - GRP0045","3",,"<?xml version=""1.0"" encoding=""UTF-8""?>
<ENTITLEMENT id=""260758679909873035"" name=""260758679909873035"" type=""REQUIRED"" version=""1.2"">
<TARGET type=""1"">erglobalid=5988423131337238826,ou=services,erglobalid=00000000000000000000,ou=Finance Corporation,dc=finance,dc=com</TARGET>
<ACCESS_DEFINITION>
<ACCESS_PARAMETER attributeName=""ergroup"" attributeType=""STRING"">
<ACCESS_PARAMETER_VALUE enforcement=""MANDATORY"" expressionType=""SCRIPT""><![CDATA[var lastname=subject.getProperty(""sn"")[0];
var lastnmletter = lastname.substr(0,1).toLowerCase();
var exchg_grp;
var grp_arr = new Array();
grp_arr[0]=""GROUP_00"";
grp_arr[1]=""GROUP_BEM"";
grp_arr[2]=""GROUP_CS3"";
grp_arr[3]=""GROUP_d64"";

if(lastnmletter == ""a"" || lastnmletter == ""b"" || lastnmletter == ""c"" || lastnmletter == ""d"")
{
exchg_grp=""Exchange Users (A-D)"";
}
else if(lastnmletter == ""e"" || lastnmletter == ""f"" || lastnmletter == ""g"" || lastnmletter == ""h"")
{
exchg_grp=""Exchange Users (E-H)"";
}
else if(lastnmletter == ""i"" || lastnmletter == ""j"" || lastnmletter == ""k"" || lastnmletter == ""l"")
{
exchg_grp=""Exchange Users (I-L)"";
}
else if(lastnmletter == ""m"" || lastnmletter == ""n"" || lastnmletter == ""o"" || lastnmletter == ""p"")
{
exchg_grp=""Exchange Users (M-P)"";
}
else if(lastnmletter == ""q"" || lastnmletter == ""r"" || lastnmletter == ""s"" || lastnmletter == ""t"")
{
exchg_grp= ""Exchange Users (Q-T)"";
}
else if(lastnmletter == ""u"" || lastnmletter == ""v"" || lastnmletter == ""w"" || lastnmletter == ""x"" || lastnmletter == ""y"" || lastnmletter == ""z"")
{
exchg_grp=""Exchange Users (U-Z)"";
}
else
{
exchg_grp=""Exchange Users (A-D)"";
}
grp_arr[20]=exchg_grp;
return grp_arr;]]></ACCESS_PARAMETER_VALUE>
</ACCESS_PARAMETER>
<ACCESS_PARAMETER attributeName=""eradhomedirdrive"" attributeType=""STRING"">
<ACCESS_PARAMETER_VALUE enforcement=""DEFAULT"" expressionType=""SCRIPT""><![CDATA[""H:""]]></ACCESS_PARAMETER_VALUE>
</ACCESS_PARAMETER>
<ACCESS_PARAMETER attributeName=""eradhomedir"" attributeType=""STRING"">
<ACCESS_PARAMETER_VALUE enforcement=""DEFAULT"" expressionType=""SCRIPT""><![CDATA[var uidval=subject.getProperty(""uid"");
var homeDirSrvr=""grouplanfilesystem1"";
if ( homeDirSrvr !=null)
{
homeDirSrvr=""\\\\""+homeDirSrvr+""\\""+uidval+""$"";
}
return homeDirSrvr;]]></ACCESS_PARAMETER_VALUE>
</ACCESS_PARAMETER>
</ACCESS_DEFINITION>
</ENTITLEMENT>
"
Eddie Hartman
2016-09-09 11:00:16 UTC
Permalink
Raw Message
Post by Max Steel
I'm trying to do something similar in 7.1.1.. so I added on to this thread. I've been searching a while now, and I'm missing the big picture I think.
What I'm trying to do, is read my ITIM LDAP for my provisioning policies and grab the entitlements (this part I have accomplished).
Now one of the work attributes I pulled from the ldap connector is an array caller erEntitlements.
When I pull the first value erEntitlements[0] it looks like what I will paste at the bottom of this post.
What I'd like to do is parse this work attribute so that is is more legible!
I'm trying to use the ParserFunctionComponent, but I can't seem to get a straight googled answer on how to use it! I have the parser set to XML parser...but I'm mixed up with the input vs output... and how to input the work attribute, reformat it, and output it perhaps into new attributes..
Any insight is appreciated... I'm a noob, and am tinkering.. If there is a post/video on how to accomplish this please feel free to make that the answer. I saw Eddie's JSON post and thought I could use that as an example, but that brought me down more! hahah..
and yes there is javascript in that attribute...
---work attribute content---
erLabel,itim_RoleScope,erRoleName,erEntitlements
"Provisioning Policy as per GROUP Access Profile - GRP0045","3",,"<?xml version=""1.0"" encoding=""UTF-8""?>
<ENTITLEMENT id=""260758679909873035"" name=""260758679909873035"" type=""REQUIRED"" version=""1.2"">
<TARGET type=""1"">erglobalid=5988423131337238826,ou=services,erglobalid=00000000000000000000,ou=Finance Corporation,dc=finance,dc=com</TARGET>
<ACCESS_DEFINITION>
<ACCESS_PARAMETER attributeName=""ergroup"" attributeType=""STRING"">
<ACCESS_PARAMETER_VALUE enforcement=""MANDATORY"" expressionType=""SCRIPT""><![CDATA[var lastname=subject.getProperty(""sn"")[0];
var lastnmletter = lastname.substr(0,1).toLowerCase();
var exchg_grp;
var grp_arr = new Array();
grp_arr[0]=""GROUP_00"";
grp_arr[1]=""GROUP_BEM"";
grp_arr[2]=""GROUP_CS3"";
grp_arr[3]=""GROUP_d64"";
if(lastnmletter == ""a"" || lastnmletter == ""b"" || lastnmletter == ""c"" || lastnmletter == ""d"")
{
exchg_grp=""Exchange Users (A-D)"";
}
else if(lastnmletter == ""e"" || lastnmletter == ""f"" || lastnmletter == ""g"" || lastnmletter == ""h"")
{
exchg_grp=""Exchange Users (E-H)"";
}
else if(lastnmletter == ""i"" || lastnmletter == ""j"" || lastnmletter == ""k"" || lastnmletter == ""l"")
{
exchg_grp=""Exchange Users (I-L)"";
}
else if(lastnmletter == ""m"" || lastnmletter == ""n"" || lastnmletter == ""o"" || lastnmletter == ""p"")
{
exchg_grp=""Exchange Users (M-P)"";
}
else if(lastnmletter == ""q"" || lastnmletter == ""r"" || lastnmletter == ""s"" || lastnmletter == ""t"")
{
exchg_grp= ""Exchange Users (Q-T)"";
}
else if(lastnmletter == ""u"" || lastnmletter == ""v"" || lastnmletter == ""w"" || lastnmletter == ""x"" || lastnmletter == ""y"" || lastnmletter == ""z"")
{
exchg_grp=""Exchange Users (U-Z)"";
}
else
{
exchg_grp=""Exchange Users (A-D)"";
}
grp_arr[20]=exchg_grp;
return grp_arr;]]></ACCESS_PARAMETER_VALUE>
</ACCESS_PARAMETER>
<ACCESS_PARAMETER attributeName=""eradhomedirdrive"" attributeType=""STRING"">
<ACCESS_PARAMETER_VALUE enforcement=""DEFAULT"" expressionType=""SCRIPT""><![CDATA[""H:""]]></ACCESS_PARAMETER_VALUE>
</ACCESS_PARAMETER>
<ACCESS_PARAMETER attributeName=""eradhomedir"" attributeType=""STRING"">
<ACCESS_PARAMETER_VALUE enforcement=""DEFAULT"" expressionType=""SCRIPT""><![CDATA[var uidval=subject.getProperty(""uid"");
var homeDirSrvr=""grouplanfilesystem1"";
if ( homeDirSrvr !=null)
{
homeDirSrvr=""\\\\""+homeDirSrvr+""\\""+uidval+""$"";
}
return homeDirSrvr;]]></ACCESS_PARAMETER_VALUE>
</ACCESS_PARAMETER>
</ACCESS_DEFINITION>
</ENTITLEMENT>
"
Hi Max,

I have written a little AL to show how to parse stuff like this using TDI 7.1.1. You can download it here:

https://ibm.biz/Bdr9za

Just save the file to disk (.assemblyline) and then drag it into a TDI project. I have endeavoured to comment it so that you can see what I am doing. Please let me know if anything is unclear.

-Eddie
Max Steel
2016-09-12 19:40:46 UTC
Permalink
Raw Message
This definitely parses the xml, and I am truly thankful! ...a way better starting (working) point that's for sure!

I have no idea why there were double quotes, the group must have added that, as I looked at the source I copy/pasted and it does not have that! All good none the less (easy to exclude).

The only follow up question would be, since I have yet to do script components in an assembly line, I'm not sure how to return the values back so that I can use the newly parsed pieces and place them into separate columns on an (output) report (csv) along side their policy...hmmm... thinking aloud as any tips are appreciated.

Thanks again!
Max Steel
2016-09-13 13:08:56 UTC
Permalink
Raw Message
Replying to myself as apparently I had a 'bad case of the monday's' yesterday :) of course I know an answer is to use the xml in the input of the work attribute assignment :)

Thanks again for your code Eddie, much appreciated!
Eddie Hartman
2017-10-20 07:19:34 UTC
Permalink
Raw Message
Post by Max Steel
Replying to myself as apparently I had a 'bad case of the monday's' yesterday :) of course I know an answer is to use the xml in the input of the work attribute assignment :)
Thanks again for your code Eddie, much appreciated!
Since Dropbox changed their Public folder handling, many of the links I've posted over the years are now dead. Please let me know if there is stuff you want to get to but can't.

And the asset previously referenced by the dead link above can be downloaded from here: https://www.dropbox.com/s/psnwkmuqmrhnxmt/parsingEntitlement.assemblyline?dl=0
Just download the .assemblyline file and drag/drop it into your TDI project.
Loading...