Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sesame 2.7.0-beta2 updates #16

Merged
merged 12 commits into from Feb 5, 2013
Merged
16 changes: 12 additions & 4 deletions core/src/main/java/org/semarglproject/source/SaxSource.java
Expand Up @@ -71,15 +71,23 @@ public void process(InputStream inputStream, String mimeType, String baseUri) th

private void initXmlReader() throws SAXException {
if (xmlReader == null) {
xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
xmlReader = getDefaultXmlReader();
}
xmlReader.setContentHandler(sink);
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", sink);
}

public void setXmlReader(XMLReader xmlReader) {
this.xmlReader = xmlReader;
public void setXmlReader(XMLReader xmlReader) throws SAXException {
if(xmlReader == null) {
this.xmlReader = getDefaultXmlReader();
} else {
this.xmlReader = xmlReader;
}
}

public static XMLReader getDefaultXmlReader() throws SAXException {
XMLReader result = XMLReaderFactory.createXMLReader();
result.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
return result;
}
}
Expand Up @@ -17,6 +17,7 @@

import org.semarglproject.rdf.ParseException;
import org.semarglproject.sink.DataSink;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;

import java.io.InputStream;
Expand Down Expand Up @@ -90,8 +91,14 @@ public void processInternal(Reader reader, String mimeType, String baseUri) thro
public boolean setProperty(String key, Object value) {
boolean result = false;
if (XML_READER_PROPERTY.equals(key) && value instanceof XMLReader && source instanceof SaxSource) {
((SaxSource) source).setXmlReader((XMLReader) value);
result = true;
try {
if (value != null) {
((SaxSource) source).setXmlReader((XMLReader) value);
result = true;
}
} catch(SAXException e) {
throw new IllegalArgumentException("XMLReader was not able to be initialized", e);
}
}
return sink.setProperty(key, value) || result;
}
Expand Down

This file was deleted.

This file was deleted.

@@ -0,0 +1,71 @@
/**
* Copyright 2012-2013 Lev Khomich
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.semarglproject.sesame.rdf.rdfa;

import org.openrdf.rio.ParserSetting;
import org.openrdf.rio.helpers.ParserSettingImpl;
import org.semarglproject.rdf.rdfa.RdfaParser;
import org.semarglproject.source.StreamProcessor;
import org.semarglproject.vocab.RDFa;
import org.xml.sax.XMLReader;

/**
* Settings specific to Semargl that are not in {@link org.openrdf.rio.helpers.BasicParserSettings}.
*
* @author Peter Ansell p_ansell@yahoo.com
* @since 0.5
*/
public final class SemarglParserSettings {

/**
* TODO: Javadoc this setting
* <p>
* Defaults to false
* @since 0.5
*/
public static final ParserSetting<Boolean> VOCAB_EXPANSION_ENABLED = new ParserSettingImpl<Boolean>(
RdfaParser.ENABLE_VOCAB_EXPANSION, "Vocabulary Expansion", Boolean.FALSE);

/**
* TODO: Javadoc this setting
* <p>
* Defaults to false
* @since 0.5
*/
public static final ParserSetting<Boolean> PROCESSOR_GRAPH_ENABLED = new ParserSettingImpl<Boolean>(
RdfaParser.ENABLE_PROCESSOR_GRAPH, "Vocabulary Expansion", Boolean.FALSE);

/**
* TODO: Javadoc this setting
* <p>
* Defaults to 1.1
* @since 0.5
*/
public static final ParserSetting<Short> RDFA_COMPATIBILITY = new ParserSettingImpl<Short>(
RdfaParser.RDFA_VERSION_PROPERTY, "RDFa Version Compatibility", RDFa.VERSION_11);

/**
* TODO: Javadoc this setting
* <p>
* Defaults to null
* @since 0.5
*/
public static final ParserSetting<XMLReader> CUSTOM_XML_READER = new ParserSettingImpl<XMLReader>(
StreamProcessor.XML_READER_PROPERTY, "Custom XML Reader", null);

private SemarglParserSettings() {
}
}