use of com.sun.org.apache.xerces.internal.parsers.DOMParser in project cogtool by cogtool.
the class BalsamiqButtonAPIConverter method parseBalsamiqFile.
/** Helper function used by importDesign.
* This method is used to parse the tags of each .bmml file in the
* directory. The file represents a {@link File} in the directory.
*
* @param inputFile the specified directory or file
* @see the new design in the project window.
*/
public void parseBalsamiqFile(File inputFile) throws IOException {
String fileName = inputFile.getName();
int lastIndex = fileName.lastIndexOf(".");
fileName = (lastIndex == -1) ? fileName : fileName.substring(0, lastIndex);
/* Check to make sure that this frame has not been created yet. Cycles
* by transitions may exist in the design and these files do not need
* to be parsed more than once. */
if (!visitedFramesNames.contains(fileName)) {
visitedFramesNames.add(fileName);
// Create a Xerces DOM Parser. A DOM Parser can parse an XML file
// and create a tree representation of it. This same parser method
// is used in ImportCogTool.java to import from CogTool XML.
DOMParser parser = new DOMParser();
InputStream fis = new FileInputStream(inputFile);
Reader input = new InputStreamReader(fis, "UTF-8");
// Parse the Document and traverse the DOM
try {
parser.parse(new InputSource(input));
} catch (SAXException e) {
throw new RcvrImportException("Not a valid XML file to parse.");
}
//Traverse the xml tags in the tree beginning at the root, the document
Document document = parser.getDocument();
parseFrame(document, fileName);
}
}
Aggregations