# Implement a Split Node which operates using XPath

## Details

• Type: Improvement
• Status: Closed
• Priority: Major
• Resolution: Fixed
• Affects Version/s: 2.2
• Fix Version/s:
• Component/s:
• Labels:
• Rice Module:
KEW
• Sprint:
Rice Sprint 2015-03-18, Rice Sprint 2015-04-15, Rice Sprint 2015-05-13
• Story Points:
2

## Description

Currently, split nodes must be programmed by hand in Java. It would be ideal if we could allow for these to be "scripted" in the XML using XPath expressions or something along those lines.

UC Irvine has shown interest in this and declarative branching seems like a good feature to have at any rate.

## Attachments

1. 01-XPathSplitNode_RuleTemplates.xml
1 kB
2. 02-XPathSplitNode_Doctype.xml
4 kB
3. 03-XPathSplitNode_Rules.xml
3 kB
4. 04-XPathSplitNode_Edl.xml
6 kB
5. XPathSplitNode.java
3 kB

## Activity

Hide
Eric Westfall added a comment -

There is an IU contribution somewhere for this (not sure if it has been integrated or not). If it hasn't been integrated yet, we should work with them to make it so. It's a handy feature.

Show
Eric Westfall added a comment - There is an IU contribution somewhere for this (not sure if it has been integrated or not). If it hasn't been integrated yet, we should work with them to make it so. It's a handy feature.
Hide
Eric Westfall added a comment -

Need to get the code from IU for this contribution.

Show
Eric Westfall added a comment - Need to get the code from IU for this contribution.
Hide
Eric Westfall added a comment -

Test this manually after integration pull request using one of our eDocLites

Show
Eric Westfall added a comment - Test this manually after integration pull request using one of our eDocLites
Hide
Claus Niesen added a comment -

From James Bennett:

Attached is a copy of the class we have in IU Rice. It is fairly general purpose so I don’t think it would require a lot of modification to bring into the foundation code. Here’s a snippet of a document type which uses it as an example:

        <split name="CampusSplit">
<activationType>P</activationType>
<mandatoryRoute>false</mandatoryRoute>
<finalApproval>false</finalApproval>
<type>edu.iu.es.esi.rice.kew.node.XPathSplitNode</type>
<branchDecisions>
<xpath branchName="BloomingtonBranch" expression="boolean(//data/version[@current='true']/field[@name='campus']/value='BL')" />
<xpath branchName="IndianapolisBranch" expression="boolean(//data/version[@current='true']/field[@name='campus']/value='IN')" />
<default branchName="OtherCampusBranch" />
</branchDecisions>
</split>


Essentially it expects 0 or more <xpath> nodes which specify a branch name and an XPath expression which should resolve to a boolean value. It checks each xpath node independently and if it resolves to true the document will route down that branch in the workflow and if it is false the branch will be skipped. This would allow you to route to multiple branches if the xpath expressions allow it. If none of the xpath nodes are matched then it routes to one or more “default” branches specified in the configuration. The example above is from an eDocLite and essentially has the following rules:

• If the campus value input on the form was BL (Bloomington) then follow the Bloomington branch
• If the campus value input on the form was IN (Indianapolis) then follow the Indianapolis branch
• If no other branches are matched then follow the OtherCampusBranch

Let me know if you have any questions about the functionality.

Attachment: XPathSplitNode.java

Show
Claus Niesen added a comment - From James Bennett: Attached is a copy of the class we have in IU Rice. It is fairly general purpose so I don’t think it would require a lot of modification to bring into the foundation code. Here’s a snippet of a document type which uses it as an example: <split name= "CampusSplit" > <activationType>P</activationType> <mandatoryRoute> false </mandatoryRoute> <finalApproval> false </finalApproval> <type>edu.iu.es.esi.rice.kew.node.XPathSplitNode</type> <branchDecisions> <xpath branchName= "BloomingtonBranch" expression= " boolean ( //data/version[@current=' true ']/field[@name='campus']/value='BL')" /> <xpath branchName= "IndianapolisBranch" expression= " boolean ( //data/version[@current=' true ']/field[@name='campus']/value='IN')" /> < default branchName= "OtherCampusBranch" /> </branchDecisions> </split> Essentially it expects 0 or more <xpath> nodes which specify a branch name and an XPath expression which should resolve to a boolean value. It checks each xpath node independently and if it resolves to true the document will route down that branch in the workflow and if it is false the branch will be skipped. This would allow you to route to multiple branches if the xpath expressions allow it. If none of the xpath nodes are matched then it routes to one or more “default” branches specified in the configuration. The example above is from an eDocLite and essentially has the following rules: • If the campus value input on the form was BL (Bloomington) then follow the Bloomington branch • If the campus value input on the form was IN (Indianapolis) then follow the Indianapolis branch • If no other branches are matched then follow the OtherCampusBranch Let me know if you have any questions about the functionality. Attachment: XPathSplitNode.java
Hide
Shannon Hess added a comment -

Pull request - https://github.com/kuali/rice/pull/147

I created a simple eDocLite to use for manual testing and wanted to include the files as an example so I added them to C:\idea\rice\rice-middleware\sampleapp\src\it\resources\XPathSplitNodeEDLExample\

If these should be removed just let me know and I can do so. I will also add them to this JIRA in case they are removed.

Show
Shannon Hess added a comment - Pull request - https://github.com/kuali/rice/pull/147 I created a simple eDocLite to use for manual testing and wanted to include the files as an example so I added them to C:\idea\rice\rice-middleware\sampleapp\src\it\resources\XPathSplitNodeEDLExample\ If these should be removed just let me know and I can do so. I will also add them to this JIRA in case they are removed.
Hide
Shannon Hess added a comment -

Attaching files used to create the eDocLite examle

Show
Shannon Hess added a comment - Attaching files used to create the eDocLite examle
Hide
Shannon Hess added a comment -

Re-opening to add example eDocLite to the sample application

Show
Shannon Hess added a comment - Re-opening to add example eDocLite to the sample application
Hide
Shannon Hess added a comment -

Pull request has been created - https://github.com/kuali/rice/pull/163

Show
Shannon Hess added a comment - Pull request has been created - https://github.com/kuali/rice/pull/163

## People

• Assignee:
Shannon Hess
Reporter:
Eric Westfall