Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 3207e986 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- Reimplented SAXParser.parse( uri ) to cover content negotiation

parent 8d50525f
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,11 @@ The utility may be invoked in the following way: ...@@ -116,6 +116,11 @@ The utility may be invoked in the following way:
<div class="terminal"> <div class="terminal">
$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter file:examples/rdf/newsample.rdf -r fr.inrialpes.exmo.align.impl.renderer.OWLAxiomsRendererVisitor $ java -cp lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter file:examples/rdf/newsample.rdf -r fr.inrialpes.exmo.align.impl.renderer.OWLAxiomsRendererVisitor
</div> </div>
It should work with files and with URIs, dereferenceable or not:
<div class="terminal">
$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter http://alignapi.gforge.inria.fr//tutorial/refalign.rdf
$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter http://aserv.inrialpes.fr/alid/1317289904908/444
</div>
</p> </p>
<h3>Translating queries</h3> <h3>Translating queries</h3>
......
...@@ -133,7 +133,7 @@ public class ParserPrinter extends CommonCLI { ...@@ -133,7 +133,7 @@ public class ParserPrinter extends CommonCLI {
System.exit(-1); System.exit(-1);
} }
//logger.trace("Filename: {}", initName); logger.trace("Filename: {}", initName);
try { try {
// Create parser // Create parser
......
...@@ -39,6 +39,8 @@ import java.io.InputStream; ...@@ -39,6 +39,8 @@ import java.io.InputStream;
import java.io.File; import java.io.File;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.lang.Integer; import java.lang.Integer;
import java.lang.Double; import java.lang.Double;
import java.util.Hashtable; import java.util.Hashtable;
...@@ -198,10 +200,16 @@ public class XMLParser extends DefaultHandler { ...@@ -198,10 +200,16 @@ public class XMLParser extends DefaultHandler {
* If the current process has links (import or include) to others documents then they are * If the current process has links (import or include) to others documents then they are
* parsed. * parsed.
* @param uri URI of the document to parse * @param uri URI of the document to parse
* Note: SAXParser has a parse( String uri ) method but it does not do content negotiation
* Hence we have to reimplement it (2014)
*/ */
public Alignment parse( String uri ) throws AlignmentException { public Alignment parse( String uri ) throws AlignmentException {
try { try {
parser.parse( uri, this ); // Reimplemented URI parsing because this does not do content negotiation
//parser.parse( uri, this );
URLConnection connection = new URL( uri ).openConnection();
connection.setRequestProperty( "Accept", "text/xml, application/rdf+xml" );
parser.parse( connection.getInputStream(), this );
} catch ( SAXException sex ) { } catch ( SAXException sex ) {
throw new AlignmentException( "Parsing error", sex ); throw new AlignmentException( "Parsing error", sex );
} catch ( IOException ioex ) { } catch ( IOException ioex ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment