Re: [Xsltforms-support] multiple "calculate" on the same bind
Brought to you by:
alain-couthures
From: peter w. <p....@in...> - 2012-09-18 08:19:20
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD><META http-equiv=Content-Type content="text/html; charset=utf-8"><META content="INBOX.COM" name=GENERATOR></HEAD> <BODY> Hello Alain<br>Thank you for your helpful illustration.<br>I am getting the XML instance from a schema/schmatron validation process and it looks like this ...<br><br><br><pre id="line1"><span style="color: rgb(0, 99, 198);" class="pi"><?xml version="1.0" encoding="UTF-8"?></span><span style="color: rgb(0, 99, 198);"> <span id="line2"></span><<span class="start-tag">out</span>> <span id="line3"></span> <<span class="start-tag">report</span> <span class="attribute-name">accref</span>="<a class="attribute-value">missacc</a>" <span id="line4"></span> <span class="attribute-name">save</span>="<a class="attribute-value">/db/records/harderrors/missacc.xml</a>" <span id="line5"></span> <span class="attribute-name">sort</span>="soft" <span id="line6"></span> <span class="attribute-name">submission</span>="<a class="attribute-value">testupgrade.txt.xml</a>"> <span id="line7"></span> <<span class="start-tag">error</span>> <span id="line8"></span> <<span class="start-tag">code</span>>java:org.xml.sax.SAXException</<span class="end-tag">code</span>> <span id="line9"></span> <<span class="start-tag">desc</span>>An empty sequence is not allowed as the second argument of index-of()</<span class="end-tag">desc</span>> <span id="line10"></span> <<span class="start-tag">val</span><span>/</span>> <span id="line11"></span> </<span class="end-tag">error</span>> <span id="line12"></span> </<span class="end-tag">report</span>> <span id="line13"></span> <<span class="start-tag">report</span> <span class="attribute-name">accref</span>="<a class="attribute-value">missveh</a>" <span id="line14"></span> <span class="attribute-name">save</span>="<a class="attribute-value">/db/STATS21test/STATS21-Code-2012-07-12/records/harderrors/missveh.xml</a>" <span id="line15"></span> <span class="attribute-name">sort</span>="<a class="attribute-value">hard</a>" <span id="line16"></span> <span class="attribute-name">submission</span>="<a class="attribute-value">testupgrade.txt.xml</a>"> <span id="line17"></span> <<span class="start-tag">error</span>> <span id="line18"></span> <<span class="start-tag">code</span>>java:org.xml.sax.SAXException</<span class="end-tag">code</span>> <span id="line19"></span> <<span class="start-tag">desc</span>>An empty sequence is not allowed as the second argument of index-of()</<span class="end-tag">desc</span>> <span id="line20"></span> <<span class="start-tag">val</span><span>/</span>> <span id="line21"></span> </<span class="end-tag">error</span>> <span id="line22"></span> </<span class="end-tag">report</span>> <span id="line23"></span> </span><span><span style="color: rgb(0, 99, 198);"><</span><span style="color: rgb(0, 99, 198);" class="start-tag">report</span><span style="color: rgb(0, 99, 198);"> </span><span style="color: rgb(0, 99, 198);" class="attribute-name">accref</span><span style="color: rgb(0, 99, 198);">="</span><a style="color: rgb(0, 99, 198);" class="attribute-value">misscas</a><span style="color: rgb(0, 99, 198);">" </span><span style="color: rgb(0, 99, 198);" id="line24"></span><span style="color: rgb(0, 99, 198);"> </span><span style="color: rgb(0, 99, 198);" class="attribute-name">save</span><span style="color: rgb(0, 99, 198);">="</span><a style="color: rgb(0, 99, 198);" class="attribute-value">/db/records/harderrors/misscas.xml</a><span style="color: rgb(0, 99, 198);">" </span><span style="color: rgb(0, 99, 198);" id="line25"></span><span style="color: rgb(0, 99, 198);"> </span><span style="color: rgb(0, 99, 198);" class="attribute-name">sort</span><span style="color: rgb(0, 99, 198);">="</span><a style="color: rgb(0, 99, 198);" class="attribute-value">hard</a><span style="color: rgb(0, 99, 198);">" </span><span style="color: rgb(0, 99, 198);" id="line26"></span><span style="color: rgb(0, 99, 198);"> </span><span style="color: rgb(0, 99, 198);" class="attribute-name">submission</span><span style="color: rgb(0, 99, 198);">="</span><a style="color: rgb(0, 99, 198);" class="attribute-value">testupgrade.txt.xml</a><span style="color: rgb(0, 99, 198);">"></span><br><br><br>etc<br><br><font style="font-family: Arial,Helvetica,sans-serif;" size="3">and I am wanting to get counts of the report/@sort values ('hard', 'soft' etc). <br>Do I set up an additional instance to hold these count values? </font><br><br><br><font style="font-family: Tahoma,sans-serif;" size="3">Also, I am wanting to convert report/@save values into a hyperlink. I can retrieve these values using the <xf:repeat ...> approach <br>but only get text outputs via the <xf:output /> as follows:</font><br><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:repeat model="general" nodeset="instance('validate-xml-results')/report"></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <div></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <span></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:output value="@save"></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:label>file:</xf:label></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </xf:output></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </span></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <span></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:output value="@sort"></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:label>Sort: </xf:label></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </xf:output></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </span></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <span></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:repeat nodeset="svrl:schematron-output/svrl:failed-assert"></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:output value="svrl:text"></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <xf:label>failed assert: </xf:label></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </xf:output> </span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </xf:repeat></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </span></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </div> </span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> <hr/></span><br style="color: rgb(0, 99, 198);"><span style="color: rgb(0, 99, 198);"> </xf:repeat></span><br><br><font size="3"><span style="font-family: Tahoma,sans-serif;"><span style="font-family: Arial,Helvetica,sans-serif;">What is the way to present the @save attribute as a URL?</span><br style="font-family: Arial,Helvetica,sans-serif;"><br style="font-family: Arial,Helvetica,sans-serif;"><span style="font-family: Arial,Helvetica,sans-serif;">Many thanks </span><br style="font-family: Arial,Helvetica,sans-serif;"><br style="font-family: Arial,Helvetica,sans-serif;"><br style="font-family: Arial,Helvetica,sans-serif;"><span style="font-family: Arial,Helvetica,sans-serif;">Peter</span><br></span></font></span><span></span></pre><br> <div> </div><br><br><blockquote style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"><div class="msgHeaders">-----Original Message-----<br><b>From:</b> ala...@ag...<br><b>Sent:</b> Mon, 17 Sep 2012 21:06:37 +0200<br><b>To:</b> p....@in...<br><b>Subject:</b> Re: [Xsltforms-support] multiple "calculate" on the same bind<br><br></div><div class="oldBody"><div> <div _class="moz-cite-prefix">Hello Peter,<br> <br> 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.<br> <br> <html xmlns=<a _class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a> xmlns:xf=<a _class="moz-txt-link-rfc2396E" href="http://www.w3.org/2002/xforms">"http://www.w3.org/2002/xforms"</a>><br> <head><br> <title>Count colours</title><br> <xf:model><br> <xf:instance><br> <items xmlns=""><br> <item><br> <colour>black</colour><br> </item><br> <item><br> <colour>black</colour><br> </item><br> <item><br> <colour>white</colour><br> </item><br> <count colour="black"/><br> <count colour="white"/><br> </items><br> </xf:instance><br> <xf:bind nodeset="count" calculate="count(../item[colour = current()/@colour])"/><br> </xf:model><br> </head><br> <body><br> <h1>Count colors</h1><br> <xf:repeat nodeset="count"><br> <xf:output value="@colour"><br> <xf:label>Colour: </xf:label><br> </xf:output><br> &#160;<br> <xf:output value="."><br> <xf:label>Count: </xf:label><br> </xf:output><br> </xf:repeat><br> </body><br> </html><br> <br> Is it what you want to do?<br> <br> Thanks!<br> <br> -Alain<br> <br> Le 17/09/2012 20:04, peter winstanley a écrit :<br> </div> <blockquote cite="mid:2D2...@in..." type="cite"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta content="INBOX.COM" name="GENERATOR"> Hello List<br> <br> This is probably a trivial question, so apologies in advance.<br> <br> 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]<br> <br> 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.<br> <br> How should I really do this?<br> <br> Thanks<br> <br> Peter<br> <br> </blockquote> <br> </div></div></blockquote> <hr size="1px" noshade style="clear:both;margin-top:10px;height:1px;"> <div style="font:12px Verdana,sans-serif;color:Black;background:white;padding:3px;line-height:1.3em"> <a href="http://www.inbox.com/smileys"><img src="http://my.inbox.com/img/ftrs/smileys.jpg" width="438" hight="73" alt="Smileys Preview" border="0" style="margin-bottom:10px" /></a><br> <nobr><strong><font color="2086c3">Get Free Smileys for Your IM & Email</font></strong> - Learn more at <a href="http://www.crawler.com/smileys">www.crawler.com/smileys</a></nobr><br> <nobr>Works with AIM<font size="-1"><sup>®</sup></font>, MSN<font size="-1"><sup>®</sup></font> Messenger, Yahoo!<font size="-1"><sup>®</sup></font> Messenger, ICQ<font size="-1"><sup>®</sup></font>, Google Talk<font size="-1"><sup>™</sup></font> and most webmails</nobr></div> </BODY> </HTML> |