Thank you for your helpful illustration.
I am getting the XML instance from a schema/schmatron validation process and it looks like this ...
<?xml version="1.0" encoding="UTF-8"?> <out> <report accref="missacc" save="/db/records/harderrors/missacc.xml" sort="soft" submission="testupgrade.txt.xml"> <error> <code>java:org.xml.sax.SAXException</code> <desc>An empty sequence is not allowed as the second argument of index-of()</desc> <val/> </error> </report> <report accref="missveh" save="/db/STATS21test/STATS21-Code-2012-07-12/records/harderrors/missveh.xml" sort="hard" submission="testupgrade.txt.xml"> <error> <code>java:org.xml.sax.SAXException</code> <desc>An empty sequence is not allowed as the second argument of index-of()</desc> <val/> </error> </report> <report accref="misscas" save="/db/records/harderrors/misscas.xml" sort="hard" submission="testupgrade.txt.xml">
etc
and I am wanting to get counts of the report/@sort values ('hard', 'soft' etc).
Do I set up an additional instance to hold these count values?
Also, I am wanting to convert report/@save values into a hyperlink. I can retrieve these values using the <xf:repeat ...> approach
but only get text outputs via the <xf:output /> as follows:
<xf:repeat model="general" nodeset="instance('validate-xml-results')/report">
<div>
<span>
<xf:output value="@save">
<xf:label>file:</xf:label>
</xf:output>
</span>
<span>
<xf:output value="@sort">
<xf:label>Sort: </xf:label>
</xf:output>
</span>
<span>
<xf:repeat nodeset="svrl:schematron-output/svrl:failed-assert">
<xf:output value="svrl:text">
<xf:label>failed assert: </xf:label>
</xf:output>
</xf:repeat>
</span>
</div>
<hr/>
</xf:repeat>
What is the way to present the @save attribute as a URL?
Many thanks
Peter
-----Original Message-----
From: [email protected]
Sent: Mon, 17 Sep 2012 21:06:37 +0200
To: [email protected]
Subject: Re: [Xsltforms-support] multiple "calculate" on the same bindHello 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
