ukrause Contributor.
Contributor.
295 views

Mapping Table - map via multiple columns?


I have a mapping table which is structured like:

FD / FoS / Faculty / Dep

I have to retrieve the Faculty and the Dep fields via the Fos (Field of
Study). Unfortunately the FoS table sometimes contains the same value in
multiple lines. They distinguish by the first line, the FinalDegree
(FD). So basically what I have to do is to use the FoS and the FD to map
against the correct Faculty or Dep.
As this table has a fixed Structure which can't be changed I am looking
for a solution. Can I do a lookup to get all lines with the appropriate
FoS into a node set variable? I've never done this and honestly no idea
how to do it yet...

Any help appreciated!

Thanks in advance.


--
Cheers

Uwe
------------------------------------------------------------------------
ukrause's Profile: http://forums.novell.com/member.php?userid=124
View this thread: http://forums.novell.com/showthread.php?t=450554

Labels (1)
0 Likes
6 Replies
Knowledge Partner
Knowledge Partner

Re: Mapping Table - map via multiple columns?

On 11.01.2012 10:46, ukrause wrote:
>
> I have a mapping table which is structured like:
>
> FD / FoS / Faculty / Dep
>
> I have to retrieve the Faculty and the Dep fields via the Fos (Field of
> Study). Unfortunately the FoS table sometimes contains the same value in
> multiple lines. They distinguish by the first line, the FinalDegree
> (FD). So basically what I have to do is to use the FoS and the FD to map
> against the correct Faculty or Dep.
> As this table has a fixed Structure which can't be changed I am looking
> for a solution. Can I do a lookup to get all lines with the appropriate
> FoS into a node set variable? I've never done this and honestly no idea
> how to do it yet...


yes, I've done similar. You need to read the mapping table object
directly into a nodeset (this is stored as base64 encoded data and needs
to be decoded) and then use xpath to select only the nodes that match
your given FoS value.

That should give you a nodeset containing what you want.

There are a couple of old thread that explain how to do this.
Alex McHugh - Knowledge Partner - Stavanger, Norway
Who are the Knowledge Partners
If you appreciate my comments, please click the Like button.
If I have resolved your issue, please click the Accept as Solution button.
0 Likes
ukrause Contributor.
Contributor.

Re: Mapping Table - map via multiple columns?


I was searching the forum and couldn't find an older thread. Can you
post the link her please?


--
Cheers

Uwe
------------------------------------------------------------------------
ukrause's Profile: http://forums.novell.com/member.php?userid=124
View this thread: http://forums.novell.com/showthread.php?t=450554

0 Likes
Knowledge Partner
Knowledge Partner

Re: Mapping Table - map via multiple columns?

On 1/11/2012 10:26 AM, ukrause wrote:
>
> I was searching the forum and couldn't find an older thread. Can you
> post the link her please?


Make your mapping table, look at the XML view. You can see the XML.

Now we get into a task of deriving appropriate XPATH. Straightforward,
but fun.

Sort of like this:

<mapping-table>
<col-def name="key" type="nocase"/>
<row>
<col>entGatekeepersDisplayName</col>
<col>Gatekeepers</col>
</row>
<col-def name="value" type="nocase"/>
</mapping-table>

So you set local variable MAP (nodeset) to
Base64-decode
source attr Mapping Table object.

Now you have the mapping table that you can XPATH.

So XPATH of $MAP/mapping-table/row/col[text()=$SomeValueIWant]/text()

Or somesuch.

I forget your original issue, in terms of selecting what you want. But
I recall it was you needed a source column or really two values?

I guess seeing real data would make figuring out the XPATH easier.


0 Likes
ukrause Contributor.
Contributor.

Re: Mapping Table - map via multiple columns?


Hi Geoffc,

Thanks a lot. I think I can figure out now the xpath. I was a bit
confused on reading the Mapping Object...


geoffc;2166819 Wrote:
> On 1/11/2012 10:26 AM, ukrause wrote:
> >
> > I was searching the forum and couldn't find an older thread. Can you
> > post the link her please?

>
> Make your mapping table, look at the XML view. You can see the XML.
>
> Now we get into a task of deriving appropriate XPATH.
> Straightforward,
> but fun.
>
> Sort of like this:
>
> <mapping-table>
> <col-def name="key" type="nocase"/>
> <row>
> <col>entGatekeepersDisplayName</col>
> <col>Gatekeepers</col>
> </row>
> <col-def name="value" type="nocase"/>
> </mapping-table>
>
> So you set local variable MAP (nodeset) to
> Base64-decode
> source attr Mapping Table object.
>
> Now you have the mapping table that you can XPATH.
>
> So XPATH of $MAP/mapping-table/row/col[text()=$SomeValueIWant]/text()
>
> Or somesuch.
>
> I forget your original issue, in terms of selecting what you want.
> But
> I recall it was you needed a source column or really two values?
>
> I guess seeing real data would make figuring out the XPATH easier.



--
Cheers

Uwe
------------------------------------------------------------------------
ukrause's Profile: http://forums.novell.com/member.php?userid=124
View this thread: http://forums.novell.com/showthread.php?t=450554

0 Likes
Knowledge Partner
Knowledge Partner

Re: Mapping Table - map via multiple columns?

On 13.01.2012 12:36, ukrause wrote:

> Thanks a lot. I think I can figure out now the xpath. I was a bit
> confused on reading the Mapping Object...


There is an easier way to read the mapping object... Geoffrey mentioned
it in one of his cool solutions tutorials.
http://www.novell.com/communities/node/11319/parsedn-custom-dn-delimiter-example

Anyway, i think the following would probably solve your problem:
(assuming you have a mapping table with 4 columns in the order and with
the logic you mentioned earlier). Also assuming you have defined local
variables with the FoS and FD values you are searching for.

In my example the mapping table is called map1 and is in the same driver
as your policy. That way it's easy to use relative path to the table.

<do-set-local-variable name="MAP" scope="driver">
<arg-node-set>
<token-document>
<arg-string>
<token-text xml:space="preserve">../map1</token-text>
</arg-string>
</token-document>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="faculty" scope="policy">
<arg-string>
<token-xpath expression="$MAP/mapping-table/row[(col[2]=$FoS and
col[1]=$FD)]/col[3]/text()"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="department" scope="policy">
<arg-string>
<token-xpath expression="$MAP/mapping-table/row[(col[2]=$FoS and
col[1]=$FD)]/col[4]/text()"/>
</arg-string>
</do-set-local-variable>

The document token does all the query and decoding work for you.
I find the token-document method easier to read and generally test with.
Especially in simulator where it avoids a query.

The other method of reading in a mapping table (which Geoffrey and I
alluded to earlier) is outlined below.

<do-set-local-variable name="MAP" scope="policy">
<arg-node-set>
<token-xml-parse>
<token-base64-decode charset="UTF-8">
<token-src-attr class-name="DirXML-Resource" name="DirXML-Data">
<arg-dn>
<token-text xml:space="preserve">../map1</token-text>
</arg-dn>
</token-src-attr>
</token-base64-decode>
</token-xml-parse>
</arg-node-set>
</do-set-local-variable>


Alex McHugh - Knowledge Partner - Stavanger, Norway
Who are the Knowledge Partners
If you appreciate my comments, please click the Like button.
If I have resolved your issue, please click the Accept as Solution button.
0 Likes
ukrause Contributor.
Contributor.

Re: Mapping Table - map via multiple columns?


Hi,

thanks a lot, the document token works like a charm. Definitely I
prefer this method! Thanks a lot.

alexmchugh;2167582 Wrote:
> On 13.01.2012 12:36, ukrause wrote:
>
> > Thanks a lot. I think I can figure out now the xpath. I was a bit
> > confused on reading the Mapping Object...

>
> There is an easier way to read the mapping object... Geoffrey
> mentioned
> it in one of his cool solutions tutorials.
> 'Parse DN Custom DN Delimiter Example | Novell User Communities'
> (http://www.novell.com/communities/node/11319/parsedn-custom-dn-delimiter-example)
>
> Anyway, i think the following would probably solve your problem:
> (assuming you have a mapping table with 4 columns in the order and
> with
> the logic you mentioned earlier). Also assuming you have defined local
> variables with the FoS and FD values you are searching for.
>
> In my example the mapping table is called map1 and is in the same
> driver
> as your policy. That way it's easy to use relative path to the table.
>
> <do-set-local-variable name="MAP" scope="driver">
> <arg-node-set>
> <token-document>
> <arg-string>
> <token-text xml:space="preserve">../map1</token-text>
> </arg-string>
> </token-document>
> </arg-node-set>
> </do-set-local-variable>
> <do-set-local-variable name="faculty" scope="policy">
> <arg-string>
> <token-xpath expression="$MAP/mapping-table/row[(col[2]=$FoS and
> col[1]=$FD)]/col[3]/text()"/>
> </arg-string>
> </do-set-local-variable>
> <do-set-local-variable name="department" scope="policy">
> <arg-string>
> <token-xpath expression="$MAP/mapping-table/row[(col[2]=$FoS and
> col[1]=$FD)]/col[4]/text()"/>
> </arg-string>
> </do-set-local-variable>
>
> The document token does all the query and decoding work for you.
> I find the token-document method easier to read and generally test
> with.
> Especially in simulator where it avoids a query.
>
> The other method of reading in a mapping table (which Geoffrey and I
> alluded to earlier) is outlined below.
>
> <do-set-local-variable name="MAP" scope="policy">
> <arg-node-set>
> <token-xml-parse>
> <token-base64-decode charset="UTF-8">
> <token-src-attr class-name="DirXML-Resource" name="DirXML-Data">
> <arg-dn>
> <token-text xml:space="preserve">../map1</token-text>
> </arg-dn>
> </token-src-attr>
> </token-base64-decode>
> </token-xml-parse>
> </arg-node-set>
> </do-set-local-variable>



--
Cheers

Uwe
------------------------------------------------------------------------
ukrause's Profile: http://forums.novell.com/member.php?userid=124
View this thread: http://forums.novell.com/showthread.php?t=450554

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.