xsl-list
[Top] [All Lists]

RE: Counting items related by a linked list

2004-03-23 23:35:22


First, an error, there should only be one:
<LinkItem>
  <SourceID>4</SourceID>
  <TargetID>1003</TargetID>
</LinkItem>
Not two as originally listed.


Rule 4 means that there cannot be:
<LinkItem>
  <SourceID>102</SourceID>
  <TargetID>1</TargetID>
</LinkItem>
and
<LinkItem>
  <SourceID>1</SourceID>
  <TargetID>102</TargetID>
</LinkItem>



For the example CItem 1003:

<LinkItem>
  <SourceID>6</SourceID>    AItem
  <TargetID>1003</TargetID>
</LinkItem>
<LinkItem>
  <SourceID>4</SourceID>    AItem
  <TargetID>1003</TargetID>
</LinkItem>
<LinkItem>
  <SourceID>101</SourceID>  BItem
  <TargetID>1003</TargetID>
</LinkItem>

So the answer is 2 in this case.
Note, the problem is checking that SourceID 6, and 4 are AItems, not BItems. Either can be any number.




From: "M. David Peterson" <m(_dot_)david(_at_)xxxxxxxxxx>
Date: Tue, 23 Mar 2004 01:00:25 -0700

Um, given rule #4 isn't the maximum count going to be 1?  Or is that the
point...  Are you trying to enforce this rule by checking the count?  Or
am I just missing the boat completely here?

I tried going with the idea that a CItem could be linked to more than
once but after looking at your sample data I'm not even sure if rule #3
can be considered true.

I guess I'm just a bit confused... can you clarify your problem a bit
more?

Thanks!

<M:D/>

-----Original Message-----
From: Joe K [mailto:anotherquestion(_at_)xxxxxxxxxxx]
Sent: Monday, March 22, 2004 10:17 PM
To: xsl-list(_at_)xxxxxxxxxxxxxxxxxxxxxx
Cc: anotherquestion(_at_)xxxxxxxxxxx
Subject: [xsl] Counting items related by a linked list

I have the following type of xml document:
Note:
1) All IDs are unique and can be any positive number
2) The link pairs below can link any item to any different Item.
3) CItems are always in the "Target" portion of the link table.
4) No item can be linked more than once to another item.

The question:  I would like to define a variable such that given the
CItem
ID, say 1003, I can get a count of all the AItems linked to it.

<TopLevel>

<AItem>
  <ID=1/>
  <Name=./>
</AItem>
<AItem>
  <ID=2/>
  <Name=./>
</AItem>
<AItem>
  <ID=3/>
  <Name=./>
</AItem>
<AItem>
  <ID=4/>
  <Name=./>
</AItem>
<AItem>
  <ID=5/>
  <Name=./>
</AItem>

<BItem>
  <ID=101/>
  <Name=./>
</BItem>
<BItem>
  <ID=102/>
  <Name=./>
</BItem>
<BItem>
  <ID=103/>
  <Name=./>
</BItem>
<BItem>
  <ID=104/>
  <Name=./>
</BItem>
<BItem>
  <ID=105/>
  <Name=./>
</BItem>
<BItem>
  <ID=106/>
  <Name=./>
</BItem>

<CItem>
  <ID=1001/>
  <Name=./>
</CItem>
<CItem>
  <ID=1002/>
  <Name=./>
</CItem>
<CItem>
  <ID=1003/>
  <Name=./>
</CItem>
<CItem>
  <ID=1004/>
  <Name=./>
</CItem>
<CItem>
  <ID=1005/>
  <Name=./>
</CItem>
<CItem>
  <ID=1006/>
  <Name=./>
</CItem>
<CItem>
  <ID=1007/>
  <Name=./>
</CItem>


<LinkItem>
  <SourceID>6</SourceID>
  <TargetID>1003</TargetID>
</LinkItem>
<LinkItem>
  <SourceID>105</SourceID>
  <TargetID>1002</TargetID>
</LinkItem>
<LinkItem>
  <SourceID>3</SourceID>
  <TargetID>101</TargetID>
</LinkItem>
<LinkItem>
  <SourceID>4</SourceID>
  <TargetID>1003</TargetID>
</LinkItem>
<LinkItem>
  <SourceID>102</SourceID>
  <TargetID>1</TargetID>
</LinkItem>
<LinkItem>
  <SourceID>101</SourceID>
  <TargetID>1003</TargetID>
</LinkItem>

</TopLevel>

_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page ? FREE download! http://toolbar.msn.com/go/onm00200413ave/direct/01/



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