NullPointerException,
Exception
{
File modifiedFile = null;
modifiedFile = new File(exeXmlFileName);
AsciiMathBlockValue amValue;
//String strMuutettuFileData = new String(muutettuFile.readBytes());
System.out.println( "modifiedFile.lastModified()=" + modifiedFile.lastModified());
System.out.println( "modifiedFile.size()=" + modifiedFile.length());
//System.out.println( "strMuutettuFileData");
//System.out.println( strMuutettuFileData);
System.out.println();
long modifiedFile_length = modifiedFile.length();
if (modifiedFile_length == outputFileSize)
throw new DtbookAsciiMathException("Unmodified file! The size of file is same: " +outputFileSize
+"\nUser has not saved a generated asciimath editor file by the browser!");
System.out.println( "Reading and handling just saved file....");
String strMuutettuFileData = readFileData(modifiedFile, charsetName);
//strMuutettuFileData = korjaaPuuttuvaMetaTag(strMuutettuFileData);
String strMathMlData = null; // getMathMlData(strMuutettuFileData);
//stMarkBegin cnstMarkEnd
int iCount = 0, max = arrAMBlock.length;
StringBuffer sb = new StringBuffer();
String inputAsciiMathText2;
String search_start;
String search_end;
String strFound;
int indBegin, indBegin_end, indEnd;
// selecting/searching read modified data and collection every value
// into back asciimath data block:
for(int i = 0; i < max; i++)
{
amValue = arrAMBlock[i];
// liika mjonoa: class="asciimath">
// inputAsciiMathText2 = getXmlAsciiMathValue(iCount, strMuutettuFileData)
search_start = "x_" + iCount + cnstMarkBegin;
search_end = "x_" + iCount + cnstMarkEnd;
indBegin = strMuutettuFileData.indexOf(search_start);
if (indBegin == -1)
continue;
indBegin_end = indBegin + search_start.length();
strFound = strMuutettuFileData.substring(indBegin);
indBegin = strMuutettuFileData.indexOf(search_start, indBegin_end);
if (indBegin == -1)
continue;
indBegin_end = indBegin + search_start.length();
indBegin = strMuutettuFileData.indexOf(search_start, indBegin_end);
if (indBegin == -1)
continue;
indBegin_end = indBegin + search_start.length();
indEnd = strMuutettuFileData.indexOf(search_end, indBegin);
if (indBegin == -1)
continue;
if (indEnd == -1)
continue;
inputAsciiMathText2 = strMuutettuFileData.substring(indBegin_end, indEnd);
// replace html asciimath characters and words into normal characters:
inputAsciiMathText2 = inputAsciiMathText2.replaceAll("<", "<");
inputAsciiMathText2 = inputAsciiMathText2.replaceAll("<", "<");
inputAsciiMathText2 = inputAsciiMathText2.replaceAll("<", "<");
// replace all html coded > character into normal > characer
inputAsciiMathText2 = inputAsciiMathText2.replaceAll(">", ">");
inputAsciiMathText2 = inputAsciiMathText2.replaceAll(">", ">");
inputAsciiMathText2 = inputAsciiMathText2.replaceAll(">", ">");
// replace possible & into & character:
inputAsciiMathText2 = inputAsciiMathText2.replaceAll("&", "&");
// take away unneede and unxml attribute: <m:mtd -moz-math-columnalign="left">
inputAsciiMathText2 = inputAsciiMathText2.replaceAll("-moz-math-columnalign=\"left\"", "");
inputAsciiMathText2 = inputAsciiMathText2.replaceAll("<m:mtd >", "<m:mtd>");
inputAsciiMathText2 = inputAsciiMathText2.replaceAll("<m:mspace>\\s*</m:mspace>", "<m:mspace/>");
inputAsciiMathText2 = inputAsciiMathText2.replaceAll(
"<(\\s*)mspace((\\s+\\S+\\s*=\\s*\\S+\\s*)+)>\\s*<(\\s*)/(\\s*)mspace(\\s*)>",
"<mspace$2/>");
/** TODO: Handle: & character in:
<m:math xmlns:dtbook="http://www.daisy.org/z3986/2005/dtbook/" altimg="" alttext="& lt lt A lt rArr lt B lt">
inputAsciiMathText2 = replaceETCharsInAsciiMath(inputAsciiMathText2);
*/
amValue.setXmlValue(inputAsciiMathText2);
amValue.setModifiedXmlValue(getModifiedXmlValue(inputAsciiMathText2));
// collect textual data into a caller buffer:
sb.append("" + iCount + ":\n Row: " + amValue.getRow() +" Column: " + amValue.getColumn() + "\n\n");
sb.append("" + ":\n"+ amValue.getModifiedXmlValue() + "\n\n");
iCount++;
}
// sb.append strMuutettuFileData
strMathMlData = sb.toString();