<?xml-stylesheet type="text/xsl" href="/exist/rest/db/apps/xsltforms/xsltforms.xsl"?><?xsltforms-options debug="yes"?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Balance</title>
        <style type="text/css">
			.amount input {
			width : 60px;
			}

			.desc input {
			width : 100px;
			}

			.delete button {
			padding : 0px;
			}
		</style>
        <xforms:model xmlns:xforms="http://www.w3.org/2002/xforms">
            <xforms:instance>
                <balance xmlns="">
                    <transaction>
                        <date>2012-11-06</date>
                        <desc>Salary</desc>
                        <withdraw>false</withdraw>
                        <amount>5000.00</amount>
                    </transaction>
                    <transaction>
                        <date>2012-11-06</date>
                        <desc>Newspaper</desc>
                        <withdraw>true</withdraw>
                        <amount>2.00</amount>
                    </transaction>
                    <totals>
                        <in>0</in>
                        <out>0</out>
                        <total>0</total>
                    </totals>
                </balance>
            </xforms:instance>
            <xforms:bind nodeset="transaction/date" type="xsd:date"/>
            <xforms:bind nodeset="transaction/amount" type="xforms:amount"/>
            <xforms:bind nodeset="totals/in" type="xforms:amount" calculate="sum(/balance/transaction[withdraw='false']/amount)"/>
            <xforms:bind nodeset="totals/out" type="xforms:amount" calculate="sum(/balance/transaction[withdraw='true']/amount)"/>
            <xforms:bind nodeset="totals/total" type="xforms:amount" calculate="../in - ../out"/>
            <xforms:submission id="s01" method="post" show="new" replace="all" resource="xsltforms/txs.php?exec=beautify.txs">
                <xforms:message xmlns:ev="http://www.w3.org/2001/xml-events" level="modeless" ev:event="xforms-submit-error">Submit error.</xforms:message>
            </xforms:submission>
            <xforms:submission id="s02" method="xml-urlencoded-post" replace="none" resource="xsltforms/txs.php?exec=returnasattachment.txs&amp;file=mybalance.xml">
                <xforms:message xmlns:ev="http://www.w3.org/2001/xml-events" level="modeless" ev:event="xforms-submit-error">Submit error.</xforms:message>
            </xforms:submission>
        </xforms:model>
        <style type="text/css">
    body {
        margin-left:2em;
        margin-top:2em;
        font-size:110%;
    }
    input {
        margin-left:1em;
        margin-right:1em;
    }
    #xsltforms_console {
        margin-top:3em;
        padding-top:1em;
        font-size:75%;
        }
    iframe {
        display:none;
    }
    #xsltforms_debug {
        padding-bottom:1em;
    }
    
    .btn {
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    background-color: #F5F5F5;
    background-image: linear-gradient(to bottom, #FFFFFF, #E6E6E6);
    background-repeat: repeat-x;
    border-bottom-color: #A2A2A2;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    border-image-outset: 0 0 0 0;
    border-image-repeat: stretch stretch;
    border-image-slice: 100% 100% 100% 100%;
    border-image-source: none;
    border-image-width: 1 1 1 1;
    border-left-color-ltr-source: physical;
    border-left-color-rtl-source: physical;
    border-left-color-value: #BBBBBB;
    border-left-style-ltr-source: physical;
    border-left-style-rtl-source: physical;
    border-left-style-value: solid;
    border-left-width-ltr-source: physical;
    border-left-width-rtl-source: physical;
    border-left-width-value: 1px;
    border-right-color-ltr-source: physical;
    border-right-color-rtl-source: physical;
    border-right-color-value: #BBBBBB;
    border-right-style-ltr-source: physical;
    border-right-style-rtl-source: physical;
    border-right-style-value: solid;
    border-right-width-ltr-source: physical;
    border-right-width-rtl-source: physical;
    border-right-width-value: 1px;
    border-top-color: #BBBBBB;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    border-top-style: solid;
    border-top-width: 1px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(0, 0, 0, 0.05);
    color: #333333;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    line-height: 20px;
    margin-top:1em;
    margin-bottom:1em;
    padding-bottom: 4px;
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 4px;
    text-align: center;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
    vertical-align: middle;
    }
    .btn:hover, .btn:active, .btn.active, .btn.disabled, .btn[disabled] {
    background-color: #E6E6E6;
    color: #333333;
    }
    .btn:active, .btn.active {
    }
    .btn:first-child {
    }
    .btn:hover {
    -moz-text-blink: none;
    -moz-text-decoration-color: -moz-use-text-color;
    -moz-text-decoration-line: none;
    -moz-text-decoration-style: solid;
    background-color: #E6E6E6;
    background-position: 0 -15px;
    color: #333333;
    transition-delay: 0s;
    transition-duration: 0.1s;
    transition-property: background-position;
    transition-timing-function: linear;
    }
    .btn:focus {
    outline-color: #333333;
    outline-offset: -2px;
    outline-style: dotted;
    outline-width: thin;
    }
    .btn.active, .btn:active {
    background-color: #E6E6E6;
    background-image: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) inset, 0 1px 2px rgba(0, 0, 0, 0.05);
    outline-color: -moz-use-text-color;
    outline-style: none;
    outline-width: 0;
    }
    a {
    text-decoration:none;
    color: #0088CC;
    }
    a:hover {
    -moz-text-blink: none;
    -moz-text-decoration-color: -moz-use-text-color;
    -moz-text-decoration-line: underline;
    -moz-text-decoration-style: solid;
    color: #005580;
    }
    .xforms-value {margin-left:1em;}
    .description {
        color: gray;
        margin-top:2em;
        font-size: 80%;}
</style>
    </head>
    <body>
        <div class="source">
            <div class="toolbar">
                <a class="btn" href="/exist/apps/eXide/index.html?open=/db/apps/XSLTForms-Demo/data/balance.xml" target="eXide" data-type="XML" title="Opens the form in eXide.">Open form in eXide</a>
            </div>
        </div>
        <h3>Balance</h3>
        <table>
            <tbody>
                <xforms:repeat xmlns:xforms="http://www.w3.org/2002/xforms" nodeset="transaction" id="transactions" appearance="compact">
                    <tr>
                        <td>
                            <xforms:input ref="date">
                                <xforms:label>Date</xforms:label>
                            </xforms:input>
                        </td>
                        <td>
                            <xforms:select1 ref="withdraw" appearance="minimal">
                                <xforms:label>Type</xforms:label>
                                <xforms:item>
                                    <xforms:label>Withdraw</xforms:label>
                                    <xforms:value>true</xforms:value>
                                </xforms:item>
                                <xforms:item>
                                    <xforms:label>Deposit</xforms:label>
                                    <xforms:value>false</xforms:value>
                                </xforms:item>
                            </xforms:select1>
                        </td>
                        <td>
                            <xforms:input ref="desc" class="desc">
                                <xforms:label>Description</xforms:label>
                            </xforms:input>
                        </td>
                        <td>
                            <xforms:input ref="amount[../withdraw = 'false']" class="amount">
                                <xforms:label>Deposit</xforms:label>
                            </xforms:input>
                        </td>
                        <td>
                            <xforms:input ref="amount[../withdraw = 'true']" class="amount">
                                <xforms:label>Withdraw</xforms:label>
                            </xforms:input>
                        </td>
                        <td>
                            <xforms:trigger class="delete">
                                <xforms:label>X</xforms:label>
                                <xforms:delete xmlns:ev="http://www.w3.org/2001/xml-events" nodeset="." at="1" ev:event="DOMActivate" if="count(transaction) &gt; 1"/>
                            </xforms:trigger>
                        </td>
                    </tr>
                </xforms:repeat>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="3">Totals</td>
                    <td style="text-align: right;">
                        <xforms:output xmlns:xforms="http://www.w3.org/2002/xforms" ref="totals/in"/>
                    </td>
                    <td style="text-align: right;">
                        <xforms:output xmlns:xforms="http://www.w3.org/2002/xforms" ref="totals/out"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">Balance</td>
                    <td colspan="2" style="text-align: right;">
                        <xforms:output xmlns:xforms="http://www.w3.org/2002/xforms" ref="totals/total"/>
                    </td>
                </tr>
            </tfoot>
        </table>
        <xforms:trigger xmlns:xforms="http://www.w3.org/2002/xforms">
            <xforms:label>New withdraw</xforms:label>
            <xforms:action xmlns:ev="http://www.w3.org/2001/xml-events" ev:event="DOMActivate">
                <xforms:insert nodeset="transaction" position="after" at="last()"/>
                <xforms:setvalue ref="transaction[last()]/date" value="substring-before(now(), 'T')"/>
                <xforms:setvalue ref="transaction[last()]/amount" value="'0.00'"/>
                <xforms:setvalue ref="transaction[last()]/withdraw">true</xforms:setvalue>
                <xforms:setvalue ref="transaction[last()]/desc"/>
            </xforms:action>
        </xforms:trigger>
        <xforms:trigger xmlns:xforms="http://www.w3.org/2002/xforms">
            <xforms:label>New deposit</xforms:label>
            <xforms:action xmlns:ev="http://www.w3.org/2001/xml-events" ev:event="DOMActivate">
                <xforms:insert nodeset="transaction" position="after" at="last()"/>
                <xforms:setvalue ref="transaction[last()]/date" value="substring-before(now(), 'T')"/>
                <xforms:setvalue ref="transaction[last()]/amount" value="'0.00'"/>
                <xforms:setvalue ref="transaction[last()]/withdraw">false</xforms:setvalue>
                <xforms:setvalue ref="transaction[last()]/desc"/>
            </xforms:action>
        </xforms:trigger>
        <!--<xforms:submit submission="s01">
            <xforms:label>View</xforms:label>
        </xforms:submit>-->
        <!--<xforms:submit submission="s02">
            <xforms:label>Save As</xforms:label>
        </xforms:submit>-->
        <xforms:trigger xmlns:xforms="http://www.w3.org/2002/xforms">
            <xforms:label>Reset</xforms:label>
            <xforms:dispatch xmlns:ev="http://www.w3.org/2001/xml-events" name="xforms-reset" target="default-model" ev:event="DOMActivate"/>
        </xforms:trigger>
        <div xmlns="" class="description">
            <description/>
        </div>
    </body>
</html>