version 1.1, 2000/10/04 15:47:00
|
version 1.2, 2000/10/04 18:18:23
|
Line 51 public class SiRPACServlet extends HttpS
|
Line 51 public class SiRPACServlet extends HttpS
|
|
|
private static final String MAIL_TO = "barstow@mediaone.net"; |
private static final String MAIL_TO = "barstow@mediaone.net"; |
|
|
|
private void generateGraph (ServletOutputStream out, String rdf) { |
|
try { |
|
out.println("<hr title=\"visualisation\">"); |
|
out.println("<h3>Visualized RDF data model</h3>"); |
|
|
|
out.println("<img src=\"http://localhost:8001/servlet/SiRPAC.tmp/1.gif\"/>"); |
|
|
|
} catch (Exception e) { |
|
System.err.println("Exception: " + e.getMessage()); |
|
} |
|
} |
|
|
|
/* |
|
* replaceString - search the given string for substring "key" |
|
* and if it is found, replace it with string "replacement" |
|
* |
|
*@return if no substitutions are done, input is returned; otherwise |
|
* a new string is returned. |
|
*/ |
|
private String replaceString(String input, String key, String replacement) { |
|
StringBuffer sb = new StringBuffer(""); |
|
StringTokenizer st = new StringTokenizer(input, key); |
|
|
|
// Must handle the case where the input string begins with the key |
|
if (input.startsWith(key)) |
|
sb = sb.append(replacement); |
|
while (st.hasMoreTokens()) { |
|
sb = sb.append(st.nextToken()); |
|
if (st.hasMoreTokens()) |
|
sb = sb.append(replacement); |
|
} |
|
if (sb.length() >= 1) |
|
return sb.toString(); |
|
else |
|
return input; |
|
} |
|
|
private void printDocumentHeader (ServletOutputStream out) { |
private void printDocumentHeader (ServletOutputStream out) { |
|
|
try { |
try { |
Line 64 public class SiRPACServlet extends HttpS
|
Line 101 public class SiRPACServlet extends HttpS
|
out.println("<BODY>"); |
out.println("<BODY>"); |
|
|
} catch (Exception e) { |
} catch (Exception e) { |
// @@ |
System.err.println("Exception: " + e.getMessage()); |
} |
} |
} |
} |
|
|
Line 74 public class SiRPACServlet extends HttpS
|
Line 111 public class SiRPACServlet extends HttpS
|
out.println("<h3>The original RDF/XML document</h3>"); |
out.println("<h3>The original RDF/XML document</h3>"); |
out.println("<pre>"); |
out.println("<pre>"); |
|
|
// Replace all "<" with "<" |
String s = replaceString(rdf, "<", "<"); |
StringBuffer sb = new StringBuffer(""); |
StringTokenizer st = new StringTokenizer(s, "\n"); |
StringTokenizer st = new StringTokenizer(rdf, "<"); |
|
|
|
// Must handle a leading "<" |
|
if (rdf.startsWith("<")) |
|
sb = sb.append("<"); |
|
while (st.hasMoreTokens()) { |
|
sb = sb.append(st.nextToken()); |
|
if (st.hasMoreTokens()) |
|
sb = sb.append("<"); |
|
} |
|
|
|
// Now output the RDF one line at a time with line numbers |
// Now output the RDF one line at a time with line numbers |
int lineNum = 1; |
int lineNum = 1; |
st = new StringTokenizer(sb.toString(), "\n"); |
|
while (st.hasMoreTokens()) { |
while (st.hasMoreTokens()) { |
out.print ("<a name=\"" + lineNum + "\">" + lineNum + |
out.print ("<a name=\"" + lineNum + "\">" + lineNum + |
"</a>: " + st.nextToken()); |
"</a>: " + st.nextToken()); |
Line 121 public class SiRPACServlet extends HttpS
|
Line 147 public class SiRPACServlet extends HttpS
|
System.err.println("Exception: " + e.getMessage()); |
System.err.println("Exception: " + e.getMessage()); |
} |
} |
} |
} |
|
|
private void printDocumentFooter (ServletOutputStream out, String rdf) { |
private void printDocumentFooter (ServletOutputStream out, String rdf) { |
try { |
try { |
|
|
out.println("<hr title=\"Problem reporting\">"); |
out.println("<hr title=\"Problem reporting\">"); |
out.println("<h3>Feedback</h3>"); |
out.println("<h3>Feedback</h3>"); |
out.println("<p>If you suspect SiRPAC produced an error, please type an explanation below why you think so. Once you press <i>Submit problem report</i> button, the message along with the example is mailed automatically to <i>barstow@w3.org</i></p>"); |
out.println("<p>If you suspect that SiRPAC produced an error, please enter an explanation below and then press the <b>Submit problem report</b> button, to mail the report (and listing) to <i>" + MAIL_TO + "</i></p>"); |
out.println("<form enctype=\"text/plain\" method=\"post\" action=\"mailto:" + MAIL_TO + "\">"); |
out.println("<form enctype=\"text/plain\" method=\"post\" action=\"mailto:" + MAIL_TO + "\">"); |
out.println("<textarea cols=\"60\" rows=\"4\" name=\"report\"></textarea>"); |
out.println("<textarea cols=\"60\" rows=\"4\" name=\"report\"></textarea>"); |
out.println("<p><input type=\"hidden\" name=\"RDF\" value=\"<?xml version="1.0"?>" + rdf + "\">"); |
out.println("<p><input type=\"hidden\" name=\"RDF\" value=\"<?xml version="1.0"?>"); |
|
|
/* |
// The listing is being passed as a parameter so the '<' |
out.println(rdf + "\">"); |
// and '"' characters must be replaced with < and ", |
|
// respectively |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
String s1 = replaceString(rdf, "<", "<"); |
xmlns:DC="http://purl.org/dc/elements/1.0/"> |
String s2 = replaceString(s1, "\"", """); |
<rdf:Description |
out.println(s2 + "\">"); |
about="http://www.w3.org/RDF/Implementations/SiRPAC/"> |
|
<DC:Creator rdf:resource="http://www.w3.org/People/Janne/" /> |
|
<DC:Subject rdf:resource="XXXXXXXXXXX"/> |
|
</rdf:Description> |
|
</rdf:RDF> |
|
"> |
|
*/ |
|
|
|
out.println("<input type=\"submit\" value=\"Submit problem report\">"); |
out.println("<input type=\"submit\" value=\"Submit problem report\">"); |
out.println("</form>"); |
out.println("</form>"); |
Line 153 public class SiRPACServlet extends HttpS
|
Line 171 public class SiRPACServlet extends HttpS
|
out.println("</HTML>"); |
out.println("</HTML>"); |
|
|
} catch (Exception e) { |
} catch (Exception e) { |
// @@ |
System.err.println("Exception: " + e.getMessage()); |
} |
} |
|
|
} |
} |
Line 210 public class SiRPACServlet extends HttpS
|
Line 228 public class SiRPACServlet extends HttpS
|
|
|
m_sirpac.parse(is, consumer); |
m_sirpac.parse(is, consumer); |
|
|
|
generateGraph(out, sRDF); |
|
|
} catch (SAXException e) { |
} catch (SAXException e) { |
error = e.toString(); |
error = e.toString(); |
} catch (Exception e) { |
} catch (Exception e) { |
Line 223 public class SiRPACServlet extends HttpS
|
Line 243 public class SiRPACServlet extends HttpS
|
if (error != null) { |
if (error != null) { |
out.println ("<h1>Errors during parsing</h1>\n"); |
out.println ("<h1>Errors during parsing</h1>\n"); |
out.println ("<pre>\n"); |
out.println ("<pre>\n"); |
|
|
|
// Make the line number a link to the listing |
out.println ("Fatal error: " + m_errorHandler.getErrorMessage()); |
out.println ("Fatal error: " + m_errorHandler.getErrorMessage()); |
out.println (" (Line number = " + "<a href=\"#" + |
out.println (" (Line number = " + "<a href=\"#" + |
m_errorHandler.getLineNumber() + "\">" + |
m_errorHandler.getLineNumber() + "\">" + |