To whom it may concern:
I created an xml file called affiliateReport.xml.config. Its purpose is to pull orders that match an affiliate so that an affiliate may view their orders. To test it I wanted the orders to be listed in the lat_account.aspx file for now. Unforatunately at this time it will only show me orders for AffiliateID equal to 0. Thus I know I'm hitting the database, and I know it it showing me the data but it won't show me the data based on the affiliateID of the affiliate login. Any help would be greatly appreciated. These files are from AspDotNetStoreFront Multistore. My code is below.
AffiliateReport.xml.config
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<package version="2.1" displayname="Affiliate Report" debug="false" includeentityhelper="true" allowengine="true">
<query name="AffiliateReport" rowElementName="AffiliateOrders">
<sql>
<![CDATA[
SELECT * from Orders with (NOLOCK)
LEFT JOIN Affiliate on Affiliate.AffiliateID = Orders.AffiliateID
WHERE Orders.AffiliateID = #affiliateID
]]>
</sql>
<queryparam paramname="#affiliateID" paramtype="runtime" requestparamname="AffiliateID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
</query>
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:param name="LocaleSetting" select="/root/Runtime/LocaleSetting" />
<xsl:param name="WebConfigLocaleSetting" select="/root/Runtime/WebConfigLocaleSetting" />
<xsl:param name="XmlPackageName" select="/root/System/XmlPackageName" />
<xsl:param name="AffiliateID" select="/root/Runtime/WebConfigLocaleSetting" />
<xsl:template match="/">
<table width="90%">
<tr>
<td>Order Number</td>
<td width="10px"> </td>
<td>Affiliate ID</td>
<td width="10px"> </td>
<td>Total</td>
</tr>
<xsl:for-each select="/root/AffiliateReport/AffiliateOrders">
<tr>
<td><xsl:value-of select="OrderNumber" /></td>
<td> </td>
<td><xsl:value-of select="AffiliateID" /></td>
<td> </td>
<td>$<xsl:value-of select="OrderTotal" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
</PackageTransform>
</package>
From lat_account.aspx line 313 I added the following code
<asp:Literal ID="XmlPackage_AffiliateOrders" runat="server" Mode="PassThrough" />
From lat_account.aspx.cs line 168 I added the following code
XmlPackage_AffiliateOrders.Text = AppLogic.RunXmlPackage ("affiliatereport.xml.config", base.GetParser, ThisCustomer, SkinID, String.Empty, String.Format("AffiliateID={0}", AffiliateID), true, true);
Thank you in advance!
Are you positive you are passing the correct value for Affiliate Id? My guess is the variable is not correctly set. You should attempt to debug at that line where you are setting the id.
Alternatively, you could set it manually to a different valid affiliate id
XmlPackage_AffiliateOrders.Text = AppLogic.RunXmlPackage ("affiliatereport.xml.config", base.GetParser, ThisCustomer, SkinID, String.Empty, String.Format("AffiliateID={0}", 5), true, true);
Add this to the top of lat_account.aspx:
<%# Register Src="~/controls/XmlPackageControl.ascx" TagName="XmlPackage" TagPrefix="adnsf" %>
Add this to lat_account.aspx where you want your XmlPackage to render:
<adnsf:XmlPackage runat="server" PackageName="AffiliateReport.xml.config" ID="AffiliateReportPackage" />
Add this to the Page_Load method of lat_account.aspx.cd after the lines where the AffiliateID variable has been populated:
AffiliateReportPackage.RuntimeParams = string.Format("LoggedInAffiliateID={0}", AffiliateID);
Change your xmlpackage sql parameter to this:
<queryparam paramname="#affiliateID" paramtype="runtime" requestparamname="LoggedInAffiliateID" sqlDataType="int" defvalue="0" validationpattern="" />
Related
In any other language I could just store the previous row's value in a variable and then see if it matches the current value or not, but alas variables in XSL aren't really "variable" or something like that...
So, how do I accomplish what should be an otherwise 'easy' task?
I have some (probably poorly formed) XML, output by a third-party application. I use it to ouput each of the following lines as html table rows using XSL:
<xsl:for-each select="Designs/TrackingDetails/Details">
<tr>
<th width="200"><xsl:value-of select="./#DGGroup"/></th>
<th width="350"><xsl:value-of select="./#DGName"/></th>
<td><xsl:value-of select="./#DGDate"/></td>
<td><xsl:value-of select="./#DGUser"/></td>
</tr>
</xsl:for-each>
What I would like is for it to only print each unique 'DGGroup' once, but it either prints all of them, or nothing at all.
So, in the end, I'd like HTML like this (using XML similar to the bottom of my post):
<tr><td>General</td><td>Quote in Date</td><td>04/16/2015</td><td>Ed Garcia</td></tr>
and on the next line:
<tr><td></td><td>Bid Complete</td><td>04/12/2015</td><td>John Smith</td></tr>
Here's some code I've tried so far:
<xsl:if test="preceding-sibling::./DGGroup[1]=self::./DGGroup">
AND
<xsl:if test="preceding-sibling::*[1]=./#DGGroup">
...Neither of which work
Here is a sample of some of the XML:
<Designs>
<TrackingDetails Transactions_Id="2" Reference="A1234">
<Details DGGroup="General" DGName="Quote in Date" DGDate="04/16/2015" DGUser="Ed Garcia" />
<Details DGGroup="General" DGName="Bid Complete" DGDate="04/12/2015" DGUser="John Smith" />
<Details DGGroup="Design" DGName="Approval Recieved" DGDate="" DGUser="" />
<Details DGGroup="Design" DGName="Design Complete" DGDate="09/18/2015" DGUser="Fred Smith" />
<Details DGGroup="Production" DGName="Released to Production" DGDate="09/18/2015" DGUser="Fred Smith" />
<Details DGGroup="Production" DGName="At Printers" DGDate="" DGUser="" />
<Details DGGroup="Production" DGName="Packaged" DGDate="" DGUser="" />
<Details DGGroup="Delivery" DGName="Delivery Packet Made" DGDate="09/18/2015" DGUser="Fred Smith" />
<Details DGGroup="Invoice" DGName="Invoiced" DGDate="" DGUser="" />
</TrackingDetails>
Any ideas? TIA!
Here is one way to do it.
First group the results by DGGroup
Then print the group name only when position = 1
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:key name="groups" match="/TrackingDetails/Details" use="#DGGroup" />
<xsl:template match="/TrackingDetails">
<table id="Details">
<tr class="heading">
<th scope="col">DGGroup</th>
<th scope="col">DGName</th>
<th scope="col">DGDate</th>
<th scope="col">DGUser</th>
</tr>
<xsl:apply-templates select="Details[generate-id() = generate-id(key('groups', #DGGroup)[1])]"/>
</table>
</xsl:template>
<xsl:template match="Details">
<xsl:for-each select="key('groups', #DGGroup)">
<tr>
<xsl:choose>
<xsl:when test="position()=1">
<td><xsl:value-of select="#DGGroup"/></td>
</xsl:when>
<xsl:otherwise>
<td></td>
</xsl:otherwise>
</xsl:choose>
<td><xsl:value-of select="#DGName"/></td>
<td><xsl:value-of select="#DGDate"/></td>
<td><xsl:value-of select="#DGUser"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I wonder if it's possible to override the Recently Added list in the home page. The default behavior is that any new submitted items are displayed in the list regardless of its issue date. Is there a way to override it such that only the latest submitted publications issued for example within two years (or a conditional if dc.date.issued => 2014) are displayed?
I am using DSpace 5.3 Mirage 2 theme.
UPDATE
Using #terry's answer, here is the code I tried:
<xsl:template match="dri:referenceSet[#rend='recent-submissions']">
<xsl:for-each select="dri:reference">
<xsl:variable name="externalMetadataURL">
<xsl:text>cocoon:/</xsl:text>
<xsl:value-of select="#url"/>
<!-- No options selected, render the full METS document -->
</xsl:variable>
<xsl:comment> External Metadata URL: <xsl:value-of select="$externalMetadataURL"/> </xsl:comment>
<xsl:variable name="issue-date" select="document($externalMetadataURL)//dim:field[#element='date'][#qualifier='issued'][1]/text()"/>
<xsl:comment> External Metadata URL: <xsl:value-of select="$issue-date"/> </xsl:comment>
<!--
Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
An XSLT extension would be needed to computer the current date.
-->
<xsl:if test="$issue-date < 2014">
<xsl:apply-templates select="."/>
</xsl:if>
</xsl:for-each>
</xsl:template>
Also, as per suggestion of #schweerelos from my other post, I put a comment before the document() call to see if the metadata from the $externalMetadataURL were retrieved properly.
Viewing the source code in by browser, the metadata were retrieved properly (although it is not respecting my condition).
View Source
<div id="aspect_discovery_SiteRecentSubmissions_div_site-home" class="ds-static-div primary repository">
<h2 class="ds-div-head page-header">Recently Added</h2>
<div id="aspect_discovery_SiteRecentSubmissions_div_site-recent-submission" class="ds-static-div secondary recent-submission">
<!-- External Metadata URL: cocoon://metadata/handle/10862/2260/mets.xml-->
<!-- External Metadata URL: 2015-->
<!-- External Metadata URL: cocoon://metadata/handle/10862/2265/mets.xml-->
<!-- External Metadata URL: 2015-->
<!-- External Metadata URL: cocoon://metadata/handle/10862/2261/mets.xml-->
<!-- External Metadata URL: 2015-->
<!-- External Metadata URL: cocoon://metadata/handle/10862/2262/mets.xml-->
<!-- External Metadata URL: 2015-->
<!-- External Metadata URL: cocoon://metadata/handle/10862/2263/mets.xml-->
<!-- External Metadata URL: 2015-->
<p id="aspect_discovery_SiteRecentSubmissions_p_recent-submission-view-more" class="ds-paragraph recentSubmissionViewMore">
View more
And this is the DRI generated:
<div id="aspect.discovery.SiteRecentSubmissions.div.site-home" rend="primary repository" n="site-home">
<div id="aspect.discovery.SiteRecentSubmissions.div.site-recent-submission" rend="secondary recent-submission" n="site-recent-submission">
<head>Recently Added</head>
<referenceSet id="aspect.discovery.SiteRecentSubmissions.referenceSet.site-last-submitted" rend="recent-submissions" n="site-last-submitted" type="summaryList">
<reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2260/mets.xml"/>
<reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2265/mets.xml"/>
<reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2261/mets.xml"/>
<reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2262/mets.xml"/>
<reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2263/mets.xml"/>
</referenceSet>
<p id="aspect.discovery.SiteRecentSubmissions.p.recent-submission-view-more" rend="recentSubmissionViewMore" n="recent-submission-view-more">
<xref target="/recent-submissions">View more</xref>
</p>
</div>
</div>
Even if I remove my condition (eg <xsl:if test="$issue-date < 2014">), I'm still having blanks as the View Source code and the image below shows.
Any advice please?
The DSpace config file for recent items (discovery.xml) will allow you to set the metadata field that is used to pull recent items. You can alter that field from collection to collection. You can set the maximum number of items to pull, but you cannot set other filter criteria.
You will need to set that criteria in your XSLT using logic like the following.
<xsl:template match="dri:referenceSet[#rend='recent-submission']">
<xsl:for-each select="dri:reference">
<xsl:variable name="issue-date" select="document(#url)//dim:field[#element='date'][#qualifier='issued'][1]/text()"/>
<!--
Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
An XSLT extension would be needed to computer the current date.
-->
<xsl:if test="$issue-date > 2014">
<ul class="ds-artifact-list">
<xsl:apply-templates select="*[not(name()='head')]" mode="summaryList"/>
</ul>
</xsl:if>
<xsl:for-each>
</xsl:template>
The following stackoverflow answer indicates how to incorporate a java function into a DSpace XSLT stylesheet: See How to shorten filename displayed in DSpace
Ok, for my future reference, the code below is what I used to override the recent submissions list in the homepage using Mirage 2 theme. Thanks to #terrywb for his answer.
<xsl:template match="dri:div[#id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/dri:referenceSet[#rend='recent-submissions']">
<xsl:for-each select="dri:reference">
<xsl:variable name="externalMetadataURL">
<xsl:text>cocoon:/</xsl:text>
<xsl:value-of select="#url"/>
<!-- No options selected, render the full METS document -->
</xsl:variable>
<xsl:variable name="issue-date" select="document($externalMetadataURL)//dim:field[#element='date'][#qualifier='issued'][1]/text()"/>
<!--
Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
An XSLT extension would be needed to computer the current date.
-->
<xsl:if test="substring($issue-date,1,4) = date:year()">
<xsl:comment> External Metadata URL: <xsl:value-of select="$issue-date"/> </xsl:comment>
<xsl:comment> Current year is: <xsl:value-of select="date:year()"/> </xsl:comment>
<ul class="ds-artifact-list list-unstyled">
<xsl:apply-templates select="." mode="summaryList"/>
</ul>
</xsl:if>
</xsl:for-each>
</xsl:template>
Note that I used
<xsl:template match="dri:div[#id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/dri:referenceSet[#rend='recent-submissions']">
This is because if I just use <xsl:template match="dri:referenceSet[#rend='recent-submissions']">, it will also override the list after you clicked the View more link. I also used the date:year() XSLT extension to capture the current year so that I don't have to hardcode or change the year every year.
I changed 'Recently Added' modifying these code block in page-strucutre.xsl:
<!-- Otherwise use default handling of body -->
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
By this:
<!-- Otherwise use default handling of body -->
<xsl:otherwise>
<xsl:apply-templates select="*[not((#n='site-home'))]"/>
</xsl:otherwise>
This change will block render of 'Recently Added' and 'Community View'.
To show 'Recently Added' in other place on page-strucutre, I have create one template for this:
<xsl:template name="buildCustomRecent">
<ul class="list-group-plain" style="list-style: none;">
<xsl:variable name="countRecent">
<xsl:value-of select="count(/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*)" />
</xsl:variable>
<xsl:for-each select="/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*">
<xsl:variable name="externalMetadataURL">
<xsl:text>cocoon:/</xsl:text>
<xsl:value-of select="#url"/>
<!-- No options selected, render the full METS document -->
</xsl:variable>
<xsl:variable name="title"
select="document($externalMetadataURL)//dim:field[#element='title'][not(#qualifier)]"/>
<xsl:variable name="author"
select="document($externalMetadataURL)//dim:field[#element='contributor'][#qualifier='author'][1]/text()"/>
<xsl:variable name="issue-date"
select="document($externalMetadataURL)//dim:field[#element='date'][#qualifier='issued'][1]/text()"/>
<xsl:variable name="urlObjId" select="document($externalMetadataURL)//mets:METS/#OBJID"/>
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$urlObjId"/>
</xsl:attribute>
<xsl:value-of select="$title"/>
</a>
<br/>
<xsl:value-of select="concat($author,' (',$issue-date,')')"/>
<br/>
</li>
</xsl:for-each>
<xsl:if test="$countRecent=0">
<xsl:text>No itens to show.</xsl:text>
</xsl:if>
</ul>
</xsl:template>
I have a problem on grouping elements based on a criteria and eliminating the duplicates.
I have 2 records in XML. Document 1 and Document 2
The objective is to create a table with 3 sections. Same, Add, Delete. Elements both in the record should come in Same subsection with their quantities. Element which is not there in Doc 1 and present in Doc 2 should come into Add subsection and Elements which is there in Doc 1 and not present in Doc 2 should come into Delete subsection.
Here i am able to create 3 subsections with their total. Now my problem is to identify the similar elements based on rec_no in the same document and sum their quantities.
Here is the output table with my comments.
---------------------------------------------------------
Section RecNo Desc Doc-1 Qty Doc-2 Qty Total
---------------------------------------------------------
Same 111 Desc1 1 2 300
Same 444 Desc4 6 4 1000
---------------------------------------------------------
Same Total 1300
---------------------------------------------------------
Add 333 Desc3 3 0 300
Add 555 Desc5 5 0 500
---------------------------------------------------------
Add Total 800
---------------------------------------------------------
Delete 222 Desc2 0 2 200
Delete 777 Desc7 0 7 700
Delete 888 Desc8 0 10 1000
---------------------------------------------------------
Delete Total 1900
---------------------------------------------------------
Grand Total 4000
---------------------------------------------------------
Here is my XML
<Logia>
<DocHeader>
<Document>
<Downto>
<rec_no>111</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>100.00</Value>
</Downto>
<Downto>
<rec_no>333</rec_no>
<desc>Desc3</desc>
<qty>3</qty>
<Value>300.00</Value>
</Downto>
<Downto>
<rec_no>444</rec_no>
<desc>Desc4</desc>
<qty>6</qty>
<Value>400.00</Value>
</Downto>
<Downto>
<rec_no>555</rec_no>
<desc>Desc5</desc>
<qty>5</qty>
<Value>500.00</Value>
</Downto>
</Document>
<Document>
<Downto>
<rec_no>222</rec_no>
<desc>Desc2</desc>
<qty>2</qty>
<Value>200.00</Value>
</Downto>
<Downto>
<rec_no>111</rec_no>
<desc>Desc1</desc>
<qty>2</qty>
<Value>100.00</Value>
</Downto>
<Downto>
<rec_no>444</rec_no>
<desc>Desc4</desc>
<qty>4</qty>
<Value>400.00</Value>
</Downto>
<Downto>
<rec_no>777</rec_no>
<desc>Desc7</desc>
<qty>7</qty>
<Value>700.00</Value>
</Downto>
<Downto>
<rec_no>888</rec_no>
<desc>Desc8</desc>
<qty>8</qty>
<Value>800.00</Value>
</Downto>
<Downto>
<rec_no>888</rec_no>
<desc>Desc8</desc>
<qty>2</qty>
<Value>800.00</Value>
</Downto>
</Document>
</DocHeader>
</Logia>
and here is my XSLT
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="doc1" match="Document[1]/Downto" use="rec_no" />
<xsl:key name="doc2" match="Document[2]/Downto" use="rec_no" />
<xsl:template match="/Logia/DocHeader">
<table border="1">
<!-- header -->
<tr>
<th>Section</th>
<th>RecNo</th>
<th>Desc</th>
<th>Doc-1 Qty</th>
<th>Doc-2 Qty</th>
<th> Total</th>
</tr>
<!-- same -->
<xsl:variable name="same" select="Document[1]/Downto[key('doc2', rec_no )]" />
<xsl:apply-templates select="$same">
<xsl:with-param name="section">Same</xsl:with-param>
</xsl:apply-templates>
<xsl:variable name="same-total" select="sum($same/Value)" />
<tr>
<td colspan="5">Same Total</td>
<th><xsl:value-of select="$same-total"/></th>
</tr>
<!-- add -->
<xsl:variable name="add" select="Document[1]/Downto[not(key('doc2', rec_no ))]" />
<xsl:apply-templates select="$add">
<xsl:with-param name="section">Add</xsl:with-param>
</xsl:apply-templates>
<xsl:variable name="add-total" select="sum($add/Value)" />
<tr>
<td colspan="5">Add Total</td>
<th><xsl:value-of select="$add-total"/></th>
</tr>
<!-- delete -->
<xsl:variable name="delete" select="Document[2]/Downto[not(key('doc1', rec_no ))]" />
<xsl:apply-templates select="$delete">
<xsl:with-param name="section">Delete</xsl:with-param>
</xsl:apply-templates>
<xsl:variable name="delete-total" select="sum($delete/Value)" />
<tr>
<td colspan="5">Delete Total</td>
<th><xsl:value-of select="$delete-total"/></th>
</tr>
<!-- grand total -->
<tr>
<th colspan="5">Grand Total</th>
<th><xsl:value-of select="$same-total + $add-total + $delete-total"/></th>
</tr>
</table>
</xsl:template>
<xsl:template match="Downto">
<xsl:param name="section"/>
<tr>
<td><xsl:value-of select="$section"/></td>
<td><xsl:value-of select="rec_no"/></td>
<td><xsl:value-of select="desc"/></td>
<td><xsl:value-of select="qty"/></td>
<td><xsl:value-of select="qty"/></td>
<td><xsl:value-of select="Value"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Any help is appreciated.
There is not much to change in your code:
New key:
<xsl:key name="docByRecNo" match="Document/Downto" use="rec_no" />
Modify template that matches Downto:
<xsl:template match="Downto">
<xsl:param name="section"/>
<xsl:if test="generate-id() = generate-id(key('docByRecNo', rec_no)[1])">
<tr>
<td><xsl:value-of select="$section"/></td>
<td><xsl:value-of select="rec_no"/></td>
<td><xsl:value-of select="desc"/></td>
<td><xsl:value-of select="sum(key('doc1', rec_no)/qty)"/></td>
<td><xsl:value-of select="sum(key('doc2', rec_no)/qty)"/></td>
<td><xsl:value-of select="sum(key('docByRecNo', rec_no)/Value)"/></td>
</tr>
</xsl:if>
</xsl:template>
Here we select only those Downto records that are the first elements in group with the same rec_no (Muench grouping).
I can declare a variable “myVariable” with a value “111” in the global scope.
But how can I re-assign a value locally. Or is there a alternative way to achieve this.
Please help.
Thank you.
Ravi
You can re-define the same variable inside a template:
<xsl:variable name="myVariable" select="'111'"/>
<xsl:template match="/">
<xsl:variable name="myVariable" select="'112'"/>
. . .
</xsl:template>
Note though that 'variables' in XSLT are actually constant - you are not re-assigning a different value to the same variable, you are re-defining it inside the template - outside the template myVariable will still have the value 111.
You can accomplish what you want to do, by using jscript/vbscript. Here is example using Jscript.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict"
xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:var='urn:var'
xmlns:JS='urn:JS'
>
<xsl:output method="html"/>
<xsl:variable name="n" select="1"/>
<xsl:template match="/NewDataSet">
<html>
<head>
<style>
table{border-collapse:collapse}
table,td{border:1px solid black;color:black; background-color:white}
table,th{border:1px solid balck;background-color:black;color:white }
.rt{color:red}
.redb{color:yellow; background-color:red;}
.greenb{color:white;background-color:green;}
</style>
<title>EDI validation Result </title>
</head>
<body>
<div font="bold">
EDI validation result for the PO <xsl:value-of select="info/pono"/>
</div>
<div>
received from <xsl:value-of select="info/CustomerName"/>
</div>
<xsl:variable name='var:hasErrors' select='0'/>
<xsl:variable name='var:ngoodlines' select='0' />
<xsl:variable name='var:nbadlines' select='0' />
<table>
<th>Position</th>
<th>Item Code</th>
<th>UoM</th>
<th>Ordered Qty.</th>
<th>Net-Quoted</th>
<th>Net-Catalog</th>
<th>Status</th>
<xsl:for-each select="Table">
<tr>
<xsl:choose>
<xsl:when test="Status !=''">
<xsl:value-of disable-output-escaping="yes" select="JS:IncBlines()"/>
<td class="redb"><xsl:value-of select="Position"/></td>
<td class="redb"><xsl:value-of select="ItemCode"/></td>
<td class="redb"><xsl:value-of select="UoM"/></td>
<td class="redb"><xsl:value-of select="QtyOrdered"/></td>
<td class="redb"><xsl:value-of select="PriceQuoted"/></td>
<td class="redb"><xsl:value-of select="Net"/></td>
<td class="redb"><xsl:value-of select="Status"/></td>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="JS:IncGlines()"/>
<td class="greenb"><xsl:value-of select="Position"/></td>
<td class="greenb"><xsl:value-of select="ItemCode"/></td>
<td class="greenb"><xsl:value-of select="UoM"/></td>
<td class="greenb"><xsl:value-of select="QtyOrdered"/></td>
<td class="greenb"><xsl:value-of select="PriceQuoted"/></td>
<td class="greenb"><xsl:value-of select="Net"/></td>
<td class="greenb"><xsl:value-of select="Status"/>OK</td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
<xsl:if test="JS:GetBlines() > 0" >
<div class="rt">
<p>
The order validation has failed ,
The order will not be processesed as there are <xsl:value-of select ="JS:GetBlines()"/> lines in error.
<xsl:if test="JS:GetGlines() > 0">
Although there are <xsl:value-of select="JS:GetGlines()"/> line item(s) are that comply the requirements, <p>
The P.O is rejected as per agreed processing rules.
</p>
</xsl:if>
</p>
</div>
</xsl:if>
<xsl:value-of select="JS:GetBlines()"/>
<xsl:value-of select ="JS:GetGlines()"/>
</body>
</html>
</xsl:template>
<msxsl:script language='JScript' implements-prefix='JS'>
<![CDATA[
var j :int=0;
var blines:int =0;
var glines:int=0;
function Inc(current)
{j=j+current;
return j+current;
}
function IncBlines()
{
blines++;
}
function IncGlines()
{
glines++;
}
function GetBlines()
{
return blines;
}
function GetGlines()
{
return glines;
}
]]>
</msxsl:script>
</xsl:stylesheet>
<NewDataSet>
<Table>
<Position>1</Position>
<ItemCode>691-301-004</ItemCode>
<QtyOrdered>1</QtyOrdered>
<PriceQuoted>0.00</PriceQuoted>
<Net>0.0000</Net>
<UoM>EA</UoM>
<Status>Not in Catalog</Status>
</Table>
<Table>
<Position>2</Position>
<ItemCode>106284-133</ItemCode>
<QtyOrdered>1</QtyOrdered>
<PriceQuoted>20.00</PriceQuoted>
<Net>0.0000</Net>
<UoM>EA</UoM>
<Status>Not in Catalog</Status>
</Table>
<Table>
<Position>3</Position>
<ItemCode>116304-317</ItemCode>
<QtyOrdered>1</QtyOrdered>
<PriceQuoted>25.00</PriceQuoted>
<Net>0.0000</Net>
<UoM>EA</UoM>
<Status>Not in Catalog</Status>
</Table>
<Table>
<Position>4</Position>
<ItemCode>574116-035</ItemCode>
<QtyOrdered>10</QtyOrdered>
<PriceQuoted>1598.85</PriceQuoted>
<Net>1865.5000</Net>
<QtyApplicable>99999999</QtyApplicable>
<UoM>EA</UoM>
<Status>Quoted Price does not match Catalog price</Status>
</Table>
<Table>
<Position>5</Position>
<ItemCode>110223-301</ItemCode>
<QtyOrdered>10</QtyOrdered>
<PriceQuoted>147.88</PriceQuoted>
<Net>147.8800</Net>
<QtyApplicable>99999999</QtyApplicable>
<UoM>EA</UoM>
</Table>
<info>
<baanid>xxx-xxxxxx</baanid>
<pono>xxx0002987</pono>
<CustomerName>[xxx-xxxxxx]-xxxxxxxxxxxxxxxxxxxxxxxxx x xxxxx/CustomerName>
</info>
</NewDataSet>
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:exforms="http://www.exforms.org/exf/1-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:date="http://exslt.org/dates-and-times">
<xhtml:head>
<xforms:model id="model">
<xforms:instance id="test">
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<add>
<yes></yes>
</add>
</form>
</xforms:instance>
<xforms:instance id="duplicate-section">
<form>
<add>
<yes></yes>
</add>
</form>
</xforms:instance>
<xforms:bind id="yes" nodeset="instance('test')/add/yes" />
</xforms:model>
</xhtml:head>
<xhtml:body>
<table>
<tr>
<td>
<xforms:trigger incremental="true">
<xforms:label>Add</xforms:label>
<xforms:insert ev:event="DOMActivate" context="instance('test')" origin="instance('duplicate-section')/add"/>
</xforms:trigger>
</td>
</tr>
<xforms:repeat nodeset="instance('test')/add" id="add-repeat" startindex="1">
<tr>
<td><xforms:output ref="position()"/></td>
<td>
<fr:currency ref="yes" incremental="true">
</fr:currency>
</td>
</tr>
</xforms:repeat>
</table>
</xhtml:body>
</xhtml:html>
Consider that, I click add button 5 times and enter values in the 5 text boxes. I want to find the sum of these 5 values entered and also I would like to find the maximum value of these 5 values. How can I achieve this ? I just want to display the sum and the maximum value.
For Sum you can output this xpath expression:
<xforms:output value="sum(instance('test')/add/yes)" />
For Max, use this:
<xforms:output value="max(instance('test')/add/yes)" />