- From: Costello, Roger L. <costello@mitre.org>
- Date: Fri, 12 Jun 2009 19:54:31 -0400
- To: "'xproc-dev@w3.org'" <xproc-dev@w3.org>
Hi Folks,
I seek your ideas on how best to implement the following.
I created a user-defined step (i.e. pipeline) to decide if a person applying for an auto loan is underage. The step needs two pieces of information: Age and State.
The Loan_Application.xml document contains that plus a lot of other information:
<Loan-Application>
<Applicant>
<Name>Johnny Brown</Name>
<Age>17</Age>
<Address>
<Street>101 Curl Drive</Street>
<City>Columbus</City>
<State>OH</State>
</Address>
</Applicant>
<Car>
<Make>Mazda</Make>
<Model>Miata</Model>
<Year>2009</Year>
</Car>
<Loan-Amount>26000</Loan-Amount>
</Loan-Application>
I don't want to send all this to my user-defined step; I only want to send Age and State.
How do you suggest I implement my user-defined step? Currently I have implemented it with two input ports: Age and State:
<p:declare-step type="applicant:is-underage"
name="is-underage">
<p:input port="state" primary="true" />
<p:input port="age" />
<p:output port="result"/>
...
</p:declare-step>
However, using it is cumbersome: first I need to filter the Loan_Application.xml document twice, once to extract Age and once to extract State:
<p:filter name="get-state" select="Loan-Application/Applicant/Address/State" >
<p:input port="source">
<p:pipe step="Auto_Loan" port="auto-loan-application" />
</p:input>
</p:filter>
<p:filter name="get-age" select="Loan-Application/Applicant/Age" >
<p:input port="source">
<p:pipe step="Auto_Loan" port="auto-loan-application" />
</p:input>
</p:filter>
Then I can use my user-defined step, connecting its input ports to the p:filter outputs:
<applicant:is-underage>
<p:input port="state">
<p:pipe step="get-state" port="result" />
</p:input>
<p:input port="age">
<p:pipe step="get-age" port="result" />
</p:input>
</applicant:is-underage>
There's got to be a better way.
Perhaps my user-defined step should be implemented using options, rather than input ports? (I tried that but wasn't able to get it to work)
My question boils down to this:
What's the best way to extract a few pieces
of information from an XML document and
provide them to a user-defined step?
/Roger
P.S. Here's my user-defined step:
<p:declare-step type="applicant:is-underage"
name="is-underage">
<p:input port="state" primary="true" />
<p:input port="age" />
<p:output port="result"/>
<p:pack wrapper="applicant">
<p:input port="alternate">
<p:pipe step="is-underage" port="age" />
</p:input>
</p:pack>
<p:group>
<p:variable name="state" select="applicant/*[1]" />
<p:variable name="age" select="applicant/*[2]" />
<p:choose>
<p:when test="($state eq 'AK') and (number($age) le 16)">
<p:identity>
<p:input port="source">
<p:inline><c:result>true</c:result></p:inline>
</p:input>
</p:identity>
</p:when>
<p:when test="($state eq 'AL') and (number($age) le 18)">
<p:identity>
<p:input port="source">
<p:inline><c:result>true</c:result></p:inline>
</p:input>
</p:identity>
</p:when>
<p:when test="($state eq 'AZ') and (number($age) le 17)">
<p:identity>
<p:input port="source">
<p:inline><c:result>true</c:result></p:inline>
</p:input>
</p:identity>
</p:when>
<!-- ... -->
<p:when test="($state eq 'OH') and (number($age) le 18)">
<p:identity>
<p:input port="source">
<p:inline><c:result>true</c:result></p:inline>
</p:input>
</p:identity>
</p:when>
<!-- ... -->
<p:when test="($state eq 'WY') and (number($age) le 17)">
<p:identity>
<p:input port="source">
<p:inline><c:result>true</c:result></p:inline>
</p:input>
</p:identity>
</p:when>
<p:otherwise>
<p:identity>
<p:input port="source">
<p:inline><c:result>false</c:result></p:inline>
</p:input>
</p:identity>
</p:otherwise>
</p:choose>
</p:group>
</p:declare-step>
Received on Friday, 12 June 2009 23:55:03 UTC