6 package de.uni_hamburg.corpora.visualization;
15 import java.io.IOException;
16 import java.io.UnsupportedEncodingException;
17 import java.io.PrintWriter;
18 import java.net.MalformedURLException;
20 import java.nio.file.Files;
21 import java.nio.file.Paths;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import javax.xml.parsers.ParserConfigurationException;
26 import javax.xml.
transform.TransformerConfigurationException;
27 import javax.xml.transform.TransformerException;
28 import javax.xml.xpath.XPathExpressionException;
29 import org.exmaralda.partitureditor.jexmaralda.BasicTranscription;
30 import org.jdom.JDOMException;
31 import org.xml.sax.SAXException;
40 private static final String STYLESHEET_PATH =
"/xsl/EXB2hScoreHTML.xsl";
41 private final String SERVICE_NAME =
"HScoreHTML";
44 String corpusname =
"";
52 }
catch (TransformerException ex) {
53 Logger.getLogger(
HScoreHTML.class.getName()).log(Level.SEVERE, null, ex);
81 String referencedRecording = bt.getHead().getMetaInformation().getReferencedFile(
"wav");
82 if (referencedRecording != null) {
83 System.out.println(
"not null " + referencedRecording);
94 public static void main(String[] args) {
96 if (args.length == 0) {
97 System.out.println(
"Usage: " +
HScoreHTML.class.getName()
101 byte[] encoded = Files.readAllBytes(Paths.get(args[0]));
102 String btString =
new String(encoded,
"UTF-8");
104 if (args.length >= 2) {
105 PrintWriter htmlOut =
new PrintWriter(args[1]);
106 htmlOut.print(score.
getHTML());
109 System.out.println(score.
getHTML());
112 }
catch (UnsupportedEncodingException uee) {
113 uee.printStackTrace();
114 }
catch (IOException ioe) {
115 ioe.printStackTrace();
128 cio.write(result, targeturl);
129 stats.
addCorrect(SERVICE_NAME, cd,
"Visualization of file was successfully saved at " + targeturl);
130 }
catch (MalformedURLException ex) {
131 stats.
addException(SERVICE_NAME, ex,
"Malformed URL used");
132 }
catch (IOException ex) {
133 stats.
addException(SERVICE_NAME, ex,
"Input Output Exception");
134 }
catch (TransformerException ex) {
135 stats.
addException(SERVICE_NAME, ex,
"Transformer Exception");
136 }
catch (ParserConfigurationException ex) {
137 stats.
addException(SERVICE_NAME, ex,
"Parser Exception");
138 }
catch (SAXException ex) {
140 }
catch (XPathExpressionException ex) {
141 stats.
addException(SERVICE_NAME, ex,
"XPath Exception");
147 public Report function(
Corpus co)
throws TransformerException, TransformerConfigurationException, IOException, SAXException {
149 Collection<BasicTranscriptionData> btc = co.getBasicTranscriptionData();
151 stats.
merge(
function(bt));
159 Class cl = Class.forName(
"de.uni_hamburg.corpora.BasicTranscriptionData");
161 }
catch (ClassNotFoundException ex) {
169 if (args.length == 0) {
170 System.out.println(
"Usage: " +
ScoreHTML.class.getName()
174 byte[] encoded = Files.readAllBytes(Paths.get(args[0]));
175 String btString =
new String(encoded,
"UTF-8");
177 if (args.length >= 2) {
178 PrintWriter htmlOut =
new PrintWriter(args[1]);
179 htmlOut.print(score.
getHTML());
182 System.out.println(score.
getHTML());
185 }
catch (UnsupportedEncodingException uee) {
186 report.
addException(SERVICE_NAME, uee,
"encoding exception");
187 }
catch (IOException ioe) {
188 report.
addException(SERVICE_NAME, ioe,
"input output exception");
189 }
catch (JDOMException ex) {
190 Logger.getLogger(
HScoreHTML.class.getName()).log(Level.SEVERE, null, ex);
191 }
catch (TransformerException ex) {
192 Logger.getLogger(
HScoreHTML.class.getName()).log(Level.SEVERE, null, ex);
199 String description =
"This class creates an html visualization " 200 +
"in the HScore format from an exb. ";
String getFilenameWithoutFileEnding()
String toSaveableString()
HScoreHTML(String btAsString)
static void main(String[] args)
String basicTranscriptionString
Report doMain(String[] args)
static BasicTranscription String2BasicTranscription(String btAsString)
static String InputStream2String(InputStream is)
void addCorrect(String statId, String description)
BasicTranscription basicTranscription
Collection< Class<?extends CorpusData > > getIsUsableFor()
void addException(Throwable e, String description)
String createFromBasicTranscription(String btAsString)