Complete Accounting Using XML and Network Envirinment

 

   Complete Accounting through XML Technology Alone

within a Network Environment

By

Dr. Subodh Chandra Garai

[This paper was prepared when working as Reader in Commerce of K. K. Das College, Kolkata - 700 084, in the year 2004]

ABSTRACT

Today’s competitive and risky business environment demands continuous, timely and relevant information through state-of-the-art IT supported communication system using a standardised and widely accepted electronic or digital language (e.g., eXtensible Markup Language, XML, eXtensible Business Reporting Language, XBRL etc.) capable of storing, manipulating, communicating and displaying data comfortably and cheaply for good corporate governance including satisfaction of the management as well as the stakeholders. In this paper an attempt is made to devise a process of complete accounting (i.e., up to the point of marshaled final balance sheet preparation) for an entity using solely XML technology within a network environment by means of Active Server Pages (ASP).

Due to massive advancement of information technology in terms of (1) favourable speed and memory capacity per rupee of hardware, (2) efficient telecommunication and client/server [Bradley (1993), Kothari (2003), Kuo (2004)] or peer-to-peer [Krishnan et al. (2003), Fakas & Karakostas (2004)] intranet (as well as Internet) facility and (3) progress of web-enabled dynamic and interactive system and basic application software (e.g., Common Gateway Interface, CGI or Active Server Pages, ASP etc.) technology, business communication (including storing and processing of data) system has significantly gone forward a dramatic step. In today’s competitive environment and hence risky situations, timely and relevant information is continuously required by every business house from inside and outside of the organization for planning, decision-making, controlling and many other administrative and important activities [Bradley et al. (1993), Fingar (1996)]. Again, for good corporate governance and regulatory and other filings, business and other information or documents are required to be stored and processed electronically following a widely accepted and standardized format1 which can also be displayed easily in traditional style and format. Consequently, accounting information system of an organisation should strive to use most and up to date facilities of the technology on one hand and satisfy the needs of the management as well as of the stakeholders accordingly on the other. In this standpoint, it is worthy of a mention that one of the most recent development of IT is the XML (eXtensible Markup Language) technology that is capable of storing, manipulating, communicating and displaying2 data comfortably and cheaply and it is also being quickly and universally accepted and widely applied in different areas. The World Wide Web Consortium has released its recommendations on 3rd edition of the XML version 1.0 on 4th February, 2004 at http://www.w3.org/TR/2004/REC-xml-20040204/. In this context, XBRL International3 devised eXtensible Business Reporting Language (XBRL, which is also XML based) is an advanced step towards standardization, for filing of business documents in electronic version [Vasal & Srivastava (2002)].

In market, there are several accounting software solution packages in use but those are proprietary and patented in nature [Johnston (2003)]; information on degree and extent of present day technology used by them cannot be readily and objectively known. However, in an earlier attempt [Garai (2003)], the present author devised a method of traditional accounting up to the preparation of trial balance, using Relational Database Management System technology within a network environment (i.e., applying the ASP technology at the front end). In this paper, an attempt is made to perform the traditional complete accounting tasks (i.e., up to the preparation of final balance sheet) using XML technology alone again with the help of Active Server Pages in a network environment too. For a working knowledge on ASP 3.0 and a preliminary concept on XML Buser et al. (1999) may be consulted. For further enquiry on XML, XSLT and related topics inquisitive readers may go through Harold (2000), Patel-Schneider and Siméon (2003), Diao et al. (2003) etc. but for most recent developments on XML and ASP technologies, on line help files and Internet sources may be explored. Some relevant Internet addresses are given in Reference section of this paper. On intranet and Internet technologies including Hypertext Transfer Protocol (http://) and Common Gateway Interface (CGI), elaborate discussions are also available in Muller (1999). A most appropriate resource for the present work is MSXML 4.0 SDK which is available free from ‘Microsoft Downloads’ through Internet, for advanced topics on XML like XML Document Object Model (DOM), XML Schema Definition, formatting XML documents using eXtensible Style Language Transform files, XPath programming etc.

[2]

                                The XML Model of Complete Accounting

The structure of XML-documents4 is apparent and hence it elicits no further mention or explanation – Figure 6 and Figure 9 of the next section may be verified in this regard. In our XML-formatted documents, all spaces between words for document name (used as the name of the documentElement or root element of the document concerned) are removed, e.g., opBalanceSheet etc. and spaces within name of elements (i.e., of leaf-nodes) are filled using an underscore character (_), e.g., Name_of_Account, Opening_Balance etc. because the name of an XML element (called ‘no-colon-name’ or ‘NCName’) does not accept white spaces (including the space character) and some reserved characters or symbols. It is to be noted that in XML-formatted opening Balance Sheet a negative sign precedes the amount for a liability item.

To use functional notation, suppose for an accounting entity,

BOX is the balance sheet at the point of time t0, i.e., BOX is the opening balance sheet at the beginning of an accounting period and

JX is the Journal for the time span t0 to t1, i.e., for the above-mentioned accounting period.

Then,       J = fJ(JX, SJX).                                                                                                            (1)

Here, J is the traditionally formatted and styled output for the Journal of the accounting entity for the said accounting period and it is functionally related to JX and the corresponding eXtensible Style Language Transform (XSLT) file, SJX, in XML format (for such styled transformation of JX).

Again,    LX = fL(BOX, JX).                                                                                                        (2)

Here, LX is the Ledger (containing all accounts before preparation of final accounts) for the said time period. That is to say, LX is functionally related to both BOX and JX. It should be remembered that all BOX, JX and LX are in XML format – the subscript X in each case is used here for indicating an XML formatted document.

Now,      Oi = fO(LX, SXi),               i=1, 2, 3, 4 and 5.                                                               (3)

Here, Oi is the ith output (account or statement), i.e., they are the group or collection of Ledger accounts5, Receipt & Payment A/c, Trial Balance, Profit & Loss A/c (or Income & Expenditure A/c, for a non-profit seeking entity) and Balance Sheet (closing and final) respectively, in one of the traditional format; SXi is the corresponding XSLT file certainly in XML format. Thus, the same LX is transformed to a desired output Oi (i.e., account or statement) passing through the same process by application of an appropriate XSLT file, SXi.

            During the process of transformation of XML formatted LX to traditionally formatted final balance sheet (i.e., O5), an intermediate product in XML format (say, BX) for final balance sheet can be produced using a template file in XML format (say, BTX with no textual content which is shown in the next section) for the facility of marshaling of closing final balance sheet, O5. In effect, from this BX (i.e., the XML-formatted closing balance sheet of a preceding period), the opening balance sheet of the immediately succeeding period BOX is derived in XML format too but the XML-elements (or nodes) of this file are defined and arranged in a different way which will be detailed and shown (Figure 6 and Figure 7) in the next section. The category of each ledger account (i.e., a capital item as well as a revenue item) in BOX shall accompany with their corresponding name of account such that the opening balance of a revenue income or expenditure account or of an account opened during the period shall have zero value.

            Diagrammatically, the process of getting XML-formatted Ledger and other subsequent accounts and statements is summarized in Figure 1, in two steps, as follows:

[3]

Figure 1

Each call of ASP file “Ledger.asp”, through a browser (preferably Internet Explorer 5.0 or a higher version), expects choice via drop-down or combo boxes for preparation and exhibition of styled account(s) or statement; albeit as a default setting (i.e., for the first time) ‘All Ledger Accounts’ in traditional T-format will be shown.

The Implementation of the XML Model of Accounting

            In this section, we shall detail our present accounting process using XML technology alone following the model proposed in the preceding section. As the Home Page for our complete accounting job, we shall use the Active Server Page (ASP) that follows:

Figure 2

All ASP’s in HTML format with server and client VBScripts are given in Appendix A. All instructions with comments and run time messages are clearly provided in each page including for this Accounting Home Page which is given filename “default.asp” and saved in the virtual directory of our intranet site (i.e., using Personal Web Server, PWS, within WindowsME or Internet Information Server, IIS, within WindowsXP) in the server computer, say, “http://garai/” as shown in Figure 2. Albeit, the “global.asa”6 file may also be saved in this virtual directory to create some session level ActiveX objects within <OBJECT> </OBJECT> tags and to perform some session level common tasks through server VBScripts.

            For creation of a new account during an accounting period we have to click the menu item I of our Accounting Home Page which will open the following ASP (saved in the same directory with filename “NewAccount.asp”):

Figure 3

[4]

Indeed, this same menu item will also be activated and same ASP shown as Figure 3 should be used to start the initial accounting job too at the beginning of an accounting period. For an accounting entity which already applied this system of accounting for a previous period, from the closing final Balance Sheet in XML format (i.e., BX as mentioned earlier in the immediately preceding section), the new XML-formatted opening Balance Sheet (i.e., BOX, of the preceding section) will be automatically created and saved with filename “opBalanceSheet.xml” in the same directory) – but before starting accounting job for a subsequent period the already existing “opBalanceSheet.xml” file must be deleted (i.e., must be permanently and manually removed from this directory) and all accounts characterizing revenue income or expenditure should be opened with appropriate category and zero opening balance, using this ASP shown as Figure 3. The dropdown box as shown in this Web page shows all the categories of accounts from the template file in XML-format (BTX of the preceding section) and direct and indirect revenue incomes and expenditures. Albeit, on first introduction of this system of accounting for an accounting entity, opening Balance Sheet in XML format must be created and saved as “opBalanceSheet.xml” in the same directory – for this purpose, the menu item VI (sub-items i & ii) of the Accounting Home Page may be effectively used. The first sub-item of this menu item will open the following ASP (saved as “createXML.asp” in the virtual directory):

Figure 4

It is to be noted here that the page shown, as Figure 4, shall initially give the names of leaf-nodes as “Child_No.1”, “Child_No.2” etc. And to rename the childNodes of the childNodes of the documentElement for the XML file the second sub-item of menu item VI of the Accounting Home Page should be activated which will open the following ASP (saved as “NamesXML.asp” in the same virtual directory):

Figure 5

[5]

Hence, the opening Balance Sheet in required XML format will appear as:

Figure 6

And this balance sheet in styled tabular form (applying appropriate XSLT file for transformation) for our illustrative simplified (only to save space) case is as follows:

Figure 7

[6]

It is already mentioned that we have taken an XML-formatted template  for marshaling of closing and final balance sheet — from this template, categories of all asset and liability items are taken and they also appear as entries in the dropdown or combo box in Figure 3. This XML-formatted template file (BTX of the preceding section, saved with filename “financialStatements.balanceSheet.xml” in the same virtual directory) is completely reproduced here for its proper anatomy as follows:

<?xml version="1.0" encoding=”utf-8”?>

 <financialStatements.balanceSheet>

  <balanceSheet.equitiesAndLiabilities>

 <equitiesAndLiabilities.equities>

  <equities.capitals />

 <equities.reserves>

  <reserves.capitalReserves />

  <reserves.specificFunds />

  <reserves.revenueReserves />

  </equities.reserves>

  </equitiesAndLiabilities.equities>

 <equitiesAndLiabilities.liabilities>

 <liabilities.longTermLiabilities>

  <longTermLiabilities.longTermSecuredLoans />

  <longTermLiabilities.longTermUnsecuredLoans />

  </liabilities.longTermLiabilities>

 <liabilities.midTermLiabilities>

  <midTermLiabilities.midTermSecuredLoans />

  <midTermLiabilities.midTermUnsecuredLoans />

  </liabilities.midTermLiabilities>

  <liabilities.currentLiabilities>

  <currentLiabilities.tradeCreditors />

  <currentLiabilities.otherCurrentLiabilities />

  </liabilities.currentLiabilities>

 <liabilities.provisions>

  <provisions.provisionsForTaxation />

  <provisions.otherProvisions />

  </liabilities.provisions>

 <liabilities.otherLiabilities>

  <OtherLiabilities.contraItems />

  <OtherLiabilities.miscellaneousLiabilities />

  </liabilities.otherLiabilities>

  </equitiesAndLiabilities.liabilities>

  </balanceSheet.equitiesAndLiabilities>

 <balanceSheet.assets>

 <assets.fixedAssets>

  <fixedAssets.intangibleFixedAssets />

  <fixedAssets.tangibleFixedAssets />

  </assets.fixedAssets>

 <assets.investments>

  <investments.longTermInvestments />

  <investments.investmentsForSpecificFunds />

  <investments.shortTermInvestments />

  </assets.investments>

 <assets.currentAssets>

 <currentAssets.stocksAndStores>

  <stocksAndStores.directMaterials />

  <stocksAndStores.indirectMaterials />

  </currentAssets.stocksAndStores>

 <currentAssets.receivablesAndCashEquivalents>

<receivablesAndCashEquivalents.receivables>

  <receivables.tradeDebtors />

  <receivables.otherReceivables />

  </receivablesAndCashEquivalents.receivables>

 <receivablesAndCashEquivalents.CashEquivalents>

  <CashEquivalents.currentBanks />

  <CashEquivalents.cash />

  </receivablesAndCashEquivalents.CashEquivalents>

  </currentAssets.receivablesAndCashEquivalents>

[7]

 <currentAssets.otherCurrentAssets>

  <otherCurrentAssets.accruedIncomes />

  <otherCurrentAssets.prepidExpenses />

  </currentAssets.otherCurrentAssets>

  </assets.currentAssets>

 <assets.fictitiousAssets>

  <fictitiousAssets.deferredRevenueExpenditures />

  <fictitiousAssets.cumulativeDeficitOrLoss />

  <fictitiousAssets.otherFictitiousAssets />

  </assets.fictitiousAssets>

 <assets.otherAssets>

  <OtherAssets.contraItems />

  <OtherAssets.miscellaneousAssets />

  </assets.otherAssets>

  </balanceSheet.assets>

  </financialStatements.balanceSheet>

Following the XBRL specification, the name of each element forming a class (or category) or descendant of that class starting from the element named “financialStatements.balanceSheet”, consists of two parts separated by a period character (.) using lower camel case convention7 – the first part of each element name is the last part of the name of its immediate parent and the last part is the category of asset or liability items (as the case may be) which are contained within the element under consideration as its children. Accordingly, for our XML-formatted opening balance sheet the category is taken from the last part of the immediate parent element as mentioned here which is evident also from Figure 6 and Figure 7. In this template for final balance sheet in XML-format, it is noticeable that the elements with no branch or child (called leaves) are closed using a forward slash (/) before the ‘>’ character at the right-end. During actual preparation of the final balance sheet, each liability/ asset item will try to find place mainly within these elements. Although a more comprehensive and generalized structure of a balance sheet can be formulated, regarding the content of our template, it is worthy of a mention that an accounting entity may maintain some accounts in the capacity of a custodian, fiduciary, guarantor or bailee. And for such items proper (e.g., Employees’ Provident Fund A/c or Loan from Bank Taken by Employees A/c) the accounting entity has no direct or immediate interest though such an account may show a debit or credit balance or both debit and credit balances in slightly different names; hence such type of accounts is categorized here as ‘contraItems’, in the present taxonomical viewpoint.

            Though the final balance sheet is now devised to fit to any type of organisation, in this project for the sake of simplicity and normal requirement, only the profit and loss account is drawn by transfer of all direct and indirect revenues and expenditures (categorized respectively as ‘directRevenues’, ‘directExpenditures’, ‘indirectRevenues’ and ‘indirectExpenditures’, under lower camel case convention) to this account of an accounting entity. Albeit, some simple adaptations/ modifications of the same methodology will enable to show (i) Trading and Profit & Loss Accounts for ordinary business concerns, (ii) Trading and Income & Expenditure Accounts for a club with provisions sales or (iii) Profit & Loss and Income & Expenditure (of household) Accounts for a professional person. Each of all the direct and indirect revenues and expenditures must be shown in the opening balance sheet with appropriate category (in the concerned XML document for opening Balance Sheet as shown in Figure 6 and Figure 7, the same file of Figure 6 but in readily intelligible format, following the lower camel case convention mentioned earlier) with zero opening balance, incontrovertibly, any new account may be subsequently opened with zero balance too. Proper categorization of the accounts will lead to preparation of correct and meaningful Profit & Loss A/c and final Balance Sheet.

[8]

            After conception of the opening Balance Sheet according to the procedures stated in the earlier part of this section in the virtual directory, for an accounting entity whether it used this system of accounting for an earlier period or not, the journal entries can be passed using the following ASP (saved with filename “JournalEntry.asp” in the said virtual directory) with a calendar control or ActiveX object too and activated through the hyperlink of menu item II of the Accounting Home Page shown in Figure 2:

Figure 8

All relevant instructions, run time errors as warnings (especially as voucher numbers shall be unique8) and other messages are available in appropriate situation, from this page. In effect, the Journal in XML format (saved automatically with the filename “Journal.xml” in the same directory) shall appear as follows:

                                                                                             Figure 9

[9]

In simple tabular form (after a transformation using XSLT file “Tjournal.xsl”), the whole Journal is reproduced here as:

                                                                                                       

Figure 10

But to exhibit the Journal in traditional style and format, the transformation shown in equation (1) of the preceding section used appropriate XSLT file “Fjournal.xsl” (i.e., SJX of preceding section) in the ASP with filename “FormattedJournal.asp” (both the XSLT and ASP files are saved in the virtual directory) — a part of this page for the properly formatted and styled Journal (i.e., J in equation (1) of the preceding section) appears as:

Figure 11

[10]

All XSLT files (with the file-extension characters ‘.xsl’) used for this project are saved in the virtual directory and they are shown with entirety in Appendix B. For correction (i.e., modification or deletion) of previously entered and saved journal entries, a special and user friendly ASP is designed (saved in the same directory with filename “Rectification.asp”) to accommodate all situations and providing very helpful data (i.e., showing at the beginning – dates, voucher numbers and amounts of all entered journal entries), messages, warnings and guides for performing this crucial task. Even voucher number itself can be modified using this page. A part of this page is given here as follows:

Figure 12

After entering the voucher number of the wrong journal entry in the appropriate text box, a click at a different place on this page will show the entire details of the entry to extend full help to the user and direct correction in the newly appeared text boxes is possible as well.

[11]

            Just now, we are in a position to get the derived results, i.e., the accounts or statements

9. For application of the transformations over LX (the file “Ledger.xml” produced by the first part of the ASP “Ledger.asp” – both are saved in the virtual directory; amongst other XSLT files “Ledger.xsl” file is also used to get all ledger accounts or a specific account as per user’s choice and it is saved in the same directory too), to get traditionally formatted and styled (in the last part of “Ledger.asp”) Receipt & Payment A/c, Trial Balance, Profit & Loss A/c and final Balance Sheet, the XSLT files used are with the filenames “ReceiptPayment.xsl”, “TrialBalance.xsl”, “PandL.xsl” and “BalanceSheet.xsl” respectively all of which are saved in the same virtual directory. As a byproduct during the application of the XSLT file “BalanceSheet.xsl” (which contains Microsoft’s proprietory “msxsl:script” tag to enable VBScript programming like other XSLT files barring “Fjournal.xsl” and “TrialBalance.xsl”), the XML-formatted file “BalanceSheet.xml” (BX of the preceding section – saved in the same virtual directory) for closing and final Balance Sheet is additionally available with the help of the template file “financialStatements.balanceSheet.xml” (mentioned earlier and referred as BTX in the preceding section). This “BalanceSheet.xml” file can be effectively used for conception of the (differently) XML-formatted opening Balance Sheet (mentioned as BOX in the immediately preceding section) for the succeeding accounting period. The ASP “Ledger.asp” with the choice of the ledger account “Cash A/c” is shown here:

Figure 13

All instructions are clearly given together with two combo or dropdown boxes to register user’s choices, in this page. All other account(s) or statements are easily available by choosing desired options in the dropdown boxes with updated data; albeit, as a default setting, all ledger accounts will appear initially. From the Accounting Home Page too, effect to a choice can be given through hyperlinks. Other derived accounts and statements are given here sequentially as Figure 14 to Figure 17 respectively:

[12]

Figure 14

Figure 15

Figure 16

[13]

Figure 17

Summary and Conclusion

This paper attempted to devise a process of traditional accounting for an accounting entity using eXtensible Markup Language (XML which is powerful enough to mount up data, to manipulate them for getting meaningful information and to display traditionally styled and formatted information) technology only within a network environment by means of Active Server Pages up to the point of marshaled final balance sheet preparation. For such marshaled balance sheet, a template is used in XML-format where category for a group of accounts is named following the eXtensible Business Reporting Language specification. From this process of accounting, as byproducts XML-formatted Journal, Ledger and opening as well as closing final Balance Sheet are produced as well which can easily be reused for other internal or external purposes. This XML technology alone can similarly be applied for preparation of departmental or sectional accounts, cash and fund flow statements, inventory accounts and even inflation-adjusted accounts etc. too using similar procedures.

[14]

 

End Notes

1. This is required to get rid of the risk of error from and cost of repetitive job of keying input.

2. It is done in desirable style and format using eXtensible Stylesheet Language Transformation or XSLT files.

3. This non-profit seeking organisation was formed with the initiative and auspices of American Institute of Certified Public Accountants with website at http://www.xbrl. rg.

4. A simple text document of such type starts with an XML declaration line (together with an optional processing instruction line) and different levels of parent-child elements in and including start- and end-tags within angle brackets, ‘<’ and ‘>’ (a start-tag for an element may have attributes and an end-tag for an element contains “</” as first two characters), in a tree-like structure. The first element that contains all other elements is called the root or document element and it dominates the entire document. An element that has no child is called a leaf-node and an empty tag (i.e., the element with no end-tag but the only start-tag containing “/>” as last two characters) does not have textual content, though it can have attributes.

5. During actual operation, both the ASP file for preparation of LX etc. and the corresponding XSLT file for exhibiting the traditionally formatted output are so designed that an individual ledger account excepting the Profit & Loss A/c and Inco e & Expenditure A/c, whichever will be relevant, shall be available according to a previously assigned (specific) choice as well.

6. For this present project, “global.asa” file is not necessary at all.

7. That is, first word starts with a lower case letter and no space between words consisting of total 80 or less number of characters.

8. Warning is essential before committing a journal entry when an attempt is made to enter a duplicate voucher number.

9. That is, the transformed output Oi using corresponding XSLT file SXi, mentioned in equation (3) of the immediately preceding section together with the LX file mentioned in equation (2) there as an intermediate product.

[15]

APPENDIX A

Listings of ASP Files (with server and client VBScripts)

1. Active Server Page for Accounting Home Page – “default.asp”

<%@LANGUAGE=VBS%><%Option Explicit: dim bd, ed

bd=Request("t1"): Session("SDate")=bd: if bd="" then Session("SDate")="01 Apr 2004"

ed=Request("t2"): Session("CDate")=ed: if ed="" then Session("CDate")="30 Apr 2004"%>

<HTML><HEAD><TITLE>Starting Page for Accounting (using XML technology alone)</TITLE></HEAD>

<BODY bgcolor="#ffddbb"><P style="font-size: 50px; color: darkblue; text-align: center">Starting Page for Accounting</P>

<FORM method="post" id="f1" name="f1" action="default.asp"><P>Starting Date

<INPUT name="t1" id="t1" style="font-size: 23px; color: white; background-color: #006077" value ="01 Apr 2004">

<INPUT name="t2" id="t2" style="font-size: 23px; color: white; background-color: #007760" value ="30 Apr 2004">

Closing Date</P><CENTER><INPUT type="submit" name="sm" id="sm" style="font-weight: 900; font-size: 20px; color: gold; background-color: brown" value="Click Here to Give Effect"></CENTER></FORM><P>

After setting above Dates, Choose and Click One Menu Item Below: <UL type="I" style="font-size: 20px;

font-family: Lucida Sans">

<LI><A href="NewAccount.asp">For Creation of New Account </A>(Name of Account must be unique)</LI>

<LI><A href="JournalEntry.asp">For Journal Entry </A>(voucher no. must be unique)</LI>

<LI><A href="FormattedJournal.asp">For Formatted Journal </A>(arranged - first date-wise then voucher no.-wise)</LI>

<LI>For Differint Derived Results as -     <UL type="a" style="font-size: 17px; font-family: Arial Alternative">

<LI><A href="Ledger.asp">Ledger Account</A></LI>

<LI><A href="Ledger.asp?s1=rp">Receipt &amp; Payment Account</A></LI>

<LI><A href="Ledger.asp?s1=tb">Trial Balance</A></LI>

<LI><A href="Ledger.asp?s1=pl">Profit &amp; Loss Account</A></LI>

<LI><A href="Ledger.asp?s1=bs">Final Balance Sheet</A></LI></UL></LI>

<LI><A href="Rectification.asp">For Rectification of Journal Entries </A>(which were already recorded)</LI>  

<LI><FONT size="2">For Miscellaneous Tasks, alternatively, for opening Balance Sheet or Journal -  </FONT>

<UL type="i" style="font-size: 15px; font-family: Arial Alternative">

<LI><A href="createXML.asp">To Create, Develop and Save XML File</A><FONT style="font-size: 11"> [Children of document element will be 'Record'(s) and leaf-nodes will be 'Child_No.1', 'Child_No.2' and so on]</FONT></LI>

<LI><A href="NamesXML.asp">To Rename the ChildNodes of the ChildNodes of the   DocumentElement for XML File</A></LI></UL></LI></UL></P></BODY></HTML>

2. Active Server Page to Get “opBalanceSheet.xml” with Any New Account – “NewAccount.asp”

<%@LANGUAGE=VBS%><%Option Explicit: dim xDoc, opBS, ns(), c(), ns1, x, y, n0, n1, fso, s, t, a, b, i, j, k

On Error Resume Next

set xDoc=Server.CreateObject("MSXML2.DomDocument.4.0")

set opBS= Server.CreateObject("MSXML2.DomDocument.4.0")’ MSXML2 DOM document objects

set fso=Server.CreateObject("Scripting.FileSystemObject")

if not fso.FileExists(Server.MapPath("opBalanceSheet.xml")) then

'For properly formatting opening Balance Sheet from that at the end of previous period, both in XML format

opBS.loadXML "<?xml version='1.0'?><?xml-stylesheet type='text/xsl' href='opBS.xsl'?><opBalanceSheet/>"

s="<P style='color: red; font-size: 22'>Neither opBalanceSheet nor BalanceSheet (i.e., closing for previous period) exists - in (required) XML format!"

s=s+"<BR/><FONT color='magenta'><EM>Either</EM> supply last period's closing Balance Sheet in XML format (prepared through this accounting process,"

s=s+" using the template) - by placing the file once in the physical directory for this web site;</BR>"

s=s+"</FONT><FONT color='orange'><EM>Or,</EM> take the help of first sub-menu item of menu VI of AccountingHOME page "

s=s+" (to enter opening balance sheet items with category of accounts, including revenue items with zero op. balances).</FONT></P>"

t=Server.MapPath("BalanceSheet.xml"): if fso.FileExists(t) then

xDoc.load t: reDim ns(2): ns(1)="equitiesAndLiabilities": ns(2)="assets"

for t=1 to 2' When value of t is 1, it indicates liability side items of the Balance Sheet

          set ns1=xDoc.documentElement.selectNodes("//"+"balanceSheet."+ns(t)+"//Item")

          for each x in ns1:     s=x.parentNode.NodeName: i=instr(1, s, "."): k=mid(s, i+1)' For account category

                          set n0=opBS.documentElement.appendChild(xDoc.createElement("Record"))

                          set n1=n0.appendChild(xDoc.createElement("Name_of_Account"))

                          s=x.firstChild.text: if k="cumulativeDeficitOrLoss" then s=mid(s, 18, len(s)-21)

[16]

n1.text=s: set n1=n0.appendChild(xDoc.createElement("Category"))

                          s=k: if k="cumulativeDeficitOrLoss" then s="revenueReserves"

                                          n1.text=s: set n1=n0.appendChild(xDoc.createElement("Opening_Balance"))

                                          s=x.lastChild.text: if t=1 then s="-"+s

n1.text=s: next: next: opBS.save Server.MapPath("opBalanceSheet.xml")' Op. Balance Sheet is saved in XML

fso.DeleteFile Server.MapPath("BalanceSheet.xml")' Closing Balance Sheet of previous period is destroyed

else

Response.Write s+"<P style='font-size: 26; color: green'>You may also use this page, to enter items of OpBalanceSheet <EM>de novo</EM>.</P>"

end if

else' When already opening Balance Sheet exists

opBS.load Server.MapPath("opBalanceSheet.xml")

end if

' The following section is to augment the opening Balance Sheet by opening another new revenue or capital account

set ns1=opBS.documentElement.selectNodes("//Record")

t=ns1.length: reDim ns(t): s=1:  k=1: a=TRim(Request("newAccount"))

b= "<P style='color:violet; font-size: 40'>Duplicate Account Name!<BR/>Enter Unique Name, please.</P>"

if a="" then s=0: Response.Write "<P style='color: blue; font-size: 25'>'Name of New Account' Box is Blank!<BR/>Please, fill in the following Form Elements to Include a New Account.</P>"

for i=1 to t: if a=RTrim(ns1(i-1).firstChild.text) then

s=0: k=0

end if

next: if k=0 then Response.Write b

if s=1 then' For inclusion of a new account, providing details by the user

set x=opBS.documentElement.appendChild(opBS.createElement("Record"))

set y=x.appendChild(opBS.createElement("Name_of_Account")): y.text=a

set y=x.appendChild(opBS.createElement("Category")): y.text=Request("category")

set y=x.appendChild(opBS.createElement("Opening_Balance")): y.text=Request("balance")

opBS.save Server.MapPath("opBalanceSheet.xml")' Opening Balance Sheet is saved in XML format

Response.Write "<P style='color: green; font-size:23'>New Account is  created! You may proceed further, by giving particulars, again.</P>"

else

Response.Write "<P style='color: red; font-size:27'>Particulars are not properly given - so, new Account is not created! Give particulars now, please.</P>"

end if

%><HTML><HEAD><TITLE>For Preparing Opening Balance Sheet and to Include New Account in XML Format</TITLE>

<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript><!--

Sub window_onload

fm.newAccount.focus

End Sub

--></SCRIPT></HEAD><BODY><FORM name="fm" id=fm action="NewAccount.asp" method="post">

<P><INPUT tabindex="1" size="30" name="newAccount" id="newAccount"/>Name of New Account</P>

<SELECT name="category" id="category"><% xDoc.load Server.MapPath("financialStatements.balanceSheet.xml")'

‘ The template file in XML for a standard Balance Sheet is loaded in the DOM document object xDoc

set ns1=xDoc.documentElement.selectNodes("//*[name()!='financialStatements.balanceSheet' and name()!='fictitiousAssets.cumulativeDeficitOrLoss']")

t=ns1.length: reDim ns(t+2)' Array variable is created to hold categories of accounts including revenue matters

for i=1 to t: a=TRim(ns1(i-1).nodeName): j=instr(1, a, "."): ns(i-1)=mid(a, j+1): next

ns(t-2)=ns(t-1)' To avoid duplicate category for 'contraItems'

ns(t-1)="directRevenues": ns(t)="indirectRevenues": ns(t+1)="directExpenditures"

ns(t+2)="indirectExpenditures": t=t+2' To accomodate revenue incomes and expenditures - direct and indirect

for i= 0 to t' To fill the OPTION elements with appropriate values

a=TRim(ns(i)): b=a: If a="cash" Then

                          a="'"+a+"' selected"

          else

                          a="'"+a+"'"

          end If

Response.Write "<OPTION Value="+a+">"+b: Next: set xDoc=nothing: set opBS=nothing: set fso=nothing%>

</SELECT>Select a Category, from this Dropdown box.<BR>

<INPUT type="text" value="0" name="balance" id="balance" size="9" style="color: darkgreen; font-size: 20; font-weight: 900"/> : Enter the Amount of Opening Balance Here (default value is zero, as shown)<BR/> 

<INPUT type="submit" value="Click to Enter the Details of New Account" name="sb" id="sb" style="color: gold; background-color: darkmagenta; font-size: 25; font-weight: 900"/></FORM>

<A style="FONT-SIZE: 20px" href="JournalEntry.asp">Click Here for Journal Entries</A><BR/><A href="">Click Here for Accounting HOME</A></P></BODY></HTML></BODY></HTML>

3. ASP to Create “opBalanceSheet.xml” or Similar XML File for a New User – “CreateXML.asp”

<%@LANGUAGE=VBS%><%Option Explicit: Response.ContentType="text/html": dim sfo, ts, xDoc, ns, fil, st, st1, n, i, j, k, ent()

On Error Resume Next

set sfo=Server.CreateObject("Scripting.FileSystemObject"): set xDoc=Server.CreateObject("MSXML2.DomDocument.4.0")

n=0: k=Request("t2"): if not k="" then

          st1="<?xml version='1.0'?>":    if k="opBalanceSheet" then st1=st1+"<?xml-stylesheet type='text/xsl' href='opBS.xsl'?>"

          st1=st1+"<"+Request("t2")+"/>": fil=Server.MapPath(k+".xml")

if not sfo.FileExists(fil) or Request("t1")="d" or Request("t1")="D" then

                          set ts=sfo.CreateTextFile(fil): ts.WriteLine st1: ts.Close ' Started and saved an XML file de novo

          else ' When the file with given name already exists and it is not required to be destroyed

                          xDoc.load fil: if xDoc.documentElement.hasChildNodes then

                                          set ns=xDoc.documentElement.selectNodes("child::node()[1]/*")

                                          n=ns.length ' n=number of children at the leaf-level, in the document tree structure

                          end if

          end if

          if n=0 then n=Request("t3")

          if sfo.FileExists(fil) and (Request("t1")="d" or Request("t1")="D") then

                          set ts=sfo.CreateTextFile(fil): ts.WriteLine st1: ts.Close: n=Request("t3")

          end if ' Destroyed an existing file with given name and specifically instructed to delete it

          xDoc.load fil: if n>0 and not Request("t4")="" then

                          set ns=xDoc.documentElement.selectNodes("//Record"): k=1: j=1: if TRim(Request("t2"))="Journal" then j=4

                          st1=TRim(Request("t"+CStr(j+3))): for each st in ns: if st1=TRim(st.childNodes(j-1).text) then k=0

                          next: if k=1 then ' On confirmation of uniqueness of the entry, i.e., when value of k remains 1

                                          set st=xDoc.documentElement.appendChild(xDoc.createElement("Record"))

                                          for i=1 to n: set st1=st.appendChild(xDoc.createElement(Request("h"+CStr(i+3))))

                                                          st1.text=Request("t"+Cstr(i+3))

                                          next ' Hence all the leaf-nodes are added to the new child 'Record' of XML document

                                          if ns.length>1 then

                                                          for each j in ns: if j.firstChild.text="" then xDoc.documentElement.removeChild j

                                                          next

                                          end if ' Thus any Child Element with no textual content is removed

                                          xDoc.save fil ' The XML document with an added 'Record' element is hence saved

                          else ' When uniquenes of entry is violated, i.e., text for a leaf-node (required to be unique) is same as an earlier one

                                          Response.Write "<P style='color: red; font-size: 30'>Uniqueness of entry is violated! Enter proper values, please.</P>"

                          end if

                          if not TRim(Request("t2"))="opSheet" and sfo.FileExists(Server.MapPath("opSheet.xml")) then

                                          sfo.DeleteFile Server.MapPath("opSheet.xml") ' When the file name given is other than 'opSheet'

                          end if

          end if

end if

%><HTML><HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"/>

<TITLE>For Creation, Development and Saving of an XML File</TITLE>

<SCRIPT ID="clientEventHandlersVBS" LANGUAGE="vbscript"><!--

Sub window_onload

          f1.s1.focus: f1.t2.select

End Sub

Sub r1_onclick

          f1.s1.focus

End Sub

--></SCRIPT></HEAD><BODY>

<P style="color:#996000; font-size: 40; text-align: center">Page to Create, Develop & Save an XML File<BR/>

<FONT size="3">(for renaming of columns Click the last sub-menu item of menu IV of the AccountingHOME page, please)

</FONT></P><FORM id="f1" name="f1"  method="POST" action="createXML.asp">

<P style="color: #ffbbbb; font-size: 20">If you want to destroy an earlier file with same name, write D or d in this small box:

<INPUT type="text" id="t1" name="t1" size="1" value="C"/></P>

<P style="color:green; font-size: 22">Give the name only of your XML File HERE:

<FONT size="3" color="red">(every time - required): </FONT><INPUT type="text" id="t2" name="t2" value="opSheet"/></P>

<P style="color:blue; font-size: 18">Give the No. of Columns in Your Table HERE

[18]

<FONT size="2" color="red">(required - up to second time only, for new files): </FONT>

<INPUT type="text" id="t3" name="t3" value="0" size="3"/></P><HR color="gold" size="9"/>

<%st1="<P style='color: darkmagenta; font-size: 30'>": if n>0 then

          set st=xDoc.documentElement.selectNodes("//Record[1]/*")

          for i=1 to n

                          k="Child_No."+CStr(i): if not (Request("t1")="d" and Request("t1")="D") then k=st(i-1).nodeName

                          j="": if k="Opening_Balance" or k="Amount" then j="0"

                          st1=st1+"Enter Value for '"+k+"' here: <INPUT type='text' size='30' name='t"+CStr(i+3)+"' id='t"+CStr(i+3)+"' value='"+j+"'/>"

                          st1=st1+"<INPUT type='hidden' name='h"+CStr(i+3)+"' id='h"+CStr(i+3)+"' value='"+k+"'/><BR/>"

          next

end if

st1=st1+"</P>": Response.Write st1: st1="": if xDoc.hasChildNodes then

          st1=st1+"<TABLE border='5' style='border-color: gold'><THEAD bgcolor='lightcyan'>Existing Records</THEAD><TR>"

          set st=xDoc.documentElement.selectNodes("//Record"): for i=1 to n

st1=st1+"<TH>"+st(0).childNodes(i-1).nodeName+"</TH>": next: st1=st1+"</TR>": for each k in st:: st1=st1+"<TR>"

for i=1 to n: st1=st1+"<TD>"+k.childNodes(i-1).text+"</TD>": next: st1=st1+"</TR>": next:: st1=st1+"</TABLE>"

end if

%><HR color="red" size="5"/>

<INPUT type="reset" id="r1" name="r1" value="Click It to Reset All" style="background-color:yellow"/>

<INPUT type="submit" id="s1" name="s1" value="Click It to Give Effect" style="font-size:20; background-color:lightgreen"/>

</FORM><P><A href="">Go to AccountingHOME</A></P><P id="p1"><%=st1%></P></BODY>

<%set sfo=nothing: set ts=nothing: set xDoc=nothing%></HTML>

4. ASP to Rename Leaf-Nodes after Creating XML-File Using “CreateXML.asp” – “NamesXML.asp

<%@LANGUAGE=VBS%><%Option Explicit: dim xDoc, sfo, st, st1, h, i, j, k, n, t()

On Error Resume Next

set xDoc=Server.CreateObject("MSXML2.DomDocument.4.0"): set sfo=Server.CreateObject("Scripting.FileSystemObject")

k=Request("tt"): if not k="" and sfo.FileExists(Server.MapPath(k+".xml")) then

          xDoc.load Server.MapPath(k+".xml"): if xDoc.documentElement.hasChildNodes then

                          set st=xDoc.documentElement.selectNodes("//Record")

st1="<DIV style='color: darkviolet'>": n=st(0).childNodes.length

                          for i= 1 to n: st1=st1+"Enter Changed Name for '"+st(0).childNodes(i-1).nodeName

st1=st1+"' here: <INPUT type='text' size='30' name='tt"+CStr(i)

                                          st1=st1+"' id='tt"+CStr(i)+"' style='color: darkmagenta; font-weight: 900'/><BR/>"

                          next: st1=st1+"</DIV>": if not Request("tt1")="" then

                                          reDim t(n, 2): for i=1 to n: k=Request("tt"+Cstr(i)): for j=1 to len(k): h=Mid(k, j, 1)

                                                          if h=" " then k=Mid(k, 1, j-1)+"_"+Mid(k, j+1)

                                          next: t(i, 1)=k: next: for each st1 in st

                                                          for i=0 to n-1: t(i+1,2)=st1.firstChild.text: st1.removeChild st1.firstChild: next

for i=0 to n-1: set k=st1.appendChild(xDoc.createElement(t(i+1,1))): k.text=t(i+1,2): next

                                          next: xDoc.save Server.MapPath(Request("tt")+".xml"): Response.Redirect "default.asp"

                          end if

          else

                          Response.Write "<P style='font-size: 22; color: violet'>Document Element has no child node!</P>"

          end if

else

          Response.Write "<P style='color: red; font-size: 25'>File does not exist! Please enter another.</P>"

end if

%><HTML><HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"><TITLE>

To Rename Leaf Nodes of an XML Document</TITLE><SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript><!--

Sub window_onload

          fm1.sm1.focus: fm1.tt.select

End Sub

Sub res1_onclick

          fm1.sm1.focus

End Sub

sub tt_onchange

          fm1.submit

end sub

[19]

--></SCRIPT></HEAD><BODY><FORM action="NamesXML.asp" method=POST id=fm1 name=fm1>

<P style="color: darkblue; font-size: 18">Give the Name of the XML File in This Text Box (then Click the Second Button):

<INPUT type="text" id="tt" name="tt" value="opSheet" size="15"><BR/><%=st1%>

<INPUT type="reset" value="May Be Reset" id="res1" name="res1">

<INPUT type="submit" style="background-color: lightgreen; font-weight: 900" value="Give Effect by Clicking It" id="sm1" name="sm1"></FORM></P><P><A href="">Go to AccountingHOME</A></P>

<%set xDoc=nothing: set sfo=nothing%></BODY></HTML>

5. ASP to Record New Journal Entries with Necessary Helps – “JournalEntry.asp”

<%@ LANGUAGE=VBSCRIPT %><%Option Explicit

dim sfo, xJ, xB, xFrag, x, hdv, s, st, fil, st1, st2, h, i, j, k, a, b, y(), n, status

On Error Resume Next

set xJ=Server.CreateObject("MSXML2.DomDocument"): set xB=Server.CreateObject("MSXML2.DomDocument")

set sfo=Server.CreateObject("Scripting.FileSystemObject"): set xFrag=xJ.createDocumentFragment

fil=Server.MapPath("Journal.xml"): if not sfo.FileExists(fil) then' For initial creation of 'Journal' XML file in the same folder

          set st=sfo.CreateTextFile(fil)

st.WriteLine "<?xml version='1.0'?><?xml-stylesheet type='text/xsl' href='TJournal.xsl'?><Journal/>": st.Close

set st=Nothing: Response.Write "<P style='font-size:30; color: gold'>Your XML File is created.</P>"

end if

xJ.load fil: set st=xJ.documentElement.selectNodes("//Voucher_No"): hdv="": j=0: status="OK": for each h in st

          st1=TRim(h.text): hdv=hdv+st1+"`": j=j+1: if st1=TRim(Request("voucherNo")) then status=""

next: n=j' Here n=No. of already recorded journal entries

if Request("amount")>0 and status="OK" then' Only under these conditions new entry can be recorded

          xJ.load fil: set st=xJ.documentElement.selectNodes("//Voucher_No")

          st1=Request("text1")+"~": for k=1 to Request("text2")

                          set s=xJ.documentElement.appendChild(xJ.createElement("Record"))

j=instr(1,st1,"`"): b=mid(st1, 1, j-1): st1=mid(st1, j+1)

                          set h=s.appendChild(xJ.createElement("Date")): h.text=TRim(b)

j=instr(1,st1,"`"): b=mid(st1, 1, j-1): st1=mid(st1, j+1)

                          set h=s.appendChild(xJ.createElement("Debit_Account")): h.text=TRim(b)

                          j=instr(1,st1,"`"): b=mid(st1, 1, j-1): st1=mid(st1, j+1)

                          set h=s.appendChild(xJ.createElement("Credit_Account")): h.text=TRim(b)

                          j=instr(1,st1,"`"): b=mid(st1, 1, j-1): st1=mid(st1, j+1)

                          set h=s.appendChild(xJ.createElement("Voucher_No")): h.text=TRim(b)

                          j=instr(1,st1,"`"): x=TRim(mid(st1, 1, j-1)): st1=mid(st1, j+1)

                          set h=s.appendChild(xJ.createElement("Amount")): h.text=TRim(x)

                          j=instr(1,st1,"`"): b=mid(st1, 1, j-1): st1=mid(st1, j+1)

                          set h=s.appendChild(xJ.createElement("Narration")): h.text=TRim(b)

                          j=instr(1,st1,"`"): b=mid(st1, 1, j-1): st1=mid(st1, j+2)

                          set h=s.appendChild(xJ.createElement("Authority")): h.text=TRim(b)

          next: xJ.save fil: session.Abandon ' Journal file is again saved in the same directory, after update

          a="<A href= 'AccountingHOME.asp'>":    s="You may click here now to go for Accounting HOME</A>"

Response.Write a + s

Else

          a="<P style='color:red'>Not entered, no effective details are given!</P>"

Response.Write a+"<P style='color:gold'>Please try again.</P>"

End If

%><HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=windows-1252">

<TITLE>For Journal Entry</TITLE><script ID="clientEventHandlersVBS" LANGUAGE="vbscript">

Dim s, a, b, d,e, n, r(): s="<TABLE id=t1 width=1000><TR style='font-size:15'><TH width=100><P align=left>"

s=s+"Date</P></TH><TH width=150><P align=left>Debit Account</P></TH><TH width=150>"

s=s+"<P align=left>Credit Account</P></TH><TH width=100><P align=left>Voucher No.</P>"

s=s+"</TH><TH width=100><P align=left>Amount (Rs.)</P></TH><TH width=250><P align=left>"

s=s+"Narration</P></TH><TH width=150><P align=left>Authority</P></TH></TR>"

Sub window_onload

          'Next section is to collect the array of voucher nos. already in 'Journal' table of the database

          e=0: st=trans.hd.Value' Already existing Voucher Nos.

          do until st="": e=e+1:  d=instr(1, st, "`"): b=mid(st, 1, d-1): redim preserve r(e)

                          r(e-1)=b: st=mid(st, d+1)' To collect the next recorded Voucher No

          loop: n=e: redim preserve r(n+50): with trans: .text1.value="": .text2.value=0: .date.select: end with

End Sub

a=0

Sub b1_onclick

          'Following small section is to show an alert when a proposed voucher no. is same as an earlier one

[20]

          d=RTrim(trans.voucherNo.value): if d="" then window.alert "'Voucher No' is Blank! - Enter one, please.": exit sub

          if trans.amount.value="0" then window.alert "'Amount' is ZERO! - Enter Amount, please.": exit sub

          for e=0 to n+a-1

                           if d=r(e) then

                                          window.alert "Voucher No Conflict! *** "+CStr(d)+vbCr+"Please enter appropriate and unique Voucher No. and continue pressing OK"

                                          exit sub

                          end if

          next

          'These Client Codes are to store temporarily the details of journal entries

          e=trans.authority.value: if isnull(e) or e="" then e=" ": b =trans.text1.value+trans.date.value +"`"

          b= b+trans.debitAccount.value+"`"+trans.creditAccount.value+"`"

b= b+d+"`"+trans.amount.value+"`"+trans.narration.value: b= b+"`"+e+"`~": trans.text1.value=b

          s= s+"<TR><TD>"+trans.date.value+"</TD><TD>"+trans.debitAccount.value+"</TD><TD>"

          s= s+trans.creditAccount.value+"</TD><TD>"+d+"</TD><TD>"

          s= s+trans.amount.value+"</TD><TD>"+trans.narration.value+"</TD><TD>"

          s=s+e+"</TD></TR>": d2.innerHTML=s+"</TABLE>": r(n+a)=Trim(d): a= a+1: trans.text2.Value=a

End Sub

Sub c1_AfterUpdate

          d=CStr(FormatDateTime(c1.Value,1)): e=InStr(7,d," ",1):d=Mid(d,e+1)

e=InStr(4,d,","):d=Mid(d,e-2,2)+" "+Mid(d,1,3)+Mid(d,e+1): trans.date.value=d

End Sub

</script></HEAD><BODY ><DIV id="d1"><FORM name="trans" method="post" action="JournalEntry.asp">

  <INPUT type="hidden" id="hd" name="hd" value="<%=hdv%>"/>

 <P style="color:darkgreen; font-size=25">Enter Details of the Transaction as below:</P>

  <P style="color:darkgreen">Date :<INPUT type="text" id="date" name="date" value="<%=Session("SDate")%>" size="25" tabindex="2" style="font-size: 14pt; font-family: 'AGaramond Bold'"></P>

  <P style="color:darkgreen">Debit Account:<SELECT id="debitAccount" name="debitAccount">

<%xB.load Server.MapPath("opBalanceSheet.xml")' To collect Name of Accounts

set st=xB.documentElement.selectNodes("//Name_of_Account")

' For arrangement of Name of Ledger accounts in Alphabetical order, to fill OPTION elements

n=st.length: reDim y(n-1): for i=0 to n-1: y(i)=TRim(st(i).text): next

for i=0 to n-1: for j=i to n-1: if  y(i)>y(j) then k=y(i): y(i)=y(j): y(j)=k: next: next

for i=0 to n-1 'This part of Server Code is for the dropdown box for Debit Account

a=y(i): b=a: If a="Cash" Then

          a="'"+a+"' selected"

Else

          a="'"+a+"'"

End If

Response.Write "<OPTION Value="+a+">"+b

next%> </SELECT></P><P style="color:darkgreen">Credit Account:<SELECT id="creditAccount" name="creditAccount">

<%for i=0 to n-1 'This part of Server Code is for the dropdown box for Credit Account

a=y(i): b=a: If a="Bank" Then

          a="'"+a+"' selected"

Else

          a="'"+a+"'"

End If

Response.Write "<OPTION Value="+a+">"+b

next%></SELECT></P>

<P>Voucher Number: <input type="text" id="voucherNo" name="voucherNo" size="24"></P>

 <P>Amount (Rs.): <input type="text" id="amount" name="amount" value="0" size="11"></P>

 <P>Narration:<textarea rows="3" id="narration" name="narration" cols="67">The amount is withdrawn in cash from bank for office use.</textarea></P>

  <P style="color:darkgreen">Authority Reference (order number etc.): <INPUT type="text" id="authority" name="authority" size="30" tabindex="3" style="font-size: 12pt"></P>

  <INPUT name="b1" type="button" value="Temporarily Store" id="b1"> <INPUT name="b2" type="submit" value="Permanently Commit Journal Entries" id="b2">

  <INPUT type="hidden" id="text1" name="text1" value=""><INPUT type="hidden" id="text2" name="text2" value="0">

</FORM><A href="">Go to AccountingHOME</A></DIV><DIV id="d2"></DIV>

<OBJECT id=c1 style="LEFT: 430px; TOP: 40px;position:absolute" classid="clsid:8E27C92B-1264-101C-8A2F-040224009C02" VIEWASTEXT><PARAM NAME="_Version" VALUE="524288"><PARAM NAME="_ExtentX" VALUE="7620">

          <PARAM NAME="_ExtentY" VALUE="5080"><PARAM NAME="_StockProps" VALUE="1">

<PARAM NAME="BackColor" VALUE="-2147483633"><PARAM NAME="DayLength" VALUE="1">

[21]

          <PARAM NAME="MonthLength" VALUE="2"><PARAM NAME="DayFontColor" VALUE="0">

<PARAM NAME="FirstDay" VALUE="1"><PARAM NAME="GridCellEffect" VALUE="1">

          <PARAM NAME="GridFontColor" VALUE="10485760"><PARAM NAME="GridLinesColor" VALUE="-2147483632">

          <PARAM NAME="ShowDateSelectors" VALUE="-1"><PARAM NAME="ShowDays" VALUE="-1">

          <PARAM NAME="ShowHorizontalGrid" VALUE="-1"><PARAM NAME="ShowTitle" VALUE="-1">

          <PARAM NAME="ShowVerticalGrid" VALUE="-1"><PARAM NAME="TitleFontColor" VALUE="navyblue">

          <PARAM NAME="ValueIsNull" VALUE="0"></OBJECT></BODY></HTML>

6. ASP to Delete or Modify a Recorded Wrong Journal Entry with Helps – “Rectification.asp”

<%@LANGUAGE=VBS%><%Option Explicit:

dim fso, ts, xDoc, xJ, st, z, a, b, d, st1, st2, st3, st4, fil, url, voucher, df, vno(), item(), m(), tc, i, j, k, n

On Error Resume Next

set xDoc=Server.CreateObject("MSXML2.DomDocument.4.0"): set xJ=Server.CreateObject("MSXML2.DomDocument.4.0")

url=Server.MapPath("Journal.xml"): xDoc.Load url' Journal (not properly arranged) in XML format  is loaded

xJ.loadXML "<?xml version='1.0'?><Journal/>": set z = xDoc.documentElement.selectNodes("//Record")

n = z.length: ReDim item(n, 2)' Array variable m() is created to arrange Dates and Voucher Nos.

for i = 0 to n - 1: item(i, 1) = Trim(z(i).firstChild.Text): item(i, 2) = Trim(z(i).childNodes(3).Text): Next

for i = 0 to n - 1: for j = i to n – 1: if CDate(item(i, 1)) > CDate(item(j, 1)) then

                d = item(i, 1): item(i, 1) = item(j, 1): item(j, 1) = d:   d = item(i, 2): item(i, 2) = item(j, 2): item(j, 2) = d

end if' For date wise arrangement

          if CDate(item(i, 1)) =CDate(item(j, 1)) then

                          if Trim(item(i,2))>TRim(item(j,2)) then

                                          d = item(i, 1): item(i, 1) = item(j, 1): item(j, 1) = d:   d = item(i, 2): item(i, 2) = item(j, 2): item(j, 2) = d

                          end if' For voucher no. wise arrangement (when date is same)

          end if

next: next: for i  = 0 to n - 1

set z = xDoc.documentElement.selectNodes("//Record[Date='" + item(i, 1) + "' and Voucher_No='" + item(i, 2) + "']")

          xJ.documentElement.appendChild z(0)

next: xJ.save url' Date and Voucher No. wise arranged journal entries are saved, now.

voucher=TRim(Request("vn")): fil=Server.MapPath("Journal.xml"): set fso=createObject("Scripting.FileSystemObject")

set df=xJ.createDocumentFragment

set st=xJ.documentElement.selectNodes("//Record"): a=st.length: reDim vno(a-1): a=0: st3=""

st2="<TABLE border='5'><THEAD bgcolor='lightcyan'>A Snappy List of Recorded "+CStr(st.length)

st2=st2+" Entries<TR><TH>Date</TH><TH>Voucher No.</TH><TH style='text-align: right'>Amount (Rs.)</TH><TR>"

for each st1 in st: st2=st2+"<TR><TD style='color:blue'>"+TRim(st1.firstChild.text)+"</TD>"

b=TRim(st1.childNodes(3).text): vno(a)=b: a=a+1: st2=st2+"<TD style='color:brown'>"+b+"</TD>"

st2=st2+"<TD style='color:brown; text-align: right'>"+TRim(st1.childNodes(4).text)+"</TD></TR>"

for i=0 to 6: st3=st3+Trim(st1.childNodes(i).text)+"`":next: st3=st3+"~"

next: st2=st2+"</TABLE>"

' For Alphabetical arrangement of Name of Ledger accounts and to store in hdd hidden element as a string

xDoc.load Server.MapPath("opBalanceSheet.xml"): set st=xDoc.documentElement.selectNodes("//Record")

tc=st.length: reDim item(tc-1): for i=0 to tc-1: item(i)=st(i).firstChild.text: next

for i=0 to tc-1: for j=i to tc-1: if  item(i)>item(j) then k=item(i): item(i)=item(j): item(j)=k

next: next: st4="": for i=0 to tc-1: st4=st4+Trim(item(i))+"`": next: reDim item(1)

'This part of Server Code is for the dropdown box for Field Names of Journal table

set st=xJ.documentElement.selectSingleNode("//Record"): tc=0

for each st1 in st.childNodes: a=Trim(st1.nodeName): tc=tc+1: reDim preserve item(tc): item(tc)=a: next:

k=0: st1="<P style='color: darkcyan; font-size: 24'>You may confirm from the following table after a REFRESH."

st1=st1+"You may continue rectification as well.</P>"

if voucher="" then

          Response.Write "<P style='font-size:30; color: darkmagenta'>To rectify ENTER after the following table (voucher no. first).</P>"

elseif mid(Request("c"), 1, 1)="d" or  mid(Request("c"), 1, 1)="D" then

          xJ.load fil: set st=xJ.documentElement.selectNodes("//Record[Voucher_No='"+voucher+"']")

          xJ.documentElement.removeChild st(0)

xJ.save fil ' Journal entry is deleted and residue is saved again (i.e., overwtitten)

          Response.Write "<P style='color: red; font-size: 30'>Your entry is entirely destroyed!</P>": Response.Write st1

else

          xJ.load fil: k=CInt(Request("vnEffected")): if k=1 then

                          for j=0 to 9E9: if voucher=TRim(vno(j)) then exit for

                          next: set st=xJ.documentElement.selectNodes("//Record")

                          set z=xJ.createDocumentFragment(): Set b=z.appendChild(xJ.createElement("Record"))

[22]

                          for i=1 to 7: a=TRim(st(j).childNodes(i-1).nodeName)

                                          set ts=b.appendChild(xJ.createElement(a)): ts.text=TRim(Request("w"+CStr(i)))

                          next: with xJ.documentElement: .removeChild st(j): .appendChild z: end with

                          xJ.save fil ' Journal entry is modified and changed XML file is hence saved (i.e., overwritten)                               

                          Response.Write "<P style='color: green'>Journal is properly rectified! You may Click at the end now for the Accounting HOME Page.</P>"

                          Response.Write st1

          else ' When no changed data is provided

                          Response.Write "<P style='color: red; font-size:30'>No effective detail is given!<BR/><FONT color='darkblue'> Supply something as per instruction below, please.</FONT></P>"                

          end if

end if

%><HTML><HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"><TITLE>Rectification</TITLE>

<SCRIPT ID="clientEventHandlersVBS" LANGUAGE="vbscript"><!--

dim s, st, st1, t, x, h, i, j, k, ss(),  index

Sub window_onload

          f1.c.value="MOD": redim ss(7, 2): ss(1, 1)="Date": ss(2, 1)="Debit Account": ss(3, 1)="Credit Account"

          ss(4, 1)="Voucher No": ss(5, 1)="Amount (Rs.)": ss(6, 1)="Narration": ss(7, 1)="Authority"

f1.vnEffected.value="0": f1.vn.focus

End Sub

Sub vn_onchange

          ' This event-driven sub-routine is for showing the record with given Voucher No

          st1="<TABLE width='100%' border='5'><THEAD bgcolor='lightyellow'>Details of the Entry<TBODY>"

          st=f1.hd.value: index=0: do until st=""

                          for k=1 to 7: j=instr(1,st,"`"): t=mid(st, 1, j - 1): ss(k, 2)=Trim(t): st=mid(st, j+1): next

                          if ss(4, 2)=Trim(f1.vn.value) then index=1: exit do

                          st=mid(st,2)

          loop: if index=0 then

                          for k=1 to 7: ss(k, 2)="": next

          end if

          for k=1 to 7: st1=st1+"<TR><TH style='color: gold' width='160'>"+CStr(ss(k, 1))+"</TH><TD>"

                          if k<2 or k>3 then

                                          st1=st1+"<INPUT type='text' style='font-size: 20; color: darkblue' size='90' name='w"+CStr(k)+"' id='w"+CStr(k)+"' value='"+ss(k, 2)+"'/>"

                          else

                               st1=st1+"<SELECT name='w"+CStr(k)+"' id='w"+CStr(k)+"' style='color: darkmagenta; font-size: 25'>"

                               st=f1.hdd.Value: x=TRim(f1.vn.value): do until st="": h=instr(1,st, "`"): s=Trim(mid(st, 1, h-1)): t=s

                                                          if s=ss(k, 2) then

                                                                          s="'"+s+"' selected"

                                                          else

                                                                          s="'"+s+"'"

                                                          end if

                                                          st1=st1+"<OPTION Value="+s+">"+t+"</OPTION>": st=mid(st, h+1)

                               loop: st1=st1+"</SELECT>"

                          end if

                          st1=st1+"</TD></TR>"

          next: st1=st1+"</TBODY></TABLE>": if index=1 then

                          f1.vnEffected.value="1"

                          st1=st1+"<FONT color='darkcyan'> Then correct the wrong values of the attributes shown above.</FONT>"

          else

                          f1.vnEffected.value="0"

st1="<FONT color='red' size='6'>There's no entry in the file, 'Journal', with this Voucher No.!</FONT>"

                          st1=st1+"<BR/><FONT size='5' color='#CC8800'>You may try again, also now.</FONT>"

          end if

          p1.innerHTML=st1

End Sub

--></SCRIPT></HEAD><BODY id="bod"><%Response.Write st2

Response.Write "Fill the following TEXT BOX with the <EM style='font-size: 23; color: darkcyan; font-weight: 900'>voucher no.</EM> (entered for the wrong journal entry) - you may copy (or drag and drop) from the above list too: "%>

<DIV><FORM name="f1" id="f1" method="POST" action="Rectification.asp">

<INPUT name="hd" id="hd" type="hidden" value="<%=st3%>"/>

<INPUT name="hdd" id="hdd" type="hidden" value="<%=st4%>"/>

<INPUT name="vnEffected" id="vnEffected" type="hidden"/>

[23]

Voucher No.:  <INPUT tabindex="1" name="vn" id="vn" type="text" value="" size="34" style="font-size:20; color: brown"/>

<P id="p1"></P>

<P style='color: green'>After entering value(s) for one or more attribute(s), select your choice below and click the button at the end please!</P>

 Write D or d in the BOX at right side, to completely DELETE the ENTRY: <INPUT type="text" name="c" id="c" size="3"/><BR/>

 <INPUT name="sm1" id="sm1" type="submit" value="Click this button to give EFFECT" size="45" style="font-size:20;background-color:brown; color: gold"/> </FORM><A href="">Go to AccountingHOME</A></DIV></BODY></HTML>

7. ASP to Get Traditionally Formatted Journal Using XSLT file “Fjournal.xsl” – “FormattedJournal.asp”

<%@LANGUAGE=VBS%><%option explicit: dim xDoc, xJ, z, n, s, ts, i, j, d, m(), url

On Error Resume Next

set xDoc=createObject("MSXML2.DomDocument.4.0"): set xJ=createObject("MSXML2.DomDocument.4.0")

set s=createObject("Scripting.FileSystemObject"): url=Server.MapPath("Journal.xml")

xDoc.Load url' Journal (not properly arranged) in XML format  is loaded

xJ.loadXML "<?xml version='1.0'?><Journal/>":  set z = xDoc.documentElement.selectNodes("//Record")

n = z.length: ReDim m(n, 2)' Array variable m() is created to arrange Dates and Voucher Nos.

for i = 0 to n - 1: m(i, 1) = Trim(z(i).firstChild.Text): m(i, 2) = Trim(z(i).childNodes(3).Text): Next

for i = 0 to n - 1: for j = i to n – 1: if CDate(m(i, 1)) > CDate(m(j, 1)) then

            d = m(i, 1): m(i, 1) = m(j, 1): m(j, 1) = d: d = m(i, 2): m(i, 2) = m(j, 2): m(j, 2) = d

        end if' For date wise arrangement

        if CDate(m(i, 1)) =CDate(m(j, 1)) then

                                          if Trim(m(i,2))>TRim(m(j,2)) then

                                                          d = m(i, 1): m(i, 1) = m(j, 1): m(j, 1) = d: d = m(i, 2): m(i, 2) = m(j, 2): m(j, 2) = d

                                          end if' For voucher no. wise arrangement (when date is same)

        end if

    next: next: for i  = 0 to n – 1

          set z = xDoc.documentElement.selectNodes("//Record[Date='" + m(i, 1) + "' and Voucher_No='" + m(i, 2) + "']")

        xJ.documentElement.appendChild z(0)

    next: xJ.save url' Date and Voucher No. wise arranged journal entries are saved, now.

xDoc.load Server.MapPath("FJournal.xsl")' XSLT file is loaded for exhibiting formatted Journal

%><HTML><HEAD><TITLE>To Show Formatted Journal</TITLE></HEAD><BODY>

<DIV><%=xJ.transformNode(xDoc)%></DIV></BODY><%set xDoc=nothing: set xJ=nothing: set z = nothing%></HTML>

8. ASP to Get Ledger Accounts and Optionally Other Derived Results Using XSLT – “Ledger.asp”

<%@LANGUAGE=VBS%><%dim xDoc, Jx, Lx, n, u, v, d, m(), url, st, i, k, opt, act, a, e, f, g, h, td(), tc(), fd, ld' Variables

On Error Resume Next

'Following two are XML DOM Document objects to hold files in XML format

set xDoc=Server.createObject("MSXML2.DomDocument.4.0"): set Jx=Server.createObject("MSXML2.DomDocument.4.0")

set Lx=Server.createObject("MSXML2.DomDocument.4.0"):

'Following section of server code is to arrange journal entries, date & voucher no. wise

url=Server.MapPath("Journal.xml"):  Jx.Load url' Journal is loaded in Jx XML DOM object

 Lx.loadXML "<?xml version='1.0'?><Journal/>" 'Lx is kept reserved to collect Ledger accounts in XML format

Set d = Jx.documentElement.selectNodes("//Record"): n = d.length: ReDim m(n, 2)' For collection of dates and voucher nos.

    for i = 0 to n - 1: m(i, 1) = Trim(d(i).firstChild.Text): m(i, 2) = Trim(d(i).childNodes(3).Text): Next

    for i = 0 to n - 1: for k= i to n – 1: if CDate(m(i, 1)) > CDate(m(k, 1)) then' For date wise arrangement

            st = m(i, 1): m(i, 1) = m(k, 1): m(k, 1) = st: st = m(i, 2): m(i, 2) = m(k, 2): m(k, 2) = st

        end If

        if CDate(m(i, 1)) =CDate(m(k, 1)) then

                                          if Trim(m(i,2))>TRim(m(k,2)) then' For voucher no. wise arrangement, when same date

                                                          st = m(i, 1): m(i, 1) = m(k, 1): m(k, 1) = st: st = m(i, 2): m(i, 2) = m(k, 2): m(k, 2) = st

                                          end if

        End If

    next: next' Now the array m() is arranged date wise (and then voucher no. wise)

    for i = 0 To n - 1: set d = Jx.documentElement.selectNodes("//Record[Date='" + m(i, 1) + "' and Voucher_No='" + m(i, 2) + "']")

        Lx.documentElement.appendChild d(0)' L is the DOM Document object to store arranged Journal in XML format

    Next: Lx.save url' Hence date (and then voucher no.) wise arranged journal entries are saved

'Rest of this page is to prepare all ledger accounts and show the XSL-transformed results

opt="Ledger": If not Request("s1")="" then

          select case Request("s1")' For choosing an option (A/c or Statement)

                          case "rp" opt="ReceiptPayment": case "tb" opt="TrialBalance": case "pl" opt="PandL"

[24]

                          case "bs" opt="BalanceSheet": case "led" opt="Ledger"

          end select

end if

opt=opt+".xsl": act=Request("ss")' opt is XSLT file name and act is the name of desired a/c

Lx.save Jx' Arranged Journal is saved (i.e., transferred) in J, now

Lx.loadXML "<?xml version='1.0'?><Ledger/>"' for Ledger (all accounts) in XML-format

'Following MSXML2 ActiveX object xDoc for DomDocument is also declared in Global.asa

xDoc.load Server.MapPath("opBalanceSheet.xml")' xDoc is for opening Balance Sheet in XML format

'Following two are MSXML2 documentFragment objects for various intermediate processing of Ledger

set u=Lx.createDocumentFragment: set v=Lx.createDocumentFragment

fd=Session("SDate"): ld=Session("CDate")' Opening and closing dates respectively

'This section is to test whether beginning date and ending date are beyond the acceptable range

set d=Jx.documentElement.selectNodes("//Date"): for each e in d: if CDate(fd)>CDate(e.text) then fd=e.text

          if CDate(ld)<CDate(e.text) then ld=e.text

next ' The next section is to find the list of accounts (to be created)

set d=Jx.documentElement.selectNodes("//Debit_Account | //Credit_Account")

for each e In d' here d is nodeList collection type of object

          set f=u.appendChild(Lx.createElement("Account")): u.lastchild.appendChild e' u is for intermediate processing

          u.lastChild.appendChild Lx.createElement("None")

next' Thus debit and credit accounts, in the Journal, are ascertained with overlaps

set d=xDoc.documentElement.selectNodes("Record")

for each e In d' here d is for nodeList of accounts in Balance Sheet

  with v: set f=.appendChild(Lx.createElement("Account"))

          if CSng(e.lastChild.Text)<0 then

                          st="Credit_Account"' for Liabilities

          else

                          st="Debit_Account"' for Assets

          end if

          .lastChild.appendChild Lx.createElement(st): lastChild.lastChild.text=e.firstChild.text

.lastChild.appendChild Lx.createElement("Category"): lastChild.lastChild.text=e.childNodes(1).text

          .lastChild.appendChild Lx.createElement("Balance")

.lastChild.lastChild.text=round(CSng(e.lastChild.text),2)' for opening balances

  end with

next' Thus all debit and credit balances in Balance Sheet got (in XML formattted v)

' The next section is to remove from the list of accounts in v the accounts

'with zero opening balance but not participating in any journal entry

set d=v.selectNodes("Account[Balance=0]")

for each f in d: st=false: set g=u.selectNodes("Account"): for each e in g

                          k=f.firstChild.text: if k=e.firstChild.text or k="Trading" then st=true

                          if k="Profit and Loss" or k="Income and Expenditure" then st=true

next: if not st then v.removeChild f

next: set d=v.selectNodes("Account"): for each f in d

          set e=u.appendChild(Lx.createElement("Account"))

e.appendChild f.firstChild: e.appendChild f.firstChild' It's the Category!

next' List of all ledger accounts is simplied and kept in u in XML format, with overlaps

set v=nothing: set v=Jx.createDocumentFragment' v is to be reused for intermediate processing of Ledger

'In the next section the final list of ledger accounts is kept in v, in XML format, removing overlaps

do until u.xml="": st=u.firstChild.firstChild.text: v.appendChild Lx.createElement("Account")

          set f=Lx.createAttribute("Name"):f.nodeValue=st: v.lastChild.attributes.setNamedItem f' Account's Name

          set d=u.selectNodes("Account[Debit_Account='"+st+"'] | Account[Credit_Account='"+st+"']")

          st="": for each e in d: if e.lastChild.nodeName="Category" then st=e.lastChild.text' To incorporate category

                          u.removeChild e

          next: set f=Lx.createAttribute("Category"): f.nodeValue=st: v.lastChild.attributes.setNamedItem f' Category

loop' Thus all overlaps are eliminated and the list of all accounts is kept in v

set d=v.selectNodes("Account"): st=d.length' st=No. of accounts, now.

for i=0 to st-1: v.childNodes(i).appendChild Lx.createElement("Debit")

v.childNodes(i).appendChild Lx.createElement("Credit")

next' Thus two child elements of each Account element are created

redim td(st-1): redim tc(st-1): for i=0 to st-1:td(i)=0.0: tc(i)=0.0:next' For totals of Debits & Credits

set d=xDoc.documentElement.selectNodes("Record[Opening_Balance!=0]")

for each e in d' d is the nodeList of accounts with non-zero opening balances in Balance Sheet

          for i=0 to st-1: set f=v.Childnodes(i)' For each account kept in v

                          if f.attributes.item(0).nodeValue=e.firstChild.text and CSng(e.lastChild.text)>0 then

[25]

                                          ' For all accounts (in v) having opening debit balances

                                          td(i)=round(CSng(e.lastChild.text),2): f.firstChild.appendChild Lx.createElement("Posting")

                                          set g=f.firstChild.lastChild.appendChild(Lx.createElement("Date"))

                                          g.text=fd: set g=f.firstChild.lastChild.appendChild(Lx.createElement("Particulars"))

                                          g.text="To Balance b/d": set g=f.firstChild.lastChild.appendChild(Lx.createElement("Amount"))

                                          g.text=round(CSng(e.lastChild.text),2)

                          elseIf f.attributes.item(0).nodeValue=e.firstChild.Text and CSng(e.lastChild.text)<0 then

                                          ' For all accounts (in v) having opening credit balances

                                          tc(i)=round(Abs(CSng(e.lastChild.text)),2): f.lastChild.appendChild Lx.createElement("Posting")

                                          set g=f.lastChild.lastChild.appendChild(Lx.createElement("Date"))

                                          g.text=fd: set g=f.lastChild.lastChild.appendChild(Lx.createElement("Particulars"))

                                          g.text="By Balance b/d": set g=f.lastChild.lastChild.appendChild(Lx.createElement("Amount"))

                                          g.text=round(Abs(CSng(e.lastChild.text)),2)

                          End If

Next: next' thus all opening balances of concerned ledger accounts are incorporated in v

Jx.load url' Journal is reloaded in XML-format, as earlier

set d=v.selectNodes("Account"): i=0' For Posting of every transaction as follows

for each e in d: st=e.attributes.item(0).nodeValue

set a=Jx.documentElement.selectNodes("Record[Debit_Account='"+st+"']")

          for each f in a' for debits of all transactions for the concerned account

                          set g=v.childNodes(i).firstChild.appendChild(Lx.createElement("Posting"))

                          set h=g.appendChild(Lx.createElement("Date")):   h.text=f.childNodes(0).text

                          set h=g.appendChild(Lx.createElement("Particulars")): h.text="To "+f.childNodes(2).text+" A/c"

                          set h=g.appendChild(Lx.createElement("Amount"))

k=f.childNodes(4).Text: h.text=round(CSng(k),2): td(i)=td(i)+round(CSng(k),2)

          next' thus all debit entries of each ledger account are posted

          set a=Jx.documentElement.selectNodes("Record[Credit_Account='"+st+"']")

          for each f in a' for credits of all transactions for the concerned account

                          set g=v.childNodes(i).lastChild.appendChild(Lx.createElement("Posting"))

                          set h=g.appendChild(Lx.createElement("Date")): h.text=f.childNodes(0).text

                          set h=g.appendChild(Lx.createElement("Particulars")): h.text="By "+f.childNodes(1).text+" A/c"

                          set h=g.appendChild(Lx.createElement("Amount")): k=f.childNodes(4).Text

h.text=round(CSng(k),2): tc(i)=tc(i)+round(CSng(k),2): next' thus all credit entries of each ledger account are posted

          if td(i)<tc(i) Then' last entry for a closing credit balance

                          set g=v.childNodes(i).firstChild.appendChild(Lx.createElement("Posting"))

                          set h=g.appendChild(Lx.createElement("Date")): h.text=ld

                          set h=g.appendChild(Lx.createElement("Particulars")): h.text="To Balance c/d"

                          set h=g.appendChild(Lx.createElement("Amount")): h.text=round(tc(i)-td(i),2)

          end if

          if td(i)>tc(i) Then' last entry for a closing debit balance

                          set g=v.childNodes(i).lastChild.appendChild(Lx.createElement("Posting"))

                          set h=g.appendChild(Lx.createElement("Date")):   h.text=ld

                          set h=g.appendChild(Jx.createElement("Particulars")): h.text="By Balance c/d"

                          set h=g.appendChild(Lx.createElement("Amount")): h.text=round(td(i)-tc(i),2)

          end if

i=i+1: next: set e=v.appendChild(Lx.createElement("SelectedAccount")): if act="" then act="AllAccounts"

e.text=act: st="The following nodes are for setting the phycal directory for the server location and about the researcher."

set e=v.appendChild(Lx.createCDATASection(st)): st=Server.MapPath("A.xml"): st=mid(st, 1, len(st) - 5)

set e=v.appendChild(Lx.createElement("VirtualDirectory")): e.text=st: set e=v.appendChild(Lx.createElement("Designer"))

set f=Lx.createAttribute("Designation"): f.nodeValue="Reader in Commerce": e.attributes.setNamedItem f

set f=Lx.createAttribute("Date"): f.nodeValue="14 April 2004": e.attributes.setNamedItem f

e.text="Dr. Subodh Chandra Garai": Lx.documentElement.appendChild v' in XML-format, Ledger is finalised in Lx

Lx.save st+"Ledger.xml" 'Ledger accounts is saved, in XML format

' For Alphabetical arrangement of Name of Ledger accounts, to fill initial OPTION elements

set v=Lx.documentElement.selectNodes("//@Name[.!='Trading' and .!='Profit and Loss' and .!='Income and Expenditure']"): ld="": fd=v.length: reDim td(fd-1): for i=0 to fd-1: td(i)=v(i).text: next

for i=0 to fd-1: for k=i to fd-1: if  td(i)>td(k) then h=td(i): td(i)=td(k): td(k)=h

next: next: for i= 0 to fd-1: ld=ld+"<OPTION value='"+td(i)+"'>"+td(i)+"</OPTION>": next

ld=ld+"<OPTION value='AllAccounts' selected>All Ledger Accounts</OPTION>"

xDoc.load st+opt ' Now, eXtensible Stylesheet Language transform for Desired Object is loaded in xDoc

st=Lx.transformNode(xDoc)' direct from the Ledger (in XML format) to Desired Object, using XSLT-file

Response.Write st' the Desired Object (in one of traditional formats) is displayed at the end

set L=nothing: set v=nothing: set J=nothing: set u=nothing: set a=nothing: set d=nothing: set e=nothing: set f=nothing

[26]

set g=nothing' All objects created in this page are ultimately destroyed now.

%><HTML><HEAD><TITLE>For Preparation and Formatting of Different Financial Statements</TITLE>

</HEAD><BODY><P><FORM name="f1" id="f1" action="Ledger.asp">

<P style="color: blue; font-size: 17; font-weight: 900">Please Select an Account from This Drop-Down Box:

<SELECT name="ss" id="ss" onchange="f1.submit()"><%=ld%></SELECT></P>

<P>Or Select a Statement/ Account Here: <SELECT name="s1" id="s1" onchange="f1.submit()">

          <OPTION value="led" selected>Ledger Account(s)</OPTION>

<OPTION value="rp">Receipt & Payment A/c</OPTION><OPTION value="tb">Trial Balance</OPTION>

          <OPTION value="pl">Profit & Loss A/c</OPTION><OPTION value="bs">Balance Sheet</OPTION></SELECT>

<INPUT type="submit" style="background-color:gold" name="sub1" id="sub1" value="Click to Make Effective"/>

</P></FORM><A href="">Go to Accounting HOME Page</A></BODY></HTML>

APPENDIX B

Listings of XSLT Files (with “<msxsl:script>” elements too)

1. XSLT file to Exhibit the Journal in Simple Two-Dimensional Tabular Form – “Tjournal.xsl”

<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Journal"><HTML><HEAD><TITLE>Tabular Journal</TITLE></HEAD><BODY>

<TABLE width="100%"><TR><TH style="text-align:center; color: darkcyan; font-size: 30">Journal</TH></TR></TABLE>

<TABLE border="5" width="100%" style="font-size: 15"><TR style="color:darkred"><xsl:for-each select="//Record[1]/*"><TH>

          <xsl:value-of select="name()"/><xsl:if test="name()='Amount'"> (Rs.)</xsl:if></TH></xsl:for-each></TR>

<xsl:for-each select="//Record"><TR><xsl:for-each select="child::node()"><TD><xsl:value-of select="."/></TD>

</xsl:for-each></TR></xsl:for-each></TABLE></BODY></HTML></xsl:template></xsl:stylesheet>

2. XSLT file to Get Traditionally Formatted Journal from “FormattedJournal.asp” – “Fjournal.xsl”

<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Journal"><HTML><HEAD><TITLE>Conversion from XML to HTML (Table) Document</TITLE>

</HEAD><BODY><DIV style="color:blue;font-size:30; text-align:center;left:0; position:absolute">Journal

<TABLE border="5" width="100%"><TR><TH align="left" style="color:brown">Date</TH>

<TH style="color:brown; border-right-width:0">Particulars</TH>

<TH style="color:green;border-right-width:3;border-left-width:0;border-top-width:3;border-bottom-width:3"/>

<TH align="center" style="color:blue">Voucher No.</TH><TH><B style="color:green; font-size:20; text-align:center">Dr.</B>

<BR>Amount (Rs.)</BR></TH><TH><B style="color:green; font-size:20; text-align:center">Cr.</B><BR>Amount (Rs.)

</BR></TH></TR><xsl:for-each select="Record"><TR><TD valign="TOP"><xsl:value-of select="Date"/></TD>

          <TD valign="TOP" style="margin-top:0; border-right-width:0"><xsl:value-of select="Debit_Account"/> A/c<BR>

          <SPAN style="margin-left:20;margin-bottom:0">To <xsl:value-of select="Credit_Account"/> A/c</SPAN></BR><BR>

          <SPAN style="text-align:justify; font-size:13">(Being <xsl:value-of select="Narration"/>)</SPAN></BR></TD>

          <TD style="text-align:right; border-left-width:0; font-weight:900" valign="TOP">Dr.</TD>

          <TD valign="TOP"><xsl:value-of select="Voucher_No"/></TD>

<TD valign="TOP" style="text-align:right"><xsl:value-of select="Amount"/></TD>

          <TD valign="TOP" style="text-align:right"><BR><xsl:value-of select="Amount"/></BR></TD></TR>

</xsl:for-each></TABLE><P style="page-break-before: always"><A style="font-size:16" href="">

Go to Accounting HOME</A></P></DIV></BODY></HTML></xsl:template></xsl:stylesheet> 

3. XSLT file to Exhibit the Ledger Account(s) in Traditional T-Format – “Ledger.xsl”

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:Subodh="urn:schemas-microsoft-com:xslt" xmlns:Garai="http://mycompany.com/mynamespace">

<xsl:output method="html"/><Subodh:script language="VBScript" implements-prefix="Garai">       dim a

          function reseta()

                          a=-1: reseta=""

          end function

          function adjusta(nodeset)

                          a=a+1:if a>= nodeset.length then

                                          a=nodeset.length-1: adjusta=""

                          else

                                          adjusta="OK"

                          end if

          end function 

[27]

          function singleItem(stat,nodeset,ind)

                          if stat="OK" then

                                          singleItem=nodeset.Item(a).ChildNodes(ind).Text

                          else

                                          singleItem="..."

                          end if

          end function

</Subodh:script>

<xsl:template match="/"><HTML><HEAD><TITLE>Complete Ledger</TITLE></HEAD><BODY>

<P style="font-size:30; color:darkcyan; text-align:center">Ledger Account(s)<BR/>

<FONT size="2" color="fuchsia">(For other choices go to left end and select one)</FONT></P>

<xsl:variable name="spAccount" select="//SelectedAccount"/><xsl:choose>     <xsl:when test="$spAccount='AllAccounts'">

<xsl:for-each select="//Account[@Name!='Trading' and @Name!='Profit and Loss' and @Name!='Income and Expenditure']">

<TABLE width="100%" border="0" style="font-size:30;color:blue"><TR><TD width="6%" style="text-align:left">Dr.</TD>

          <TD width="88%" style="text-align:center"><xsl:value-of select="@Name"/> A/c</TD>

          <TD width="6%" style="text-align:right">Cr.</TD></TR></TABLE>

<TABLE width="100%" border="5" style="color:brown;border-color:gold"><TR style="color:darkgreen">

                          <TH>Date</TH><TH>Debit Particulars</TH><TH align="right">Amount (Rs)</TH>

                          <TH>Date</TH><TH>Credit Particulars</TH><TH align="right">Amount (Rs)</TH>

          </TR><xsl:variable name="d" select="Debit/Posting"></xsl:variable>

<xsl:variable name="c" select="Credit/Posting"></xsl:variable>

          <xsl:variable name="dc" select="count($d)"></xsl:variable>    <xsl:variable name="cc" select="count($c)"></xsl:variable>

          <xsl:if test="$dc&gt;=$cc"><xsl:value-of select="Garai:reseta()"/><xsl:for-each select="$d">

                          <xsl:variable name="status" select="Garai:adjusta($c)"></xsl:variable>

<TR><TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Date"/></TD>

                          <TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Particulars"/></TD>

                          <TD align="right" style="color:darkmagenta;font-size:23"><xsl:value-of select="Amount"/></TD>

                          <TD style="color:darkblue"><xsl:value-of select="Garai:singleItem($status,$c,0)"/></TD>

                          <TD style="color:darkblue"><xsl:value-of select="Garai:singleItem($status,$c,1)"/></TD>

                          <TD align="right" style="color:darkblue"><xsl:value-of select="Garai:singleItem($status,$c,2)"/></TD></TR>

          </xsl:for-each></xsl:if><xsl:if test="$dc&lt;$cc"><xsl:value-of select="Garai:reseta()"/><xsl:for-each select="$c">

                          <xsl:variable name="status" select="Garai:adjusta($d)"></xsl:variable><TR>

                          <TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Garai:singleItem($status,$d,0)"/></TD>

                          <TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Garai:singleItem($status,$d,1)"/></TD>

                          <TD align="right" style="color:darkmagenta;font-size:23">

<xsl:value-of select="Garai:singleItem($status,$d,2)"/></TD><TD style="color:darkblue">

<xsl:value-of select="Date"/></TD><TD style="color:darkblue"><xsl:value-of select="Particulars"/></TD>

                <TD align="right" style="color:darkblue"><xsl:value-of select="Amount"/></TD>    </TR></xsl:for-each>

          </xsl:if><TR><TD>&#32;</TD><TD>&#32;</TD>   <TD align="right" style="color:green"><U><B>

<xsl:value-of select="sum(Debit/Posting/Amount)"/></B></U></TD><TD>&#32;</TD><TD>&#32;</TD>

          <TD align="right" style="color:green"><U><B>

<xsl:value-of select="sum(Credit/Posting/Amount)"/></B></U></TD></TR></TABLE></xsl:for-each>             </xsl:when>

<xsl:otherwise> <xsl:for-each select="//Account[@Name=string($spAccount)]">

          <TABLE width="100%" border="0" style="font-size:30;color:blue"><TR><TD width="6%" style="text-align:left">

Dr.</TD> <TD width="88%" style="text-align:center"><xsl:value-of select="@Name"/> A/c</TD>

          <TD width="6%" style="text-align:right">Cr.</TD></TR></TABLE>

<TABLE width="100%" border="5" style="color:brown;border-color:gold"><TR style="color:darkgreen">

                          <TH>Date</TH><TH>Debit Particulars</TH><TH align="right">Amount (Rs)</TH>

                          <TH>Date</TH><TH>Credit Particulars</TH><TH align="right">Amount (Rs)</TH></TR>

                          <xsl:variable name="d" select="Debit/Posting"></xsl:variable>

<xsl:variable name="c" select="Credit/Posting"></xsl:variable>

                          <xsl:variable name="dc" select="count($d)"></xsl:variable>

                          <xsl:variable name="cc" select="count($c)"></xsl:variable>

                          <xsl:if test="$dc&gt;=$cc"><xsl:value-of select="Garai:reseta()"/><xsl:for-each select="$d">

                                          <xsl:variable name="status" select="Garai:adjusta($c)"></xsl:variable><TR>

                                          <TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Date"/></TD>

                                          <TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Particulars"/></TD>

                                          <TD align="right" style="color:darkmagenta;font-size:23"><xsl:value-of select="Amount"/></TD>

                                          <TD style="color:darkblue"><xsl:value-of select="Garai:singleItem($status,$c,0)"/></TD>

                                          <TD style="color:darkblue"><xsl:value-of select="Garai:singleItem($status,$c,1)"/></TD>

                                          <TD align="right" style="color:darkblue">

<xsl:value-of select="Garai:singleItem($status,$c,2)"/></TD></TR></xsl:for-each></xsl:if>

<xsl:if test="$dc&lt;$cc"><xsl:value-of select="Garai:reseta()"/><xsl:for-each select="$c">

[28]

                                          <xsl:variable name="status" select="Garai:adjusta($d)"></xsl:variable><TR>

<TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Garai:singleItem($status,$d,0)"/></TD>

<TD style="color:darkmagenta;font-size:23"><xsl:value-of select="Garai:singleItem($status,$d,1)"/></TD>

                                          <TD align="right" style="color:darkmagenta;font-size:23">

<xsl:value-of select="Garai:singleItem($status,$d,2)"/></TD>

                                          <TD style="color:darkblue"><xsl:value-of select="Date"/></TD>

                                          <TD style="color:darkblue"><xsl:value-of select="Particulars"/></TD>

                                          <TD align="right" style="color:darkblue"><xsl:value-of select="Amount"/></TD>    </TR>

                          </xsl:for-each></xsl:if><TR><TD>&#32;</TD><TD>&#32;</TD>

                          <TD align="right" style="color:green"><U><B><xsl:value-of select="sum(Debit/Posting/Amount)"/>

</B></U></TD><TD>&#32;</TD><TD>&#32;</TD><TD align="right" style="color:green"><U><B>

<xsl:value-of select="sum(Credit/Posting/Amount)"/></B></U></TD></TR></TABLE></xsl:for-each>

</xsl:otherwise></xsl:choose><P style="page-break-before: always"></P>      </BODY></HTML></xsl:template></xsl:stylesheet>

4. XSLT file to Exhibit Traditionally Formatted Receipt & Payment A/c – “ReceiptPayment.xsl”

 <?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:Subodh="urn:schemas-microsoft-com:xslt" xmlns:Garai="http://mycompany.com/mynamespace">

<Subodh:script language="VBScript" implements-prefix="Garai">

dim countCr, countDr, counterCr, counterDr: counterCr=0: counterDr=0

function countCrDr(x, y, cRdR)

          dim r, u, v, w, s, t,  st, total, tItem, n, i, ss: set w=CreateObject("MSXML2.DomDocument.4.0")

          ss="Credits":if cRdR="d" then ss="Debits": w.loadXML "&lt;?xml version='1.0'?&gt;&lt;"+ss+"/&gt;":      tItem=0: n=0

          for each u in x: n=n + 1: s=u.parentNode.childNodes(1).text: s=Right(s, Len(s)-3): s=Left(s, Len(s)-4): st=true

                          for i=0 to n-2: t=x(i).parentNode.childNodes(1).text: t=Right(t, Len(t)-3): t=Left(t, Len(t)-4): if t=s then st=false

                          next: set v=u.parentNode.parentNode.parentNode.parentNode.selectNodes("Account[@Name='"+s+"']")

                          t=v(0).attributes.item(1).value: if t="currentBanks" or t="cash" then st=false

                          if st then

                                          tItem=tItem + 1: w.documentElement.appendChild w.createElement("Entry")

                                          set r=w.documentElement.lastChild.appendChild(w.createElement("Item"))

                                          r.text=s: total=0: for each v in x

t=v.parentNode.childNodes(1).text: t=Right(t, Len(t)-3): t=Left(t, Len(t)-4)

                                                          if t=s then

                                                                          total=total + CSng(v.text)

                                                          end if

                                          next: set r=w.documentElement.lastChild.appendChild(w.createElement("Amount"))

r.text=CStr(total)

                          end if

          next: if cRdR="c" then

                          countCr= tItem

          else

                          countDr= tItem

          end if

          set countCrDr=w.documentElement.selectNodes("Entry")

end function

function createIndicator(y)

          dim temp,  i, c, d: c=countCr: d=countDr: if y&gt;0 then d=d – 1: if y&lt;=0 then c=c - 1

          if c&lt;d then c=d

          set temp=CreateObject("MSXML2.DomDocument.4.0"): temp.loadXML "&lt;?xml version='1.0'?&gt;&lt;ROOT/&gt;"

          for i=1 to c: temp.documentElement.appendChild temp.createElement("x"):next

set createIndicator=temp.documentElement.selectNodes("x")

end function

function creditTesting(x, y)

          creditTesting=false: if y&gt;0 and countDr&gt;countCr+1 and x&gt;=0 and counterCr=countCr then creditTesting=true

          if y&lt;=0 and countDr&gt;=countCr and x&gt;=0 and counterCr=countCr then creditTesting=true

end function

function debitTesting(x, y)

          debitTesting=false: if y&gt;=0 and countCr&gt;countDr+1 and x&gt;0 and counterDr=countDr then debitTesting=true

          if y&lt;=0 and countCr&gt;=countDr and x&gt;0 and counterDr=countDr then debitTesting=true

end function

function testing(x)

          dim c, d: testing=false: c=countCr - CounterCr: d=countDr – counterDr: if x="c" and c&gt;=d then  testing=true

          if x="d" and c&lt;d then  testing=true

[29]

end function

function creditEntry(nodeList, op, indexT)

          if indexT=1 then counterCr=counterCr+1

          if counterCr&lt;=countCr then

                          if indexT=1 then

                                          creditEntry="By  "+nodeList(counterCr - 1).firstChild.text+" A/c"

                          else

                                          creditEntry=nodeList(counterCr - 1).lastChild.text

                          end if

          else

                          creditEntry="..."

          end if

end function

function debitEntry(nodeList, op, indexT)

          if indexT=1 then counterDr=counterDr+1

          if counterDr&lt;=countDr then

                          if indexT=1 then

                                          debitEntry="To "+nodeList(counterDr-1).firstChild.text+" A/c"

                          else

                                          debitEntry=nodeList(counterDr - 1).lastChild.text

                          end if

          else

                          debitEntry="..."

          end if

end function

function outsideBalancing(x, y, z)

          outsideBalancing=false

          if z="c" then

                          if x&gt;=0 then

                                          if y&gt;0 and countCr&gt;=countDr - 1 then outsideBalancing=true

                                          if y&lt;0 and countDr&lt;=countCr - 1 then outsideBalancing=true

                          end if

          else

                          if x&gt;0 then

                                          if y&gt;=0 and countDr&gt;=countCr - 1 then outsideBalancing=true

                                          if y&lt;0 and countCr&lt;=countDr - 1 then outsideBalancing=true

                          end if

          end if

end function

</Subodh:script><xsl:template match="/">

<xsl:variable name="opCr" select="//Account[@Category='currentBanks' or @Category='cash']/Credit//Amount[parent::node()/Particulars='By Balance b/d']"></xsl:variable>

<xsl:variable name="opDr" select="//Account[@Category='currentBanks' or @Category='cash']/Debit//Amount[parent::node()/Particulars='To Balance b/d']"></xsl:variable>

<xsl:variable name="credits" select="//Account[@Category='currentBanks' or @Category='cash']/Credit//Amount[parent::node()/Particulars!='By Balance b/d' and parent::node()/Particulars!='By Balance c/d']"></xsl:variable>

<xsl:variable name="debits" select="//Account[@Category='currentBanks' or @Category='cash']/Debit//Amount[parent::node()/Particulars!='To Balance b/d' and parent::node()/Particulars!='To Balance c/d']"></xsl:variable>

<xsl:variable name="clCr" select="//Account[@Category='currentBanks' or @Category='cash']//Amount[parent::node()/Particulars='By Balance c/d']"></xsl:variable>

<xsl:variable name="clDr" select="//Account[@Category='currentBanks' or @Category='cash']//Amount[parent::node()/Particulars='To Balance c/d']"></xsl:variable>

<xsl:variable name="entriesCr" select="Garai:countCrDr($credits, sum($clCr) - sum($clDr), 'c')"/>

<xsl:variable name="entriesDr" select="Garai:countCrDr($debits, sum($clDr) - sum($clCr), 'd')"/>

<xsl:variable name="tCr"><xsl:choose>

<xsl:when test="sum($opCr)&gt;=sum($opDr) and sum($clCr)&gt;=sum($clDr)">

<xsl:value-of select="sum($entriesCr/Amount) + sum($opCr) - sum($opDr)+sum($clCr) - sum($clDr)"/></xsl:when>

<xsl:when test="sum($opCr)&gt;=sum($opDr) and sum($clCr)&lt;=sum($clDr)">

<xsl:value-of select="sum($entriesCr/Amount) + sum($opCr) - sum($opDr)"/></xsl:when>

<xsl:when test="sum($opCr)&lt;=sum($opDr) and sum($clCr)&gt;=sum($clDr)">

<xsl:value-of select="sum($entriesCr/Amount) + sum($clCr) - sum($clDr)"/></xsl:when>

[30]

<xsl:otherwise><xsl:value-of select="sum($entriesCr/Amount)"/></xsl:otherwise></xsl:choose></xsl:variable>

<xsl:variable name="tDr"><xsl:choose>

<xsl:when test="sum($opDr)&gt;=sum($opCr) and sum($clDr)&gt;=sum($clCr)">

<xsl:value-of select="sum($entriesDr/Amount) + sum($opDr) - sum($opCr)+sum($clDr) - sum($clCr)"/></xsl:when>

<xsl:when test="sum($opDr)&gt;=sum($opCr) and sum($clDr)&lt;=sum($clCr)">

<xsl:value-of select="sum($entriesDr/Amount) + sum($opDr) - sum($opCr)"/></xsl:when>

<xsl:when test="sum($opDr)&lt;=sum($opCr) and sum($clDr)&gt;=sum($clCr)">

<xsl:value-of select="sum($entriesDr/Amount) + sum($clDr) - sum($clCr)"/></xsl:when>

<xsl:otherwise><xsl:value-of select="sum($entriesDr/Amount)"/></xsl:otherwise></xsl:choose></xsl:variable>

<xsl:variable name="indicator" select="Garai:createIndicator(sum($opCr) - sum($opDr))"/>

<HTML><HEAD><TITLE>Receipt &#38; Payment A/c</TITLE></HEAD><BODY>

<TABLE width="100%" border="0" style="font-size:22"><TR><TH width="6%" align="left">Dr.</TH>

<TH width="38%" align="center">Receipt &#38; Payment A/c <FONT size="1">for the period ended

<xsl:value-of select="$clCr/parent::node()/Date"/></FONT></TH><TH width="6%" align="right">Cr.</TH></TR></TABLE>

<TABLE width="100%" border="7" style="font-size:16; color:darkred"><TR style="color:darkmagenta">

<TH width="30%" align="left">Receipts</TH><TH width="10%" align="right">Amount (Rs.)</TH>

<TH align="right" width="10%">Amount (Rs.)</TH><TH width="30%" align="left">Payments</TH>

<TH width="10%" align="right">Amount (Rs.)</TH><TH align="right" width="10%">Amount (Rs.)</TH></TR>

<xsl:if test="sum($opCr)&gt;sum($opDr)"><TR><TD align="left">

<xsl:value-of select="Garai:debitEntry($entriesDr, sum($opDr) - sum($opCr), 1)"/></TD><TD align="right">...</TD>

<TD align="right"><xsl:value-of select="Garai:debitEntry($entriesDr, sum($opDr) - sum($opCr), 2)"/></TD>

<TD align="left">By Balance b/d <BR/><xsl:for-each select="$opCr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each><xsl:if test="sum($opDr)&gt;0"><BR/>

<xsl:for-each select="$opDr"><xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each></xsl:if>

</TD><TD align="right"><BR/><xsl:for-each select="$opCr">

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="."/><BR/></xsl:when><xsl:otherwise><U>

<xsl:value-of select="."/></U></xsl:otherwise></xsl:choose></xsl:for-each><xsl:if test="sum($opDr)&gt;0"><BR/>

<xsl:value-of select="sum($opCr)"/><xsl:for-each select="$opDr"><BR/><xsl:choose><xsl:when test="position()!=last()">

<xsl:value-of select="concat('-', .)"/></xsl:when><xsl:otherwise><U>

<xsl:value-of select="concat('-', .)"/></U></xsl:otherwise></xsl:choose></xsl:for-each></xsl:if></TD>

<TD align="right" valign="bottom"><xsl:value-of select="round(100*(sum($opCr) - sum($opDr))) div 100"/></TD></TR></xsl:if>

<xsl:if test="sum($opDr)&gt;=sum($opCr)"><TR><TD align="left">To Balance b/d <BR/><xsl:for-each select="$opDr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each><xsl:if test="sum($opCr)&gt;0"><BR/>

<xsl:for-each select="$opCr"><xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each></xsl:if></TD>

<TD align="right"><BR/><xsl:for-each select="$opDr">

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="."/><BR/></xsl:when><xsl:otherwise><U>

<xsl:value-of select="."/></U></xsl:otherwise></xsl:choose></xsl:for-each>

<xsl:if test="sum($opCr)&gt;0"><BR/><xsl:value-of select="sum($opDr)"/><xsl:for-each select="$opCr"><BR/>

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="concat('-', .)"/></xsl:when>

<xsl:otherwise><U><xsl:value-of select="concat('-', .)"/></U></xsl:otherwise></xsl:choose></xsl:for-each></xsl:if></TD>

<TD align="right" valign="bottom"><xsl:value-of select="round(100*(sum($opDr) - sum($opCr))) div 100"/></TD>

<TD align="left"><xsl:value-of select="Garai:creditEntry($entriesCr, sum($opCr) - sum($opDr), 1)"/></TD>

<TD align="right">...</TD><TD align="right">

<xsl:value-of select="Garai:creditEntry($entriesCr, sum($opCr) - sum($opDr), 2)"/></TD></TR></xsl:if>

<xsl:for-each select="$indicator"><TR bordercolorlight="white">

<xsl:if test="Garai:creditTesting(sum($clCr) - sum($clDr), sum($opCr) - sum($opDr))">

<TR><xsl:if test="sum($clCr)&gt;=sum($clDr)">

<TD align="left"><xsl:value-of select="Garai:debitEntry($entriesDr, sum($clDr) - sum($clCr), 1)"/></TD>

<TD align="right">...</TD>

<TD align="right"><xsl:value-of select="Garai:debitEntry($entriesDr, sum($opDr) - sum($opCr), 2)"/></TD>

<TD align="left">By Balance c/d <BR/><xsl:for-each select="$clCr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each>

<xsl:if test="sum($clDr)&gt;0"><BR/><xsl:for-each select="$clDr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/>

<BR/></xsl:for-each></xsl:if></TD><TD align="right"><BR/><xsl:for-each select="$clCr">

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="."/><BR/></xsl:when>

<xsl:otherwise><U><xsl:value-of select="."/></U></xsl:otherwise></xsl:choose></xsl:for-each>

<xsl:if test="sum($clDr)&gt;0"><BR/><xsl:value-of select="sum($clCr)"/><xsl:for-each select="$clDr"><BR/>

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="concat('-', .)"/></xsl:when>

<xsl:otherwise><U><xsl:value-of select="concat('-', .)"/></U></xsl:otherwise></xsl:choose></xsl:for-each></xsl:if></TD>

<TD align="right" valign="bottom"><xsl:value-of select="round((sum($clCr) - sum($clDr))*100) div 100"/></TD>

</xsl:if></TR></xsl:if>

<xsl:if test="Garai:debitTesting(sum($clDr) - sum($clCr), sum($opDr) - sum($opCr))">

[31]

<TR><xsl:if test="sum($clDr)&gt;sum($clCr)"><TD align="left">To Balance c/d <BR/>

<xsl:for-each select="$clDr"><xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each>

<xsl:if test="sum($clCr)&gt;0"><BR/><xsl:for-each select="$clCr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/>

<BR/></xsl:for-each></xsl:if></TD><TD align="right"><BR/><xsl:for-each select="$clDr">

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="."/><BR/></xsl:when>

<xsl:otherwise><U><xsl:value-of select="."/></U></xsl:otherwise></xsl:choose></xsl:for-each>

<xsl:if test="sum($clCr)&gt;0"><BR/><xsl:value-of select="sum($clDr)"/><xsl:for-each select="$clCr"><BR/>

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="concat('-', .)"/></xsl:when>

<xsl:otherwise><U><xsl:value-of select="concat('-', .)"/></U></xsl:otherwise></xsl:choose></xsl:for-each></xsl:if></TD>

<TD align="right" valign="bottom"><xsl:value-of select="round((sum($clDr) - sum($clCr))*100) div 100"/></TD>

<TD align="left"><xsl:value-of select="Garai:creditEntry($entriesCr, sum($clCr) - sum($clDr), 1)"/></TD>

<TD align="right">...</TD><TD align="right">

<xsl:value-of select="Garai:creditEntry($entriesCr, sum($opCr) - sum($opDr), 2)"/></TD></xsl:if></TR></xsl:if>

<xsl:if test="Garai:testing('c')">

<TD align="left"><xsl:value-of select="Garai:debitEntry($entriesDr, sum($opDr) - sum($opCr), 1)"/></TD><TD>...</TD>

<TD align="right"><xsl:value-of select="Garai:debitEntry($entriesDr, sum($opDr) - sum($opCr), 2)"/></TD>

<TD align="left"><xsl:value-of select="Garai:creditEntry($entriesCr, sum($opCr) - sum($opDr), 1)"/></TD><TD>...</TD>

<TD align="right"><xsl:value-of select="Garai:creditEntry($entriesCr, sum($opCr) - sum($opDr), 2)"/></TD></xsl:if>

<xsl:if test="Garai:testing('d')">

<TD align="left"><xsl:value-of select="Garai:debitEntry($entriesDr, sum($opDr) - sum($opCr), 1)"/></TD><TD>...</TD>

<TD align="right"><xsl:value-of select="Garai:debitEntry($entriesDr, sum($opDr) - sum($opCr), 2)"/></TD>

<TD align="left"><xsl:value-of select="Garai:creditEntry($entriesCr, sum($opCr) - sum($opDr), 1)"/></TD><TD>...</TD>

<TD align="right"><xsl:value-of select="Garai:creditEntry($entriesCr, sum($opCr) - sum($opDr), 2)"/></TD>

</xsl:if></TR></xsl:for-each>

<xsl:if test="Garai:outsideBalancing(sum($clCr) - sum($clDr), sum($opCr) - sum($opDr), 'c')"><TR>

<xsl:if test="sum($clCr)&gt;=sum($clDr)"><TD>...</TD><TD>...</TD><TD>...</TD>

<TD align="left">By Balance c/d <BR/><xsl:for-each select="$clCr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each>

<xsl:if test="sum($clDr)&gt;0"><BR/><xsl:for-each select="$clDr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each></xsl:if></TD><TD align="right"><BR/>

<xsl:for-each select="$clCr"><xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="."/><BR/></xsl:when>

<xsl:otherwise><U><xsl:value-of select="."/></U></xsl:otherwise></xsl:choose></xsl:for-each>

<xsl:if test="sum($clDr)&gt;0"><BR/><xsl:value-of select="sum($clCr)"/>

<xsl:for-each select="$clDr"><BR/><xsl:choose><xsl:when test="position()!=last()">

<xsl:value-of select="concat('-', .)"/></xsl:when><xsl:otherwise><U><xsl:value-of select="concat('-', .)"/></U></xsl:otherwise>

</xsl:choose></xsl:for-each></xsl:if></TD><TD align="right" valign="bottom">

<xsl:value-of select="round(100*(sum($clCr) - sum($clDr))) div 100"/></TD></xsl:if></TR></xsl:if>

<xsl:if test="Garai:outsideBalancing(sum($clDr) - sum($clCr), sum($opDr) - sum($opCr), 'd')"><TR>

<xsl:if test="sum($clDr)&gt;sum($clCr)"><TD align="left">To Balance c/d <BR/><xsl:for-each select="$clDr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each>

<xsl:if test="sum($clCr)&gt;0"><BR/><xsl:for-each select="$clCr">

<xsl:value-of select="concat('.....',ancestor::node()/@Name)"/><BR/></xsl:for-each></xsl:if></TD>

<TD align="right"><BR/><xsl:for-each select="$clDr">

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="."/><BR/></xsl:when><xsl:otherwise><U>

<xsl:value-of select="."/></U></xsl:otherwise></xsl:choose></xsl:for-each>

<xsl:if test="sum($clCr)&gt;0"><BR/><xsl:value-of select="sum($clDr)"/><xsl:for-each select="$clCr"><BR/>

<xsl:choose><xsl:when test="position()!=last()"><xsl:value-of select="concat('-', .)"/></xsl:when>

<xsl:otherwise><U><xsl:value-of select="concat('-', .)"/></U></xsl:otherwise></xsl:choose></xsl:for-each></xsl:if></TD>

<TD align="right" valign="bottom"><xsl:value-of select="round(100*(sum($clDr) - sum($clCr))) div 100"/></TD><TD>...</TD>

<TD>...</TD><TD>...</TD></xsl:if></TR></xsl:if><TR><TD></TD><TD></TD>

<TD align="right" style="font-weight:900; color:darkgreen"><U><xsl:value-of select="round(100*$tDr) div 100"/></U></TD>

<TD></TD><TD></TD><TD align="right" style="font-weight:900; color:darkgreen"><U>

<xsl:value-of select="round(100*$tCr) div 100"/></U></TD></TR></TABLE>

<P style="page-break-before: always"></P></BODY></HTML></xsl:template></xsl:stylesheet>

5. XSLT file to Exhibit Traditionally Formatted Trial Balance – “Trial Balance.xsl”

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/><xsl:template match="/"><HTML><HEAD><TITLE>

Stylesheet to Prepare Trial Balance</TITLE></HEAD><BODY>

<xsl:variable name="closingDate" select="//Account/Debit/Posting[Particulars='To Balance c/d']/Date"></xsl:variable>

<TABLE width="100%" border="0"><TR><A name="trialBalance"><TH style="text-align:center;color:darkcyan;font-size:30">

[32]

Trial Balance as at <xsl:value-of select="$closingDate"/></TH></A></TR></TABLE>

<TABLE width="100%" border="15" style="color:blue"><TR style="color:darkred"><TH width="60%">Name of Account</TH>

<TH width="20%">Debit Balance (Rs.)</TH><TH width="20%">Credit Balance (Rs.)</TH></TR>

<xsl:for-each select="//Account">

<xsl:if test="Credit/Posting[Particulars='By Balance c/d'] | Debit/Posting[Particulars='To Balance c/d']">

                                <TR><TD><xsl:value-of select="@Name"/> A/c (<FONT color="#88ddee">

<xsl:value-of select="@Category"/></FONT>) </TD>

                                <TD style="text-align:right">

<xsl:value-of select="Credit/Posting[Particulars='By Balance c/d']/Amount"/></TD>

                                <TD style="text-align:right">

<xsl:value-of select="Debit/Posting[Particulars='To Balance c/d']/Amount"/></TD>

</TR></xsl:if></xsl:for-each>

<xsl:variable name="td" select="sum(//Account/Credit/Posting[Particulars='By Balance c/d']/Amount)"></xsl:variable>

<xsl:variable name="tc" select="sum(//Account/Debit/Posting[Particulars='To Balance c/d']/Amount)"></xsl:variable>

<TR><TD><FONT color="#996600" size="1">Designed by: <xsl:value-of select="//Designer"/><BR>```````````````````

<xsl:value-of select="//@Designation"/></BR></FONT></TD><TD style="text-align:right;font-weight:900;color:green;font-size:25"><U><xsl:value-of select="round(100*$td) div 100"/></U></TD>

<TD style="text-align:right;font-weight:900;color:green;font-size:25"><U><xsl:value-of select="round(100*$tc) div 100"/></U>

</TD></TR></TABLE><P style="page-break-before: always"></P></BODY></HTML></xsl:template></xsl:stylesheet>

6. XSLT file to Exhibit Traditionally Formatted Profit & Loss A/c – “PandL.xsl”

<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:Subodh="urn:schemas-microsoft-com:xslt" xmlns:Garai="http://mycompany.com/mynamespace">

<xsl:output method="html"/>

<Subodh:script language="VBScript" implements-prefix="Garai">

dim a, b, c, d, e

function reseta()

                                reseta="": a=-1: e=0' e is used to confirm that pfofit/ loss is entered only once

                end function

                function adjusta(nodeset)

                                a=a+1:if a&gt;= nodeset.length then

                                                a=nodeset.length-1: adjusta=" "

                                else

                                                adjusta="OK"

                                end if

                end function 

function selectItem(stat,nodeset,ind, surplus, tally)

                                with nodeset.item(a): b=.parentNode.parentNode.attributes.item(0).value: c=.childNodes(1).text

                                d="To ": if Left(c,2)="To"  then d="By "

                                if stat="OK" and ind=0 then

                                                if b="Profit and Loss" then

                                                                if c="To Balance b/d"  then

                                                                                selectItem="To Previous Balance"

                                                                elseif c="By Balance b/d"  then

                                                                                selectItem="By Previous Balance"

                                                                else

                                                                                selectItem=c

                                                                end if

                                                else

                                                                selectItem=d+b+" A/c"

                                                end if

                                                c= .parentNode.parentNode.attributes.item(1).value

if c="directMaterials" or b="indirectMaterials" then

                                                                selectItem="To "+b+" A/c"

                                                end if

                                elseif  stat="OK" and ind=1 then

                                                selectItem=.lastChild.text

                                else' For entering deficit when no. of credit entries is less

                                                if e&lt;2 and surplus&lt;0 and tally&lt;0 then

                                                                e=e+1: if ind=0 then

                                                                                selectItem="By Net Loss c/d"

                                                                else

[33]

                                                                                selectItem=-round(surplus, 2)

                                                                end if

                                                elseif e&lt;2 and surplus&gt;0 and tally&gt;0 then

                                                                e=e+1

                                                                if ind=0 then

                                                                                selectItem="To Net Profit c/d"

                                                                else

                                                                                selectItem=round(surplus, 2)

                                                                end if

                                                else

                                                                selectItem="..."

                                                end if

                                end if

                 end with

end function

</Subodh:script>

<xsl:template match="/">

<xsl:variable name="pd" select="//Account[@Name='Profit and Loss']/Debit/Posting[Particulars!='To Balance c/d'] | //Account[@Name!='Profit and Loss' and (@Category='directExpenditures' or @Category='indirectExpenditures' or @Category='directRevenues' or @Category='indirectRevenues')]/Credit/Posting[Particulars='By Balance c/d'] | //Account[@Category='directMaterials' or @Category='indirectMaterials']/Debit/Posting[Particulars='To Balance b/d']"></xsl:variable>

                <xsl:variable name="pc" select="//Account[@Name='Profit and Loss']/Credit/Posting[Particulars!='By Balance c/d'] | //Account[@Name!='Profit and Loss' and (@Category='directExpenditures' or @Category='indirectExpenditures' or @Category='directRevenues' or @Category='indirectRevenues')]/Debit/Posting[Particulars='To Balance c/d']"></xsl:variable>

                <xsl:variable name="cd" select="count($pd)"></xsl:variable>

<xsl:variable name="cc" select="count($pc)"></xsl:variable>

                <xsl:variable name="td" select="sum($pd/Amount)"></xsl:variable>

                <xsl:variable name="tc" select="sum($pc/Amount)"></xsl:variable>

                <xsl:variable name="profit" select="round(100*($tc - $td)) div 100"></xsl:variable>

                <xsl:variable name="rowtally" select="$cc - $cd"></xsl:variable>

<HTML><HEAD><TITLE>Profit and Loss Account</TITLE></HEAD><BODY>

<TABLE width="100%" border="0" style="font-size:25;color:#880000"><TR><TH align="left" width="10%">Dr.</TH>

<TH align="center" width="80%">Profit &#38; Loss Account <FONT size="2">for the period ended

<xsl:value-of select="//Posting[Particulars='To Balance c/d']/Date"/></FONT></TH>

<TH align="right" width="10%">Cr.</TH></TR></TABLE>

<TABLE width="100%" border="9" style="font-size:20;color:#553300;border-color:#eec777">

<TR><TH align="left" width="36%">Particulars</TH><TH align="right" width="14%">Amount (Rs.)</TH>

<TH align="left" width="36%">Particulars</TH><TH align="right" width="14%">Amount (Rs.)</TH></TR>

<xsl:if test="$cd&gt;=$cc"><xsl:value-of select="Garai:reseta()"/>

<xsl:for-each select="$pd"><xsl:variable name="status" select="Garai:adjusta($pc)"/><TR>

<TD align="left"><xsl:choose><xsl:when test="ancestor::node()[@Name='Profit and Loss']">

<xsl:choose><xsl:when test="Particulars='To Balance b/d'">To Previous Balance</xsl:when><xsl:otherwise>

<xsl:value-of select="Particulars"/></xsl:otherwise></xsl:choose></xsl:when>

<xsl:otherwise>To <xsl:value-of select="ancestor::node()/@Name"/> A/c</xsl:otherwise></xsl:choose></TD>

<TD align="right"><xsl:value-of select="round(100*Amount) div 100"/></TD>

<TD align="left"><xsl:value-of select="Garai:selectItem($status, $pc, 0, $profit, $rowtally)"/></TD>

<TD align="right"><xsl:value-of select="Garai:selectItem($status, $pc, 1, $profit, $rowtally)"/></TD>

</TR></xsl:for-each></xsl:if><xsl:if test="$cd&lt;$cc"><xsl:value-of select="Garai:reseta()"/>

<xsl:for-each select="$pc"><xsl:variable name="status" select="Garai:adjusta($pd)"/><TR>

<TD align="left"><xsl:value-of select="Garai:selectItem($status, $pd, 0, $profit, $rowtally)"/></TD>

<TD align="right"><xsl:value-of select="Garai:selectItem($status, $pd, 1, $profit, $rowtally)"/></TD>

<TD align="left"><xsl:choose><xsl:when test="ancestor::node()[@Name='Profit and Loss']">

<xsl:choose><xsl:when test="Particulars='By Balance b/d'">By Previous Balance</xsl:when><xsl:otherwise>

<xsl:value-of select="Particulars"/></xsl:otherwise></xsl:choose></xsl:when>

<xsl:otherwise>By <xsl:value-of select="ancestor::node()/@Name"/> A/c</xsl:otherwise></xsl:choose></TD>

<TD align="right"><xsl:value-of select="round(100*Amount) div 100"/></TD></TR>

</xsl:for-each></xsl:if><TR><xsl:if test="$td&lt;$tc and $cd&gt;=$cc">

<TD>To Net Profit c/d</TD><TD align="right"><xsl:value-of select="round(100*($tc - $td)) div 100"/></TD>

<TD>...</TD><TD align="right" >...</TD></xsl:if>

<xsl:if test="$td&gt;$tc and $cd&lt;=$cc"><TD>...</TD><TD align="right" >...</TD><TD>By Net Loss c/d</TD><TD align="right">

<xsl:value-of select="round(100*($td - $tc)) div 100"/></TD></xsl:if></TR>

<TR><TD>.</TD><TD align="right" style="font-weight:900">

[34]

<U><xsl:choose><xsl:when test="$td&lt;=$tc"><xsl:value-of select="$tc"/></xsl:when><xsl:otherwise>

<xsl:value-of select="$td"/></xsl:otherwise></xsl:choose></U></TD><TD>.</TD>

<TD align="right" style="font-weight:900"><U><xsl:choose><xsl:when test="$td&lt;=$tc">

<xsl:value-of select="round(100*$tc) div 100"/></xsl:when><xsl:otherwise>

<xsl:value-of select="round(100*$td) div 100"/></xsl:otherwise></xsl:choose></U></TD></TR></TABLE>

<P style="page-break-before: always"></P><P style="color:darkgreen;font-size:12">Designed by:

<xsl:value-of select="//Designer"/></P></BODY></HTML></xsl:template></xsl:stylesheet>

7. XSLT file to Exhibit Traditionally Formatted Balance Sheet – “BalanceSheet.xsl”

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:Subodh="urn:schemas-microsoft-com:xslt"

xmlns:Garai="http://mycompany.com/mynamespace">

<Subodh:script language="VBScript" implements-prefix="Garai">

dim xDoc, fso, ts, st, i, debits, credits, ss, cd, cc, id, ic, c, d:     set fso=CreateObject("Scripting.FileSystemObject")

set xDoc=CreateObject("MSXML2.DomDocument.4.0"): xDoc.load "financialStatements.balanceSheet.xml"

function fillBSTemplate(x)

dim selectedNode, newChild, newGrandChild: for each y in x

                                with y.parentNode.parentNode.attributes

                                                st="//*[substring-after(name(.),'.')='"+.item(1).value+"']"

                                                if .item(1).value="contraItems" and y.childNodes(1).text="By Balance c/d" then

                                                                st="balanceSheet.assets"+st

                                                end if

                                                if .item(1).value="currentBanks" and y.childNodes(1).text="To Balance c/d"  then

                                                                st="//currentLiabilities.otherCurrentLiabilities"

                                                end if

                                                set selectedNode=xdoc.documentElement.selectSingleNode(st)

                                                set newChild=selectedNode.appendChild(xDoc.createElement("Item"))

                                                set newGrandChild=newChild.appendChild(xDoc.createElement("Name"))

                                                newGrandChild.text=.item(0).value

                                                set newGrandChild=newChild.appendChild(xDoc.createElement("Amount"))

                                                if .item(1).value="tradeCreditors" and y.childNodes(1).text="By Balance c/d" then

                                                                newGrandChild.text= - y.lastChild.text

                                                elseif .item(1).value="tradeDebtors" and y.childNodes(1).text="To Balance c/d" then

                                                                newGrandChild.text= - y.lastChild.text

                                                else

                                                                newGrandChild.text=y.lastChild.text

                                                end if

                                 end with

                   next: fillBSTemplate=""

end function

function putSurplusDeficit(x, vd)

dim selectedNode, newNode, newBranchNode: if x&gt;=0 then

                                st="reserves.revenueReserves": i="Credit"

                else

                                st="fictitiousAssets.cumulativeDeficitOrLoss": x= - x: i="Debit"

                end if

                set selectedNode=xDoc.documentElement.selectSingleNode("//*[name(.)='"+st+"']")

                set newNode=selectedNode.appendChild(xDoc.createElement("Item"))

                set newBranchNode=newNode.appendChild(xDoc.createElement("Name"))

                newBranchNode.text=i+" Balance of Profit and Loss A/c"

                set newBranchNode=newNode.appendChild(xDoc.createElement("Amount"))

                newBranchNode.text= round(x, 2): xDoc.save vd+"BalanceSheet.xml": putSurplusDeficit=""

end function

function forLargerEntry()

                set credits= xDoc.documentElement.firstChild.selectNodes( ".//Item[name(parent::node())!='currentLiabilities.tradeCreditors'] | .//currentLiabilities.tradeCreditors")

                set debits=xDoc.documentElement.lastChild.selectNodes(

".//Item[name(parent::node())!='receivables.tradeDebtors'] | .//receivables.tradeDebtors")

                cc=credits.length: cd=debits.length: if cc&gt;=cd then

                                set forLargerEntry=credits

                else

[35]

                                set forLargerEntry=debits

                end if

                ic=-1: id=-1

end function

function forActualEntry(side, indexe)

                if side="c" then

                                if indexe=0 then ic=ic+1

                                if ic&lt;cc then

                                                if indexe=0 then

                                                                if credits.item(ic).nodeName="currentLiabilities.tradeCreditors" then

                                                                                forActualEntry="Total Creditors"

                                                                else

                                                                                forActualEntry=credits.item(ic).childNodes(0).text

                                                                end if

                                                elseif indexe=2 then

                                                                if credits.item(ic).nodeName="currentLiabilities.tradeCreditors" then

                                                                                d=0: set ss=credits.item(ic).selectNodes(".//Amount")

                                                                                for c=0 to ss.length-1: d=d+CSng(ss.item(c).text): next: forActualEntry=d

                                                                else

                                                                                forActualEntry=credits.item(ic).childNodes(1).text

                                                                end if

                                                elseif indexe=1 then

                                                                if credits.item(ic).nodeName="currentLiabilities.tradeCreditors" then

                                                                                forActualEntry="tradeCreditors"

                                                                else

                                                                                st=credits.item(ic).parentNode.nodeName: i=InStr(1,st,".")

                                                                                forActualEntry=Right(st,len(st)-i)

                                                                end if

                                                end if

                                else

                                                forActualEntry="."

                                end if

                else

                                if indexe=0 then id=id+1

                                if id&lt;cd then

                                                if indexe=0 then

                                                                if debits.item(id).nodeName="receivables.tradeDebtors" then

                                                                                forActualEntry="Total Debtors"

                                                                else

                                                                                forActualEntry=debits.item(id).childNodes(0).text

                                                                end if

                                                elseif indexe=2 then

                                                                if debits.item(id).nodeName="receivables.tradeDebtors" then

                                                                                d=0: set ss=debits.item(id).selectNodes(".//Amount")

                                                                                for c=0 to ss.length-1: d=d+CSng(ss.item(c).text): next: forActualEntry=d

                                                                else

                                                                                forActualEntry=debits.item(id).childNodes(1).text

                                                                end if

                                                elseif indexe=1 then

                                                                if debits.item(id).nodeName="receivables.tradeDebtors" then

                                                                                forActualEntry="tradeDebtors"

                                                                else

                                                                                st=debits.item(id).parentNode.nodeName: i=InStr(1,st,".")

                                                                                forActualEntry=Right(st,len(st)-i)

                                                                end if

                                                end if

                                else

                                                forActualEntry="."

                                end if      

                end if

end function

function forTotals(x)

                d=0.0

[36]

                if x="c" then

                                for i=0 to cc-1

                                                if credits.item(i).nodeName="currentLiabilities.tradeCreditors" then

                                                                set ss=credits.item(i).selectNodes(".//Amount")

                                                                st=0.0: for c=0 to ss.length-1: st=st+CSng(ss.item(c).text): next: d+round(st,2)

                                                else

                                                                d=d+round(CSng(credits.item(i).lastChild.text),2)

                                                end if

                                next: forTotals=round(d, 2)

                else

                                for i=0 to cd-1

                                                if debits.item(i).nodeName="receivables.tradeDebtors" then

                                                                set ss=debits.item(i).selectNodes(".//Amount")

                                                                st=0.0: for c=0 to ss.length-1: st=st+CSng(ss.item(c).text): next: d=d+st

                                                else

                                                                d=d+debits.item(i).lastChild.text

                                                end if

                                next: forTotals=round(d, 2)

                end if

end function

</Subodh:script>

<xsl:output method="html"/><xsl:template match="/">

<xsl:variable name="pldt" select="sum(//Account[@Name='Trading']/Debit/Posting[Particulars!='To Balance c/d' and Particulars!='Profit and Loss' and Particulars!='Income and Expenditure']/Amount)+sum(//Account[@Name='Profit and Loss']/Debit/Posting[Particulars!='To Balance c/d' and Particulars!='Trading' and Particulars!='Income and Expenditure']/Amount)+sum(//Account[@Name='Income and Expenditure']/Debit/Posting[Particulars!='To Balance c/d' and Particulars!='Trading' and Particulars!='Profit and Loss']/Amount)+sum(//Account[@Category='directExpenditures' or @Category='indirectExpenditures' or @Category='directRevenues' or @Category='indirectRevenues']/Credit/Posting[Particulars='By Balance c/d']/Amount)+sum(//Account[@Category='directMaterials' or @Category='indirectMaterials']/Debit/Posting[Particulars='To Balance b/d']/Amount)"></xsl:variable>

<xsl:variable name="plct" select="sum(//Account[@Name='Trading']/Credit/Posting[Particulars!='By Balance c/d' and Particulars!='Profit and Loss' and Particulars!='Income and Expenditure']/Amount)+sum(//Account[@Name='Profit and Loss']/Credit/Posting[Particulars!='By Balance c/d' and Particulars!='Trading' and Particulars!='Income and Expenditure']/Amount)+sum(//Account[@Name='Income and Expenditure']/Credit/Posting[Particulars!='By Balance c/d' and Particulars!='Trading' and Particulars!='Profit and Loss']/Amount)+sum(//Account[@Category='directExpenditures' or @Category='indirectExpenditures' or @Category='directRevenues' or @Category='indirectRevenues']/Debit/Posting[Particulars='To Balance c/d']/Amount)"></xsl:variable>

<xsl:variable name="directory" select="normalize-space(string(//VirtualDirectory))"></xsl:variable>

<xsl:value-of select="Garai:fillBSTemplate(//Account[@Name!='Trading' and @Name!='Profit and Loss' and @Name!='Income and Expenditure' and @Category!='directExpenditures' and @Category!='indirectExpenditures' and @Category!='directRevenues' and @Category!='indirectRevenues' and @Category!='directMaterials' and @Category!='indirectMaterials']//Posting[Particulars='To Balance c/d' or Particulars='By Balance c/d'] | //Account[@Category='directMaterials' or @Category='indirectMaterials']/Debit/Posting[Particulars='To Trading A/c' or Particulars='To Profit and Loss A/c' or Particulars='To Income and Expenditure A/c'])"/>

<xsl:value-of select="Garai:putSurplusDeficit($plct - $pldt, $directory)"/><HTML><HEAD><BGSOUND src="http://Garai/Antabihin.wma" loop="-1"/>

<TITLE>Balance Sheet</TITLE></HEAD><BODY><P style="color:darkgreen;font-size:40;text-align:center">

Balance Sheet<FONT size="4"> as at <xsl:value-of select="//Posting[Particulars='To Balance c/d']/Date"/></FONT></P>

<TABLE border="9" width="100%" style="color:darkblue;font-size:20"><TR>

<TH width="32%">Liabilities</TH><TH width="10%" style="text-align: left; font-size: 10">Category</TH><TH width="13%" style="border-right-width:2;border-color:blue">Amount (Rs)</TH><TH width="32%" style="border-left-width:2">Assets</TH>

<TH width="10%" style="text-align: left; font-size: 10">Category</TH><TH width="13%">Amount (Rs)</TH></TR>

<xsl:variable name="largerEntry" select="Garai:forLargerEntry()"></xsl:variable><xsl:for-each select="$largerEntry"><TR>

<TD><xsl:value-of select="Garai:forActualEntry('c',0)"/></TD><TD style="color: 88ccee; font-size: 10"><xsl:value-of select="Garai:forActualEntry('c',1)"/></TD><TD align="right" style="border-right-width:2;border-color:blue"><xsl:value-of select="Garai:forActualEntry('c',2)"/></TD>

<TD style="border-left-width:2;border-color:blue"><xsl:value-of select="Garai:forActualEntry('d',0)"/></TD><TD style="color: 88ccee; font-size: 10"><xsl:value-of select="Garai:forActualEntry('d',1)"/></TD><TD align="right"><xsl:value-of select="Garai:forActualEntry('d',2)"/></TD></TR></xsl:for-each>

<TR><TD>.</TD><TD></TD><TD align="right" style="font-weight:900;border-right-width:2;border-color:blue"><U><xsl:value-of select="Garai:forTotals('c')"/></U></TD><TD style="border-left-width:2">.</TD><TD></TD>

<TD align="right" style="font-weight:900"><U><xsl:value-of select="Garai:forTotals('d')"/></U></TD></TR></TABLE>

[37]

<P style="page-break-before: always"></P></BODY></HTML></xsl:template></xsl:stylesheet>

References

Bradley, Stephen P. (1993), “The Role of IT Networking in Sustaining Competitive Advantage” in Globalisation, Technology and Competition – The Fusion of Computers and Telecommunications in the 1990’s edited by Stephen P. Bradley, Jerry A. Hausman and Richard L. Nolan, Harvard Business School Press, Boston, Massachusetts, pp.113-42.

Bradley, Stephen P., Jerry A. Hausman and Richard L. Nolan (1993), “Globalization, Competition and Technology” in Globalization, Technology and Competition – The Fusion of Computers and Telecommunications in the 1990’s edited by Stephen P. Bradley, Jerry A. Hausman and Richard L. Nolan, Harvard Business School Press, Boston, Massachusetts, pp.3-32.

Buser, David, John Kauffman, Juan T. Llibre, Brian Francis, David Sussman, Chris Ullman and Jon Duckett (1999), Beginning Active Server Pages 3.0, Wrox Press Ltd, Shroff Publishers and Distributors Pvt. Ltd., Navi Mumbai.

Diao, Yanlei, Mehmet Altinel, Michael J. Franklin, Hao Zhang and Peter Fischer (2003), “Path Sharing and Predicate Evaluation for High –Performance XML Filtering”, ACM Transactions on Database Systems, Vol.28, No.4, December, pp. 467-516.

Fakas, Georgios John and Bill Karakostas (2004), “A Peer to Peer (P2P) Architecture for Dynamic Workflow Management”, Informatin and Software Technology, Vol.46, No.6 (May), pp.423-31.

Fingar, Peter (1996), The Blueprints of Business Objects, SIGS Books & Multimedia, New York, London, Paris, Munich, Cologne, pp.1-2.

Garai, Subodh Chandra (2003), “Accounting in RDBMS and Internet Architecture”, Indian Accounting Review, Vol.7, No.2 (December), pp.36-54.

Harold, Elliotte Rusty (2000), XML Bible, IDG Books India Pvt. Ltd., Daryaganj, New Delhi.

Johnston, Randolph P. (2003), “A Strategy for Finding the Right Accounting Software”, Journal of Accountancy, Vol.196, No.3 (Sept), pp.39-46.

Kothari, Nitin (2003), “Connect to Your Office PC from Home”, Information Technology, Vol.12, No.1 (March), pp.50-51.

Krishnan, Ramaya, Michael Smith and Rahul Telang (2003), “The Economics of Peer-to-Peer Networks”, Journal of Information Technology Theory and Application, Vol.5, No.3, pp.31-44.

Kuo, Jong-Yih (2004), “A Document-Driven Agent-Based Approach for Business Processes Management”, Information and Software Technology, Vol.46, No.6 (May), pp.373-82.

Muller, Nathan J. (1999), “Choosing and Equipping an Internet Server” in Handbook of Local Area Networks (On ‘Building Enterprise Solutions Using LAN-Based Technology’) edited by John P. Stones, CRC Press LLC, Viva Books Pvt. Ltd., New Delhi, Mumbai, Chennai, pp. 469-81.

Patel-Schneider, Peter F. and Jérôme Siméon (2003), “The Yin/ Yang Web: A Unified Model for XML Syntax and RDF Semantics”, IEEE Transactions on Knowledge and Data Engineering, Vol.15, No.4, July-August, pp. 797-812.

Vasal, Virendra K. and Rajendra P. Srivastava, “eXtensible Business Reporting Language (XBRL) – the Digital Language of Business: an Indian Perspective”, Indian Accounting Review, Vol.6, No.1, pp.41-59.

Web Sites:

http://www.acm.org/tods/Upcoming.htm;

http://www.edgar-online.com/xbrl/;

http://www.nasdaq.com/xbrl/demo;

http://www.trinity.edu/rjensen/XBRLandOLAP.htm;

http://www.w3.org/TR/2004/REC-xml-20040204/

http://www.xbrl.org.

[The author, Dr. Subodh Chandra Garai, is Former Principal of BARUIPUR COLLEGE and resides at Laskarpur Purbapara, Kolkata - 700 153, with personal E-Mail address: scgarai55@gmail.com.

This author later in 2006 (when he was the Reader of Commerce of K. K. Das College at Garia, Kolkata 700084 and a part-time faculty member of Govt. College of Engineering and Leather Technology at Salt Lake City, Sector III, Kolkata 700098), guided/ supervised a final year project completed by five Computer Science & Engineering and Information Technology students of Govt. College of Engineering and Leather Technology - a copy of the Project Report (with certificate) is reproduced in the link below.]