On Tue, 22 May 2012 14:06:01 +0000, iceman3 wrote:

> I have been asked to reformat the JMS message going to MQ via the
> subscriber channel in the following format:
>
> <idm>
> <eagle></eagle>
> <userid></userid>
> <timestamp>YYYYMMDDHHMMSSS</timestamp>
> <primaryAffiliation></primaryAffiliation> <affiliations>
> <affiliation></affiliation>
> <affiliation></affiliation>
> </affiliations>
> <priorityStatus></priorityStatus>
> <primaryAlias></primaryAlias>
> <mailRoutingAddress></mailRoutingAddress> <mailHost></mailHost>
> <aliases>
> <alias></alias>
> <alias></alias>
> </aliases>
> </idm>


I'm assuming the Output Transform is where you'll want to do this. The
difficult part here is that DirXML Script doesn't allow access to the
root of the document.

This isn't the prettiest solution, but seems to work the way you want it
to. On the Output Transform, I put a policy in DirXML script to handle
most of the document hacking:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE policy PUBLIC "policy-
builder-dtd" "/home/a02dag1/bin/designer_3.5/plugins/
com.novell.idm.policybuilder_3.5.0.201003011501/DTD/
dirxmlscript3.6.1.dtd"><policy>
<rule>
<description>Transform XDS to JMS</description>
<conditions>
<and>
<if-operation mode="regex" op="equal">add|modify</if-operation>
</and>
</conditions>
<actions>
<do-append-xml-element expression=".." name="idm"/>
<do-append-xml-element expression="../idm" name="eagle"/>
<do-append-xml-text expression="../idm/eagle">
<arg-string>
<token-xpath expression="modify-attr[@attr-name='eaglenumber']/add-
value/value"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="userid"/>
<do-append-xml-text expression="../idm/userid">
<arg-string>
<token-xpath expression="modify-attr[@attr-name='userid']/add-value/
value"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="timestamp"/>
<do-append-xml-text expression="../idm/timestamp">
<arg-string>
<token-time format="yyyyMMDDhhmmss"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="primaryAffiliation"/>
<do-append-xml-text expression="../idm/primaryAffiliation">
<arg-string>
<token-xpath expression="modify-attr[@attr-
name='primaryAffiliation']/add-value/value"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="affiliations"/>
<do-for-each>
<arg-node-set>
<token-xpath expression="modify-attr[@attr-name='Affiliation']/add-
value/value"/>
</arg-node-set>
<arg-actions>
<do-append-xml-element expression="../idm/affiliations"
name="affiliation"/>
<do-append-xml-text expression="../idm/affiliations/affiliation[last
()]">
<arg-string>
<token-local-variable name="current-node"/>
</arg-string>
</do-append-xml-text>
</arg-actions>
</do-for-each>
<do-append-xml-element expression="../idm" name="priorityStatus"/>
<do-append-xml-text expression="../idm/priorityStatus">
<arg-string>
<token-xpath expression="modify-attr[@attr-name='priorityStatus']/
add-value/value"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="primaryAlias"/>
<do-append-xml-text expression="../idm/primaryAlias">
<arg-string>
<token-xpath expression="modify-attr[@attr-name='primaryAlias']/add-
value/value"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="mailRoutingAddress"/>
<do-append-xml-text expression="../idm/mailRoutingAddress">
<arg-string>
<token-xpath expression="modify-attr[@attr-
name='mailRoutingAddress']/add-value/value"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="mailHost"/>
<do-append-xml-text expression="../idm/mailHost">
<arg-string>
<token-xpath expression="modify-attr[@attr-name='mailHost']/add-
value/value"/>
</arg-string>
</do-append-xml-text>
<do-append-xml-element expression="../idm" name="aliases"/>
<do-for-each>
<arg-node-set>
<token-xpath expression="modify-attr[@attr-name='alias']/add-value/
value"/>
</arg-node-set>
<arg-actions>
<do-append-xml-element expression="../idm/aliases" name="alias"/>
<do-append-xml-text expression="../idm/aliases/alias[last()]">
<arg-string>
<token-local-variable name="current-node"/>
</arg-string>
</do-append-xml-text>
</arg-actions>
</do-for-each>
<do-strip-xpath expression="."/>
</actions>
</rule>
</policy>


Then I put an XSLT Stylesheet in to handle stripping off the <nds> layer:


<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet exclude-result-
prefixes="query cmd dncv" version="1.0" xmlns:cmd="http://www.novell.com/
nxsl/java/com.novell.nds.dirxml.driver.XdsCommandProcessor"
xmlns:dncv="http://www.novell.com/nxsl/java/
com.novell.nds.dirxml.driver.DNConverter" xmlns:query="http://
www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><!-- parameters passed
in from the DirXML engine -->
<xslaram name="srcQueryProcessor"/>
<xslaram name="destQueryProcessor"/>
<xslaram name="srcCommandProcessor"/>
<xslaram name="destCommandProcessor"/>
<xslaram name="dnConverter"/>
<xslaram name="fromNds"/>
<!-- identity transformation template -->
<!-- in the absence of any other templates this will cause -->
<!-- the stylesheet to copy the input through unchanged to the output -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="nds/input/idm"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


For a sample input document:

<?xml version="1.0" encoding="UTF-8"?><nds dtdversion="3.5"
ndsversion="8.x">
<source>
<product version="?.?.?.?">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<modify cached-time="20120518190746.573Z" class-name="user" event-
id="ID:414d5120716d736764202020202020204ca0d02827e c548e" qualified-src-
dn="O=data\OU=people\CN=laffeyta" src-dn="\BCIDV-DEV\data\people
\laffeyta" src-entry-id="33913" timestamp="1337368066#54">
<association state="associated">10080404</association>
<modify-attr attr-name="eaglenumber">
<remove-all-values/>
<add-value>
<value type="string">10080404</value>
</add-value>
</modify-attr>
<modify-attr attr-name="mailHost">
<remove-all-values/>
<add-value>
<value type="string">host.bc.edu</value>
</add-value>
</modify-attr>
<modify-attr attr-name="primaryAffiliation">
<remove-all-values/>
<add-value>
<value type="string">Test PA</value>
</add-value>
</modify-attr>
<modify-attr attr-name="Affiliation">
<remove-all-values/>
<add-value>
<value type="string">Test PA 1</value>
</add-value>
<add-value>
<value type="string">Test PA 2</value>
</add-value>
<add-value>
<value type="string">Test PA 3</value>
</add-value>
</modify-attr>
<modify-attr attr-name="mailRoutingAddress">
<remove-all-values/>
<add-value>
<value type="string">test@host.bc.edu</value>
</add-value>
</modify-attr>
<modify-attr attr-name="primaryAlias">
<remove-all-values/>
<add-value>
<value type="string">taylor.laffey@bc.edu</value>
</add-value>
</modify-attr>
<modify-attr attr-name="userid">
<remove-all-values/>
<add-value>
<value type="string">laffeyta</value>
</add-value>
</modify-attr>
<modify-attr attr-name="alias">
<remove-all-values/>
<add-value>
<value type="string">taylor.laffey.1@bc.edu</value>
</add-value>
<add-value>
<value type="string">taylor.laffey.2@bc.edu</value>
</add-value>
<add-value>
<value type="string">taylor.laffey.3@bc.edu</value>
</add-value>
</modify-attr>
</modify>
</input>
</nds>

This seems to produce the output you were looking for:

<idm>
<eagle>10080404</eagle>
<userid>laffeyta</userid>
<timestamp>201205146031548</timestamp>
<primaryAffiliation>Test PA</primaryAffiliation>
<affiliations>
<affiliation>Test PA 1</affiliation>
<affiliation>Test PA 2</affiliation>
<affiliation>Test PA 3</affiliation>
</affiliations>
<priorityStatus/>
<primaryAlias>taylor.laffey@bc.edu</primaryAlias>
<mailRoutingAddress>test@host.bc.edu</mailRoutingAddress>
<mailHost>host.bc.edu</mailHost>
<aliases>
<alias>taylor.laffey.1@bc.edu</alias>
<alias>taylor.laffey.2@bc.edu</alias>
<alias>taylor.laffey.3@bc.edu</alias>
</aliases>
</idm>


Though really this might be better off done entirely in XSLT.


--
--------------------------------------------------------------------------
David Gersic dgersic_@_niu.edu
Knowledge Partner http://forums.novell.com

Please post questions in the forums. No support provided via email.