W3C home > Mailing lists > Public > xproc-dev@w3.org > July 2009

[XProc Challenge] Implement this rule: All person's social security number must be unique

From: Costello, Roger L. <costello@mitre.org>
Date: Sun, 5 Jul 2009 18:20:56 -0400
To: "xproc-dev@w3.org" <xproc-dev@w3.org>
Message-ID: <9E51F88D5247B648908850C35A3BBB500400458C5E@IMCMBX3.MITRE.ORG>

Hi Folks,

Consider this business rule:

   All person's social security number 
   must be unique.

How would you implement the rule, using only native XProc steps? (i.e. don't escape to XSLT)

Below is an implementation I created. Can you come up with a better implementation? 


<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
    <p:input port="SSNs">
        <p:document href="SSNs.xml" />
    <p:output port="result" />

    <p:filter select="/*[count(distinct-values(//@ssn)) eq count(//@ssn)]" />

    <p:count />

        <p:when test="number(c:result) gt 0">
                <p:input port="source">
                <p:input port="source">

<?xml version="1.0"?>
    <Person ssn="365-78-2145" />
    <Person ssn="430-43-4530" />
    <Person ssn="201-59-3021" />
    <Person ssn="590-10-0902" />
    <Person ssn="430-32-4329" />
Received on Sunday, 5 July 2009 22:21:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:48 UTC