try {
// collect asciimath data with the collector
//AsciiMathBlockValue [] arrAMBlock = pamb.getAllAsciiMathBlocks();
AsciiMathBlockValue [] arrAMBlock = jAsciiMath.getArrayOfAsciiMathBlocks();
if (arrAMBlock == null)
throw new DtbookAsciiMathException("Not founded any asciimath-blocks!");
String inputAsciiMathText;
StringBuffer sb = new StringBuffer();
int iCount = 0, max = arrAMBlock.length;
AsciiMathBlockValue amValue;
// collect all asciimath calculus data into one stringbuffer
// and mark every asciimath blocks with special mark string,
// that is possible to find these special labeled asciimath
// positions later. At later time, generated asciimath-xml
// blocks will replaced <asciimath> and </asciimath> blocks.
for(int i = 0; i < max; i++)
{
amValue = arrAMBlock[i];
// to much strings: class="asciimath">
inputAsciiMathText = amValue.getAsciiMathValue();
//inputAsciiMathText = inputAsciiMathText.substring("class=\"asciimath\">".length());
sb.append("x_" + iCount + cnstMarkBegin + inputAsciiMathText + "x_" + iCount +cnstMarkEnd +"\n");
iCount++;
}
inputAsciiMathText = sb.toString();
// replace inputText_here with template data
// (template data is just little modifyed ascimath editor data)
String strChanged = strTemplate.replace("inputText_here",
new String(inputAsciiMathText.getBytes(charsetName)));
//System.out.println( "strMuutettu");
//System.out.println( strMuutettu);
//System.out.println();
// write modified template data into a file and run it later within
// the asciimath browser:
FileWriter fw = new FileWriter(outputFile);
fw.write(strChanged.toCharArray());
fw.close();
// take timestamp just writen file:
File tmp_file = outputFile ;
//outputFile = null;
outputFile = new File(tmp_file.getAbsolutePath());
tmp_file = null;
long outputFile_lastModified = outputFile.lastModified();
long outputFile_size = outputFile.length();
File exe_asciimath = outputFile.getAbsoluteFile();
// A string can be executed in the standard java way:
// Create the String
outputFile = null;
outputFile = new File(exeXmlFileName);
if (outputFile == null)
throw new DtbookAsciiMathException("outputFile is null: " + exeXmlFileName +"!");
long outputFileSize = exe_asciimath.length();
exe_asciimath = null;
String command = "\"" + asciiMathWWWBrowserApplication +"\""; // -chrome
// see if this application is executed under unix