xsl-list
[Top] [All Lists]

Re[2]: [xsl] Trying to Detect corrupt data

2007-10-25 01:49:51
Hello Andrew,

Thursday, October 25, 2007, 9:35:29 AM, you wrote:

On 25/10/2007, Arthur Maloney <ArthurM(_at_)seipas(_dot_)com> wrote:
Depending on user choice. The Xml file contains 500-50,000 row elements

In the Xml file each row element contains between 2-15 agent elements
(there is always more than 1). The agent name should be the same in all 
agent elements.



Example of Xml file
1.  AppicantNumber is always unique for each row element
2.  row 1 is not corrupt. All agent names the same
3.  rows 2 and 3 are corrupt. Contain more than one agent name (row2
contains 4 names, row3 2 names).

<table>
...
<row>
     <applicantNumber>56789</applicantNumber>
     <agent>John1</agent>
     <agent>John1</agent>
     <agent>John1</agent>
     <agent>John1</agent>
</row>
...
<row>
     <applicantNumber>127789</applicantNumber>
     <agent>John27</agent>
     <agent>John1</agent>
     <agent>Fred13</agent>
     <agent>John27</agent>
     <agent>John27</agent>
     <agent>John27</agent>
     <agent>Paul8</agent>
     <agent>John27</agent>
</row>
...
<row>
     <applicantNumber>16789345</applicantNumber>
     <agent>Fred9</agent>
     <agent>Fred9</agent>
     <agent>Fred9</agent>
     <agent>John1</agent>
     <agent>Fred9</agent>
     <agent>Fred9</agent>
     <agent>Fred9</agent>
     <agent>Fred9</agent>
     <agent>Fred9</agent>
</row>
...
</table>


You haven't shown any XSLT or given a clue to what version you're
using (which is always a good idea)...

However in this case the solution is probably the same for both: to
check the applicant number is unique define a key and check that it
only ever contains a single item with that value eg:

<xsl:key name="appNum" match="applicantNumber" use="."/>

and then when matching <row>:

count(key('appNum', applicantNumber)) = 1

To check that all <agent>s contain the same value use:

agent != agent  (one of the few times you want to use !=   ....!)

or maybe in 2.0:

count(distinct-values(agent) eq 1)

I hope this helps...


cheers


Whoops I'm using v1.0

Thanks
agent != agent should do me very well

-- 
Best regards,
 Arthur                            mailto:ArthurM(_at_)seipas(_dot_)com


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>