Hello Peter,
To calculate separate counts, you need as many nodes as counts as you
want. You could use an attribute to distinguish from colour=white or
colour=black then the calculate expression will be evaluated according
to this value.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms">
<head>
<title>Count colours</title>
<xf:model>
<xf:instance>
<items xmlns="">
<item>
<colour>black</colour>
</item>
<item>
<colour>black</colour>
</item>
<item>
<colour>white</colour>
</item>
<count colour="black"/>
<count colour="white"/>
</items>
</xf:instance>
<xf:bind nodeset="count" calculate="count(../item[colour =
current()/@colour])"/>
</xf:model>
</head>
<body>
<h1>Count colors</h1>
<xf:repeat nodeset="count">
<xf:output value="@colour">
<xf:label>Colour: </xf:label>
</xf:output>
 
<xf:output value=".">
<xf:label>Count: </xf:label>
</xf:output>
</xf:repeat>
</body>
</html>
Is it what you want to do?
Thanks!
-Alain
Le 17/09/2012 20:04, peter winstanley a écrit :
Hello List
This is probably a trivial question, so apologies in advance.
I have an xform for which I want to calculate two or more seperate
counts [ e.g. count of nodes where colour=white and another count of
the same instance where colour=black]
AFAIK, I can only have one 'calculate' per instance/nodeset. {I would
appreciate clarification here}, so the only way that I have been able
to do this is to have the same XML instance in two separate models and
to have one bind and calculate in one model and the other bind and
calculate in the other model.
How should I really do this?
Thanks
Peter
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support