test.xml).trim() function from PHP:
function trim(s)
{
var trimmed = s.replace(/^\s+|\s+$/g, '') ;
return trimmed;
}
collapseWhiteSpaces, collapses white spaces generated by the Enter or Tab keys:
function collapseWhiteSpaces(allstr)
{
var whtSpMult = new RegExp("\\s\\s+", "g");
var strWithoutMultipleSpaces = allstr.replace(whtSpMult, " ");
return strWithoutMultipleSpaces;
}
clientRequests, is the main function. It does nearly all the work behind the application as follows:textarea HTML element (<textarea id="xml" rows="10" cols="50">) using its ID from the Web interfacechunks array, which will be storing the transformed XML document< and > entities and deleting the white spaces generated by the Enter or Tab keyschunks arraysaveChunks() function, which contains the Ajax mechanism implementation and is described after the clientRequests function bodyclientRequests function.saveChunks() function builds the URL of the server script (in this case 2.php) as well as the following parameters:XMLchunck -- the current chunk, which is sent through the URLchunkNr -- the total number of chunkschuncks -- the current chunk numberXMLName -- the XML document name (in this case test.xml)saveChunks() function then opens a connection to the server using a GET request and calls the callback function to check the progress of requests, identify the result of the request and handle data returned from the server. See Listing 2 for the complete code of the saveChunks() function.callback(), which is the Ajax callback function. It is responsible for checking the progress of requests, identifying the result of the request and handling data returned from the server. See Listing 3 for the complete code of the callback() function.test.xml file, writes each chunk one by one as they comes from the 1.php application using the $_GET['XMLchunck'] parameter, and lists a progress percentage using $_GET['chunkNr'] and $_GET['chuncks'] parameters into this simple formula (int)(( $_GET['chunkNr'] *100)/ $_GET['chuncks']). See Listing 5 for the complete code for the second page of the Ajax mechanism.
Click here for larger image
Figure 1. The Web interface of the Application Transferring and Monitoring Huge XML Documents
Click here for larger image
Figure 2. The Web Interface of the Application After Inserting a Huge XML
Click here for larger image
Figure 3. The Transfer of the Huge XML Document in Progress
Click here for larger image
Figure 4. The Transfer Completed Successfully
Click here for larger image
Figure 5. The Generated XML Document, test.xml
Click here for larger image
Figure 6. The Content of the Generated XML Document, test.xml, as Seen from the Web Interface of the Application