You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/02/21 16:30:44 UTC
[40/55] MARMOTTA-106: renamed sesame-rio modules
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/RDFaProfileHandler.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/RDFaProfileHandler.java b/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/RDFaProfileHandler.java
deleted file mode 100644
index 6ae4ae3..0000000
--- a/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/RDFaProfileHandler.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.sesame.rio.rdfa;
-
-import fi.tikesos.rdfa.core.datatype.Component;
-import fi.tikesos.rdfa.core.datatype.Language;
-import fi.tikesos.rdfa.core.datatype.Literal;
-import fi.tikesos.rdfa.core.exception.NullErrorHandler;
-import fi.tikesos.rdfa.core.parser.RDFaParser;
-import fi.tikesos.rdfa.core.parser.sax.SAXRDFaParser;
-import fi.tikesos.rdfa.core.profile.Profile;
-import fi.tikesos.rdfa.core.profile.ProfileHandler;
-import fi.tikesos.rdfa.core.triple.TripleSink;
-import fi.tikesos.rdfa.core.util.NullEntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A custom version of SimpleProfileHandler with a local cache of the most common profiles.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class RDFaProfileHandler implements ProfileHandler {
-
-
- private Map<String, Profile> profileCache = new HashMap<String, Profile>();
-
- public RDFaProfileHandler() {
- }
-
- /**
- * (non-Javadoc)
- *
- * @see fi.tikesos.rdfa.core.profile.ProfileHandler#loadProfile(java.lang.String)
- */
- @Override
- public Profile loadProfile(String profileURI) throws Exception {
- Profile profile = profileCache.get(profileURI);
- if (profile == null) {
- if(profileURI.equals(RDFaParser.XHTML_PROFILE)) {
- profile = new XHTMLProfile();
- } else if(profileURI.equals(RDFaParser.RDFA_PROFILE)) {
- profile = new RDFaProfile();
- } else {
- XMLReader reader = XMLReaderFactory.createXMLReader();
- ProfileTripleSink profileTripleSink = new ProfileTripleSink();
- SAXRDFaParser parser = new SAXRDFaParser(profileURI,
- profileTripleSink, null, new NullErrorHandler(),
- fi.tikesos.rdfa.core.parser.RDFaParser.XML_RDFA);
- // Disable validation
- reader.setFeature("http://xml.org/sax/features/validation",
- Boolean.FALSE);
- // Set processor to return namespaces as attributes
- reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
- Boolean.TRUE);
- // Set content handler
- reader.setContentHandler(parser);
- // Set entity resolver
- reader.setEntityResolver(new NullEntityResolver());
- // Parse the file
-
- reader.parse(new InputSource(new URI(profileURI).toURL().openStream()));
- profile = new SimpleProfile(profileTripleSink.getTermMappings(),
- profileTripleSink.getPrefixMappings(),
- profileTripleSink.getDefaultVocabulary());
- }
- // Cache profile
- profileCache.put(profileURI, profile);
- }
- return profile;
- }
-
- /**
- * Profile implementation for SimpleProfileLoader
- *
- * @author ssakorho
- *
- */
- private class SimpleProfile implements Profile {
- private String defaultVocabulary;
- private Map<String, String> termMappings;
- private Map<String, String> prefixMappings;
-
- public SimpleProfile(Map<String, String> termMappings,
- Map<String, String> prefixMappings, String defaultVocabulary) {
- this.termMappings = termMappings;
- this.prefixMappings = prefixMappings;
- this.defaultVocabulary = defaultVocabulary;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see fi.tikesos.rdfa.core.profile.Profile#getTermMappings()
- */
- @Override
- public Map<String, String> getTermMappings() {
- return termMappings;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see fi.tikesos.rdfa.core.profile.Profile#getPrefixMappings()
- */
- @Override
- public Map<String, String> getPrefixMappings() {
- return prefixMappings;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see fi.tikesos.rdfa.core.profile.Profile#getDefaultVocabulary()
- */
- @Override
- public String getDefaultVocabulary() {
- return defaultVocabulary;
- }
- }
-
- /**
- * TripleSink implementation for SimpleProfileLoader
- *
- * @author ssakorho
- *
- */
- private class ProfileTripleSink implements TripleSink {
- private final static String RDFA_NS = "http://www.w3.org/ns/rdfa#";
- private String defaultVocabulary = null;
- private Map<String, Map<String, String>> tripleMap = new HashMap<String, Map<String, String>>();
-
- /**
- * @return list of term and uri pairs
- */
- public Map<String, String> getTermMappings() {
- Map<String, String> termMappings = new HashMap<String, String>();
- for (Map.Entry<String, Map<String, String>> tripleEntry : tripleMap
- .entrySet()) {
- String term = tripleEntry.getValue().get("term");
- if (term != null && term.isEmpty() == false) {
- String uri = tripleEntry.getValue().get("uri");
- if (uri != null && uri.isEmpty() == false) {
- termMappings.put(term, uri);
- }
- }
- }
- return termMappings;
- }
-
- /**
- * @return the default vocabulary or null
- */
- public String getDefaultVocabulary() {
- return defaultVocabulary;
- }
-
- /**
- * @return list of prefix and uri pairs
- */
- public Map<String, String> getPrefixMappings() {
- Map<String, String> prefixMappings = new HashMap<String, String>();
- for (Map.Entry<String, Map<String, String>> tripleEntry : tripleMap
- .entrySet()) {
- String prefix = tripleEntry.getValue().get("prefix");
- if (prefix != null && prefix.isEmpty() == false) {
- String uri = tripleEntry.getValue().get("uri");
- if (uri != null && uri.isEmpty() == false) {
- prefixMappings.put(prefix, uri);
- }
- }
- }
- return prefixMappings;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see fi.tikesos.rdfa.core.triple.TripleSink#startRelativeTripleCaching()
- */
- @Override
- public void startRelativeTripleCaching() {
- }
-
- /**
- * (non-Javadoc)
- *
- * @see fi.tikesos.rdfa.core.triple.TripleSink#stopRelativeTripleCaching()
- */
- @Override
- public void stopRelativeTripleCaching() {
- }
-
- /**
- * (non-Javadoc)
- *
- */
- @Override
- public void generateTriple(Component subject, Component predicate,
- Component object) {
- // Ignored
- }
-
- /**
- * (non-Javadoc)
- *
- */
- @Override
- public void generateTripleLiteral(Component subject,
- Component predicate, Literal literal, Language language,
- Component datatype) {
- // Store triple to map, if it's of known type
- String type = null;
- if ((RDFA_NS + "uri").equals(predicate.getValue()) == true) {
- type = "uri";
- } else if ((RDFA_NS + "prefix").equals(predicate.getValue()) == true) {
- type = "prefix";
- } else if ((RDFA_NS + "term").equals(predicate.getValue()) == true) {
- type = "term";
- } else if ((RDFA_NS + "vocabulary").equals(predicate.getValue()) == true) {
- defaultVocabulary = literal.getValue();
- }
- if (type != null) {
- Map<String, String> valueMap = tripleMap
- .get(subject.getValue());
- if (valueMap == null) {
- valueMap = new HashMap<String, String>();
- tripleMap.put(subject.getValue(), valueMap);
- }
- valueMap.put(type, literal.getValue());
- }
- }
-
- /**
- * (non-Javadoc)
- *
- * @see fi.tikesos.rdfa.core.triple.TripleSink#generateTriple(java.lang.String
- * , java.lang.String, java.lang.String)
- */
- @Override
- public void generateTriple(String subject, String predicate,
- String object) {
- // NOT IMPLEMENTED
- throw new UnsupportedOperationException();
- }
-
- /**
- * (non-Javadoc)
- *
- */
- @Override
- public void generateTripleLiteral(String subject, String predicate,
- String lexical, String language, String datatype) {
- // NOT IMPLEMENTED
- throw new UnsupportedOperationException();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/XHTMLProfile.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/XHTMLProfile.java b/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/XHTMLProfile.java
deleted file mode 100644
index 9df7c59..0000000
--- a/commons/sesame-tools-rio-rdfa/src/main/java/at/newmedialab/sesame/rio/rdfa/XHTMLProfile.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.sesame.rio.rdfa;
-
-import com.google.common.collect.ImmutableMap;
-import fi.tikesos.rdfa.core.profile.Profile;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class XHTMLProfile implements Profile {
- public static final String NS = "http://www.w3.org/1999/xhtml/vocab#";
-
- private static Map<String,String> termMappings = new HashMap<String, String>();
- static {
- termMappings.put("alternate", NS+"alternate");
- termMappings.put("appendix", NS+"appendix");
- termMappings.put("bookmark", NS+"bookmark");
- termMappings.put("cite", NS+"cite");
- termMappings.put("chapter", NS+"chapter");
- termMappings.put("contents", NS+"contents");
- termMappings.put("copyright", NS+"copyright");
- termMappings.put("first", NS+"first");
- termMappings.put("glossary", NS+"glossary");
- termMappings.put("help", NS+"help");
- termMappings.put("icon", NS+"icon");
- termMappings.put("index", NS+"index");
- termMappings.put("itsRules", NS+"itsRules");
- termMappings.put("last", NS+"last");
- termMappings.put("license", NS+"license");
- termMappings.put("meta", NS+"meta");
- termMappings.put("next", NS+"next");
- termMappings.put("p3pv1", NS+"p3pv1");
- termMappings.put("prev", NS+"prev");
- termMappings.put("role", NS+"role");
- termMappings.put("section", NS+"section");
- termMappings.put("stylesheet", NS+"stylesheet");
- termMappings.put("subsection", NS+"subsection");
- termMappings.put("start", NS+"start");
- termMappings.put("top", NS+"top");
- termMappings.put("up", NS+"up");
- }
-
-
- private static Map<String,String> prefixMappings = new HashMap<String, String>();
- static {
- // official
- prefixMappings.put("grddl","http://www.w3.org/2003/g/data-view#");
- prefixMappings.put("ma", "http://www.w3.org/ns/ma-ont#");
- prefixMappings.put("owl", "http://www.w3.org/2002/07/owl#");
- prefixMappings.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
- prefixMappings.put("rdfa", "http://www.w3.org/ns/rdfa#");
- prefixMappings.put("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
- prefixMappings.put("rif", "http://www.w3.org/2007/rif#");
- prefixMappings.put("skos", "http://www.w3.org/2004/02/skos/core#");
- prefixMappings.put("skosxl","http://www.w3.org/2008/05/skos-xl#");
- prefixMappings.put("wdr", "http://www.w3.org/2007/05/powder#");
- prefixMappings.put("void", "http://rdfs.org/ns/void#");
- prefixMappings.put("wdrs", "http://www.w3.org/2007/05/powder-s#");
- prefixMappings.put("xhv", "http://www.w3.org/1999/xhtml/vocab#");
- prefixMappings.put("xml", "http://www.w3.org/XML/1998/namespace");
- prefixMappings.put("xsd", "http://www.w3.org/2001/XMLSchema#");
-
- // in-progress
-
- // commonly used
- prefixMappings.put("cc", "http://creativecommons.org/ns#");
- prefixMappings.put("ctag", "http://commontag.org/ns#");
- prefixMappings.put("dc", "http://purl.org/dc/elements/1.1/");
- prefixMappings.put("dcterms","http://purl.org/dc/terms/");
- prefixMappings.put("foaf", "http://xmlns.com/foaf/0.1/");
- prefixMappings.put("gr", "http://purl.org/goodrelations/v1#");
- prefixMappings.put("ical", "http://www.w3.org/2002/12/cal/icaltzd#");
- prefixMappings.put("og", "http://ogp.me/ns#");
- prefixMappings.put("rev", "http://purl.org/stuff/rev#");
- prefixMappings.put("sioc", "http://rdfs.org/sioc/ns#");
- prefixMappings.put("v", "http://rdf.data-vocabulary.org/#");
- prefixMappings.put("vcard", "http://www.w3.org/2006/vcard/ns#");
- prefixMappings.put("schema","http://schema.org/");
-
- }
-
-
- /**
- * @return Term mappings defined in the profile
- */
- @Override
- public Map<String, String> getTermMappings() {
- return ImmutableMap.copyOf(termMappings);
- }
-
- /**
- * @return Prefix mappings defined in the profile
- */
- @Override
- public Map<String, String> getPrefixMappings() {
- return ImmutableMap.copyOf(prefixMappings);
- }
-
- /**
- * @return Default vocabulary set in the profile or null
- */
- @Override
- public String getDefaultVocabulary() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParser.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParser.java b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParser.java
new file mode 100644
index 0000000..6b6f82a
--- /dev/null
+++ b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParser.java
@@ -0,0 +1,284 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.apache.marmotta.commons.sesame.rio.rdfa;
+
+import fi.tikesos.rdfa.core.datatype.Component;
+import fi.tikesos.rdfa.core.datatype.Language;
+import fi.tikesos.rdfa.core.datatype.Literal;
+import fi.tikesos.rdfa.core.exception.ErrorHandler;
+import fi.tikesos.rdfa.core.parser.sax.SAXRDFaParser;
+import fi.tikesos.rdfa.core.profile.ProfileHandler;
+import fi.tikesos.rdfa.core.profile.SimpleProfileHandler;
+import fi.tikesos.rdfa.core.triple.TripleSink;
+import fi.tikesos.rdfa.core.util.NullEntityResolver;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFHandlerException;
+import org.openrdf.rio.RDFParseException;
+import org.openrdf.rio.helpers.RDFParserBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+
+/**
+ * A Sesame RDFa parser based on the Tikesos parser.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class RDFaParser extends RDFParserBase implements TripleSink, ErrorHandler {
+
+ private Logger log = LoggerFactory.getLogger(RDFaParser.class);
+
+ private static ProfileHandler profileHandler = null;
+
+ private HashMap<String,Resource> anonResourceMap;
+
+ /**
+ * Creates a new RDFParserBase that will use a {@link org.openrdf.model.impl.ValueFactoryImpl} to
+ * create RDF model objects.
+ */
+ public RDFaParser() {
+ anonResourceMap = new HashMap<String, Resource>();
+ }
+
+ /**
+ * Creates a new RDFParserBase that will use the supplied ValueFactory to
+ * create RDF model objects.
+ *
+ * @param valueFactory A ValueFactory.
+ */
+ public RDFaParser(ValueFactory valueFactory) {
+ super(valueFactory);
+ anonResourceMap = new HashMap<String, Resource>();
+ }
+
+ /**
+ * Gets the RDF format that this parser can parse.
+ */
+ @Override
+ public RDFFormat getRDFFormat() {
+ return RDFFormat.RDFA;
+ }
+
+ /**
+ * Parses the data from the supplied InputStream, using the supplied baseURI
+ * to resolve any relative URI references.
+ *
+ * @param in The InputStream from which to read the data.
+ * @param baseURI The URI associated with the data in the InputStream.
+ * @throws java.io.IOException If an I/O error occurred while data was read from the InputStream.
+ * @throws org.openrdf.rio.RDFParseException
+ * If the parser has found an unrecoverable parse error.
+ * @throws org.openrdf.rio.RDFHandlerException
+ * If the configured statement handler has encountered an
+ * unrecoverable error.
+ */
+ @Override
+ public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
+ if(baseURI != null) {
+ setBaseURI(baseURI);
+ }
+
+ XMLReader reader;
+ try {
+ reader = XMLReaderFactory.createXMLReader();
+ reader.setFeature("http://xml.org/sax/features/validation",
+ Boolean.FALSE);
+ reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+ Boolean.TRUE);
+ reader.setEntityResolver(new NullEntityResolver());
+
+ if (profileHandler == null) {
+ profileHandler = new RDFaProfileHandler();
+ }
+
+ try {
+ ErrorHandler errorHandler = this;
+ ContentHandler parser = new SAXRDFaParser(baseURI, this,
+ profileHandler, errorHandler, fi.tikesos.rdfa.core.parser.RDFaParser.UNKNOWN_XML);
+ reader.setContentHandler(parser);
+ reader.parse(new InputSource(in));
+ } catch (IOException e) {
+ throw new RDFParseException(e);
+ } catch (URISyntaxException e) {
+ throw new RDFParseException(e);
+ }
+ } catch (SAXException e) {
+ throw new RDFParseException(e);
+ }
+
+ }
+
+ /**
+ * Parses the data from the supplied Reader, using the supplied baseURI to
+ * resolve any relative URI references.
+ *
+ * @param in The Reader from which to read the data.
+ * @param baseURI The URI associated with the data in the InputStream.
+ * @throws java.io.IOException If an I/O error occurred while data was read from the InputStream.
+ * @throws org.openrdf.rio.RDFParseException
+ * If the parser has found an unrecoverable parse error.
+ * @throws org.openrdf.rio.RDFHandlerException
+ * If the configured statement handler has encountered an
+ * unrecoverable error.
+ */
+ @Override
+ public void parse(Reader in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
+ if(baseURI != null) {
+ setBaseURI(baseURI);
+ }
+
+ XMLReader reader;
+ try {
+ reader = XMLReaderFactory.createXMLReader();
+ reader.setFeature("http://xml.org/sax/features/validation",
+ Boolean.FALSE);
+ reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+ Boolean.TRUE);
+ reader.setEntityResolver(new NullEntityResolver());
+
+ if (profileHandler == null) {
+ profileHandler = new RDFaProfileHandler();
+ }
+
+ try {
+ ErrorHandler errorHandler = this;
+ ContentHandler parser = new SAXRDFaParser(baseURI, this,
+ profileHandler, errorHandler, fi.tikesos.rdfa.core.parser.RDFaParser.UNKNOWN_XML);
+ reader.setContentHandler(parser);
+ reader.parse(new InputSource(in));
+ } catch (IOException e) {
+ throw new RDFParseException(e);
+ } catch (URISyntaxException e) {
+ throw new RDFParseException(e);
+ }
+ } catch (Exception e) {
+ throw new RDFParseException(e);
+ }
+ }
+
+
+
+ @Override
+ public void startRelativeTripleCaching() {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void stopRelativeTripleCaching() {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void generateTriple(Component component, Component component1, Component component2) {
+ generateTriple(component.getValue(),component1.getValue(),component2.getValue());
+ }
+
+ @Override
+ public void generateTriple(String s, String s1, String s2) {
+ try {
+ Resource subject = createResource(s);
+ URI property = createURI(s1);
+ Resource object = createResource(s2);
+
+ Statement statement = createStatement(subject,property,object);
+
+ rdfHandler.handleStatement(statement);
+ } catch (RDFParseException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (RDFHandlerException e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ @Override
+ public void generateTripleLiteral(Component component, Component component1, Literal literal, Language language, Component component2) {
+ generateTripleLiteral(component.getValue(),component1.getValue(),literal.getValue(), language != null ? language.getValue() : null, component2 != null ? component2.getValue() : null);
+ }
+
+ @Override
+ public void generateTripleLiteral(String subject, String predicate, String value, String language, String datatype) {
+ try {
+ Resource r_subject = createResource(subject);
+ URI r_property = createURI(predicate);
+ Value r_object;
+
+ if(datatype != null) {
+ r_object = createLiteral(value,null,createURI(datatype));
+ } else if(language != null) {
+ r_object = createLiteral(value,language,null);
+ } else {
+ r_object = createLiteral(value,null,null);
+ }
+
+ Statement statement = createStatement(r_subject,r_property,r_object);
+
+ rdfHandler.handleStatement(statement);
+ } catch (RDFParseException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (RDFHandlerException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+
+ @Override
+ public void warning(Exception exception) {
+ log.warn(exception.getMessage());
+ }
+
+ @Override
+ public void fatalError(Exception exception) {
+ log.error(exception.getMessage());
+
+ throw new IllegalStateException(exception);
+ }
+
+ private Resource createResource(String value) throws RDFParseException {
+ Resource resource;
+ if(value.startsWith("_:")) {
+ if(anonResourceMap.containsKey(value)) {
+ resource = anonResourceMap.get(value);
+ } else {
+ resource = createBNode();
+ anonResourceMap.put(value,resource);
+ }
+ } else {
+ resource = createURI(value);
+ }
+ return resource;
+ }
+
+
+ private static class LocalProfileHandler extends SimpleProfileHandler {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParserFactory.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParserFactory.java b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParserFactory.java
new file mode 100644
index 0000000..3b6e984
--- /dev/null
+++ b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaParserFactory.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.apache.marmotta.commons.sesame.rio.rdfa;
+
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.RDFParserFactory;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class RDFaParserFactory implements RDFParserFactory {
+
+ /**
+ * Returns the RDF format for this factory.
+ */
+ @Override
+ public RDFFormat getRDFFormat() {
+ return RDFFormat.RDFA;
+ }
+
+ /**
+ * Returns a RDFParser instance.
+ */
+ @Override
+ public RDFParser getParser() {
+ return new RDFaParser();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfile.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfile.java b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfile.java
new file mode 100644
index 0000000..399c88a
--- /dev/null
+++ b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfile.java
@@ -0,0 +1,103 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.apache.marmotta.commons.sesame.rio.rdfa;
+
+import com.google.common.collect.ImmutableMap;
+import fi.tikesos.rdfa.core.profile.Profile;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class RDFaProfile implements Profile {
+
+ public static final String NS = "http://www.w3.org/1999/xhtml/vocab#";
+
+ private static Map<String,String> termMappings = new HashMap<String, String>();
+ static {
+ termMappings.put("describedby", "http://www.w3.org/2007/05/powder-s#describedby");
+ termMappings.put("license", "http://www.w3.org/1999/xhtml/vocab#license");
+ termMappings.put("role", "http://www.w3.org/1999/xhtml/vocab#role");
+ }
+
+
+ private static Map<String,String> prefixMappings = new HashMap<String, String>();
+ static {
+ // official
+ prefixMappings.put("grddl","http://www.w3.org/2003/g/data-view#");
+ prefixMappings.put("ma", "http://www.w3.org/ns/ma-ont#");
+ prefixMappings.put("owl", "http://www.w3.org/2002/07/owl#");
+ prefixMappings.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ prefixMappings.put("rdfa", "http://www.w3.org/ns/rdfa#");
+ prefixMappings.put("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
+ prefixMappings.put("rif", "http://www.w3.org/2007/rif#");
+ prefixMappings.put("skos", "http://www.w3.org/2004/02/skos/core#");
+ prefixMappings.put("skosxl","http://www.w3.org/2008/05/skos-xl#");
+ prefixMappings.put("wdr", "http://www.w3.org/2007/05/powder#");
+ prefixMappings.put("void", "http://rdfs.org/ns/void#");
+ prefixMappings.put("wdrs", "http://www.w3.org/2007/05/powder-s#");
+ prefixMappings.put("xhv", "http://www.w3.org/1999/xhtml/vocab#");
+ prefixMappings.put("xml", "http://www.w3.org/XML/1998/namespace");
+ prefixMappings.put("xsd", "http://www.w3.org/2001/XMLSchema#");
+
+ // in-progress
+
+ // commonly used
+ prefixMappings.put("cc", "http://creativecommons.org/ns#");
+ prefixMappings.put("ctag", "http://commontag.org/ns#");
+ prefixMappings.put("dc", "http://purl.org/dc/elements/1.1/");
+ prefixMappings.put("dcterms","http://purl.org/dc/terms/");
+ prefixMappings.put("foaf", "http://xmlns.com/foaf/0.1/");
+ prefixMappings.put("gr", "http://purl.org/goodrelations/v1#");
+ prefixMappings.put("ical", "http://www.w3.org/2002/12/cal/icaltzd#");
+ prefixMappings.put("og", "http://ogp.me/ns#");
+ prefixMappings.put("rev", "http://purl.org/stuff/rev#");
+ prefixMappings.put("sioc", "http://rdfs.org/sioc/ns#");
+ prefixMappings.put("v", "http://rdf.data-vocabulary.org/#");
+ prefixMappings.put("vcard", "http://www.w3.org/2006/vcard/ns#");
+ prefixMappings.put("schema","http://schema.org/");
+
+ }
+
+ /**
+ * @return Term mappings defined in the profile
+ */
+ @Override
+ public Map<String, String> getTermMappings() {
+ return ImmutableMap.copyOf(termMappings);
+ }
+
+ /**
+ * @return Prefix mappings defined in the profile
+ */
+ @Override
+ public Map<String, String> getPrefixMappings() {
+ return ImmutableMap.copyOf(prefixMappings);
+ }
+
+ /**
+ * @return Default vocabulary set in the profile or null
+ */
+ @Override
+ public String getDefaultVocabulary() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfileHandler.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfileHandler.java b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfileHandler.java
new file mode 100644
index 0000000..f4456c9
--- /dev/null
+++ b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/RDFaProfileHandler.java
@@ -0,0 +1,277 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.apache.marmotta.commons.sesame.rio.rdfa;
+
+import fi.tikesos.rdfa.core.datatype.Component;
+import fi.tikesos.rdfa.core.datatype.Language;
+import fi.tikesos.rdfa.core.datatype.Literal;
+import fi.tikesos.rdfa.core.exception.NullErrorHandler;
+import fi.tikesos.rdfa.core.parser.RDFaParser;
+import fi.tikesos.rdfa.core.parser.sax.SAXRDFaParser;
+import fi.tikesos.rdfa.core.profile.Profile;
+import fi.tikesos.rdfa.core.profile.ProfileHandler;
+import fi.tikesos.rdfa.core.triple.TripleSink;
+import fi.tikesos.rdfa.core.util.NullEntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A custom version of SimpleProfileHandler with a local cache of the most common profiles.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class RDFaProfileHandler implements ProfileHandler {
+
+
+ private Map<String, Profile> profileCache = new HashMap<String, Profile>();
+
+ public RDFaProfileHandler() {
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see fi.tikesos.rdfa.core.profile.ProfileHandler#loadProfile(java.lang.String)
+ */
+ @Override
+ public Profile loadProfile(String profileURI) throws Exception {
+ Profile profile = profileCache.get(profileURI);
+ if (profile == null) {
+ if(profileURI.equals(RDFaParser.XHTML_PROFILE)) {
+ profile = new XHTMLProfile();
+ } else if(profileURI.equals(RDFaParser.RDFA_PROFILE)) {
+ profile = new RDFaProfile();
+ } else {
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ ProfileTripleSink profileTripleSink = new ProfileTripleSink();
+ SAXRDFaParser parser = new SAXRDFaParser(profileURI,
+ profileTripleSink, null, new NullErrorHandler(),
+ fi.tikesos.rdfa.core.parser.RDFaParser.XML_RDFA);
+ // Disable validation
+ reader.setFeature("http://xml.org/sax/features/validation",
+ Boolean.FALSE);
+ // Set processor to return namespaces as attributes
+ reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+ Boolean.TRUE);
+ // Set content handler
+ reader.setContentHandler(parser);
+ // Set entity resolver
+ reader.setEntityResolver(new NullEntityResolver());
+ // Parse the file
+
+ reader.parse(new InputSource(new URI(profileURI).toURL().openStream()));
+ profile = new SimpleProfile(profileTripleSink.getTermMappings(),
+ profileTripleSink.getPrefixMappings(),
+ profileTripleSink.getDefaultVocabulary());
+ }
+ // Cache profile
+ profileCache.put(profileURI, profile);
+ }
+ return profile;
+ }
+
+ /**
+ * Profile implementation for SimpleProfileLoader
+ *
+ * @author ssakorho
+ *
+ */
+ private class SimpleProfile implements Profile {
+ private String defaultVocabulary;
+ private Map<String, String> termMappings;
+ private Map<String, String> prefixMappings;
+
+ public SimpleProfile(Map<String, String> termMappings,
+ Map<String, String> prefixMappings, String defaultVocabulary) {
+ this.termMappings = termMappings;
+ this.prefixMappings = prefixMappings;
+ this.defaultVocabulary = defaultVocabulary;
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see fi.tikesos.rdfa.core.profile.Profile#getTermMappings()
+ */
+ @Override
+ public Map<String, String> getTermMappings() {
+ return termMappings;
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see fi.tikesos.rdfa.core.profile.Profile#getPrefixMappings()
+ */
+ @Override
+ public Map<String, String> getPrefixMappings() {
+ return prefixMappings;
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see fi.tikesos.rdfa.core.profile.Profile#getDefaultVocabulary()
+ */
+ @Override
+ public String getDefaultVocabulary() {
+ return defaultVocabulary;
+ }
+ }
+
+ /**
+ * TripleSink implementation for SimpleProfileLoader
+ *
+ * @author ssakorho
+ *
+ */
+ private class ProfileTripleSink implements TripleSink {
+ private final static String RDFA_NS = "http://www.w3.org/ns/rdfa#";
+ private String defaultVocabulary = null;
+ private Map<String, Map<String, String>> tripleMap = new HashMap<String, Map<String, String>>();
+
+ /**
+ * @return list of term and uri pairs
+ */
+ public Map<String, String> getTermMappings() {
+ Map<String, String> termMappings = new HashMap<String, String>();
+ for (Map.Entry<String, Map<String, String>> tripleEntry : tripleMap
+ .entrySet()) {
+ String term = tripleEntry.getValue().get("term");
+ if (term != null && term.isEmpty() == false) {
+ String uri = tripleEntry.getValue().get("uri");
+ if (uri != null && uri.isEmpty() == false) {
+ termMappings.put(term, uri);
+ }
+ }
+ }
+ return termMappings;
+ }
+
+ /**
+ * @return the default vocabulary or null
+ */
+ public String getDefaultVocabulary() {
+ return defaultVocabulary;
+ }
+
+ /**
+ * @return list of prefix and uri pairs
+ */
+ public Map<String, String> getPrefixMappings() {
+ Map<String, String> prefixMappings = new HashMap<String, String>();
+ for (Map.Entry<String, Map<String, String>> tripleEntry : tripleMap
+ .entrySet()) {
+ String prefix = tripleEntry.getValue().get("prefix");
+ if (prefix != null && prefix.isEmpty() == false) {
+ String uri = tripleEntry.getValue().get("uri");
+ if (uri != null && uri.isEmpty() == false) {
+ prefixMappings.put(prefix, uri);
+ }
+ }
+ }
+ return prefixMappings;
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see fi.tikesos.rdfa.core.triple.TripleSink#startRelativeTripleCaching()
+ */
+ @Override
+ public void startRelativeTripleCaching() {
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see fi.tikesos.rdfa.core.triple.TripleSink#stopRelativeTripleCaching()
+ */
+ @Override
+ public void stopRelativeTripleCaching() {
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ */
+ @Override
+ public void generateTriple(Component subject, Component predicate,
+ Component object) {
+ // Ignored
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ */
+ @Override
+ public void generateTripleLiteral(Component subject,
+ Component predicate, Literal literal, Language language,
+ Component datatype) {
+ // Store triple to map, if it's of known type
+ String type = null;
+ if ((RDFA_NS + "uri").equals(predicate.getValue()) == true) {
+ type = "uri";
+ } else if ((RDFA_NS + "prefix").equals(predicate.getValue()) == true) {
+ type = "prefix";
+ } else if ((RDFA_NS + "term").equals(predicate.getValue()) == true) {
+ type = "term";
+ } else if ((RDFA_NS + "vocabulary").equals(predicate.getValue()) == true) {
+ defaultVocabulary = literal.getValue();
+ }
+ if (type != null) {
+ Map<String, String> valueMap = tripleMap
+ .get(subject.getValue());
+ if (valueMap == null) {
+ valueMap = new HashMap<String, String>();
+ tripleMap.put(subject.getValue(), valueMap);
+ }
+ valueMap.put(type, literal.getValue());
+ }
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see fi.tikesos.rdfa.core.triple.TripleSink#generateTriple(java.lang.String
+ * , java.lang.String, java.lang.String)
+ */
+ @Override
+ public void generateTriple(String subject, String predicate,
+ String object) {
+ // NOT IMPLEMENTED
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ */
+ @Override
+ public void generateTripleLiteral(String subject, String predicate,
+ String lexical, String language, String datatype) {
+ // NOT IMPLEMENTED
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/XHTMLProfile.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/XHTMLProfile.java b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/XHTMLProfile.java
new file mode 100644
index 0000000..0cd4f9f
--- /dev/null
+++ b/commons/sesame-tools-rio-rdfa/src/main/java/org/apache/marmotta/commons/sesame/rio/rdfa/XHTMLProfile.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.apache.marmotta.commons.sesame.rio.rdfa;
+
+import com.google.common.collect.ImmutableMap;
+import fi.tikesos.rdfa.core.profile.Profile;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class XHTMLProfile implements Profile {
+ public static final String NS = "http://www.w3.org/1999/xhtml/vocab#";
+
+ private static Map<String,String> termMappings = new HashMap<String, String>();
+ static {
+ termMappings.put("alternate", NS+"alternate");
+ termMappings.put("appendix", NS+"appendix");
+ termMappings.put("bookmark", NS+"bookmark");
+ termMappings.put("cite", NS+"cite");
+ termMappings.put("chapter", NS+"chapter");
+ termMappings.put("contents", NS+"contents");
+ termMappings.put("copyright", NS+"copyright");
+ termMappings.put("first", NS+"first");
+ termMappings.put("glossary", NS+"glossary");
+ termMappings.put("help", NS+"help");
+ termMappings.put("icon", NS+"icon");
+ termMappings.put("index", NS+"index");
+ termMappings.put("itsRules", NS+"itsRules");
+ termMappings.put("last", NS+"last");
+ termMappings.put("license", NS+"license");
+ termMappings.put("meta", NS+"meta");
+ termMappings.put("next", NS+"next");
+ termMappings.put("p3pv1", NS+"p3pv1");
+ termMappings.put("prev", NS+"prev");
+ termMappings.put("role", NS+"role");
+ termMappings.put("section", NS+"section");
+ termMappings.put("stylesheet", NS+"stylesheet");
+ termMappings.put("subsection", NS+"subsection");
+ termMappings.put("start", NS+"start");
+ termMappings.put("top", NS+"top");
+ termMappings.put("up", NS+"up");
+ }
+
+
+ private static Map<String,String> prefixMappings = new HashMap<String, String>();
+ static {
+ // official
+ prefixMappings.put("grddl","http://www.w3.org/2003/g/data-view#");
+ prefixMappings.put("ma", "http://www.w3.org/ns/ma-ont#");
+ prefixMappings.put("owl", "http://www.w3.org/2002/07/owl#");
+ prefixMappings.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ prefixMappings.put("rdfa", "http://www.w3.org/ns/rdfa#");
+ prefixMappings.put("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
+ prefixMappings.put("rif", "http://www.w3.org/2007/rif#");
+ prefixMappings.put("skos", "http://www.w3.org/2004/02/skos/core#");
+ prefixMappings.put("skosxl","http://www.w3.org/2008/05/skos-xl#");
+ prefixMappings.put("wdr", "http://www.w3.org/2007/05/powder#");
+ prefixMappings.put("void", "http://rdfs.org/ns/void#");
+ prefixMappings.put("wdrs", "http://www.w3.org/2007/05/powder-s#");
+ prefixMappings.put("xhv", "http://www.w3.org/1999/xhtml/vocab#");
+ prefixMappings.put("xml", "http://www.w3.org/XML/1998/namespace");
+ prefixMappings.put("xsd", "http://www.w3.org/2001/XMLSchema#");
+
+ // in-progress
+
+ // commonly used
+ prefixMappings.put("cc", "http://creativecommons.org/ns#");
+ prefixMappings.put("ctag", "http://commontag.org/ns#");
+ prefixMappings.put("dc", "http://purl.org/dc/elements/1.1/");
+ prefixMappings.put("dcterms","http://purl.org/dc/terms/");
+ prefixMappings.put("foaf", "http://xmlns.com/foaf/0.1/");
+ prefixMappings.put("gr", "http://purl.org/goodrelations/v1#");
+ prefixMappings.put("ical", "http://www.w3.org/2002/12/cal/icaltzd#");
+ prefixMappings.put("og", "http://ogp.me/ns#");
+ prefixMappings.put("rev", "http://purl.org/stuff/rev#");
+ prefixMappings.put("sioc", "http://rdfs.org/sioc/ns#");
+ prefixMappings.put("v", "http://rdf.data-vocabulary.org/#");
+ prefixMappings.put("vcard", "http://www.w3.org/2006/vcard/ns#");
+ prefixMappings.put("schema","http://schema.org/");
+
+ }
+
+
+ /**
+ * @return Term mappings defined in the profile
+ */
+ @Override
+ public Map<String, String> getTermMappings() {
+ return ImmutableMap.copyOf(termMappings);
+ }
+
+ /**
+ * @return Prefix mappings defined in the profile
+ */
+ @Override
+ public Map<String, String> getPrefixMappings() {
+ return ImmutableMap.copyOf(prefixMappings);
+ }
+
+ /**
+ * @return Default vocabulary set in the profile or null
+ */
+ @Override
+ public String getDefaultVocabulary() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/resources/META-INF/services/org.openrdf.rio.RDFParserFactory
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/resources/META-INF/services/org.openrdf.rio.RDFParserFactory b/commons/sesame-tools-rio-rdfa/src/main/resources/META-INF/services/org.openrdf.rio.RDFParserFactory
index 451ebb9..1ebbe21 100644
--- a/commons/sesame-tools-rio-rdfa/src/main/resources/META-INF/services/org.openrdf.rio.RDFParserFactory
+++ b/commons/sesame-tools-rio-rdfa/src/main/resources/META-INF/services/org.openrdf.rio.RDFParserFactory
@@ -1 +1 @@
-at.newmedialab.sesame.rio.rdfa.RDFaParserFactory
\ No newline at end of file
+org.apache.marmotta.commons.sesame.rio.rdfa.RDFaParserFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/21a28cf8/commons/sesame-tools-rio-rdfa/src/main/resources/at/newmedialab/sesame/rio/rdfa/rdfa11-profile.html
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-rio-rdfa/src/main/resources/at/newmedialab/sesame/rio/rdfa/rdfa11-profile.html b/commons/sesame-tools-rio-rdfa/src/main/resources/at/newmedialab/sesame/rio/rdfa/rdfa11-profile.html
deleted file mode 100644
index ffa604a..0000000
--- a/commons/sesame-tools-rio-rdfa/src/main/resources/at/newmedialab/sesame/rio/rdfa/rdfa11-profile.html
+++ /dev/null
@@ -1,389 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2013 Salzburg Research.
-
- 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.
-
--->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
-<html
- xmlns="http://www.w3.org/1999/xhtml" version="RDFa 1.1">
-<head about="http://www.w3.org/profile/rdfa-1.1.html">
- <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
- <title>RDFa Core Initial Context</title>
- <link type="text/css" rel="stylesheet" href="/StyleSheets/TR/base.css"/>
- <style type="text/css">
- td:first-child + td a {
- color: darkGreen
- }
-
- td:first-child + td {
- color: darkGreen
- }
-
- td {
- border: inset 1pt;
- margin-bottom: 10ex;
- }
-
- th {
- text-align: center;
- font-weight: bold;
- background: lavender
- }
-
- tr:nth-child(even) {
- background: lavender
- }
-
- caption {
- font-weight: bold
- }
- </style>
-</head>
-<body about="http://www.w3.org/profile/rdfa-1.1" prefix="
- rdfa: http://www.w3.org/ns/rdfa# rdfs: http://www.w3.org/2000/01/rdf-schema#
- dcterms: http://purl.org/dc/terms/ foaf: http://xmlns.com/foaf/0.1/">
-<div class="head">
- <p><a href="http://www.w3.org/"> <img alt="W3C" src="http://www.w3.org/Icons/w3c_home"
- height="48" width="72"/> </a></p>
-
- <h1 property="dcterms:title">RDFa Core Initial Context</h1>
-</div>
-<h2>Vocabulary Prefixes</h2>
-<table>
- <caption>Vocabulary Prefixes of W3C Documents (Recommendations or Notes)</caption>
- <thead>
- <tr>
- <th>Prefix</th>
- <th>URI</th>
- <th>Description</th>
- <th>For more details see</th>
- <th>Origin</th>
- </tr>
- </thead>
- <tbody>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">grddl</td>
- <td property="rdfa:uri">http://www.w3.org/2003/g/data-view#</td>
- <td property="dcterms:description">GRDDL</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2009/REC-skos-reference-20090818/">Gleaning
- Resource Descriptions from Dialects of Languages (GRDDL)</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">ma</td>
- <td property="rdfa:uri">http://www.w3.org/ns/ma-ont#</td>
- <td property="dcterms:description">Ontology for Media Resources</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2012/REC-mediaont-10-20120209/">Ontology
- for Media Resources 1.0</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">owl</td>
- <td property="rdfa:uri">http://www.w3.org/2002/07/owl#</td>
- <td property="dcterms:description">OWL</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2009/REC-owl2-overview-20091027/">OWL
- Overview</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">rdf</td>
- <td property="rdfa:uri">http://www.w3.org/1999/02/22-rdf-syntax-ns#</td>
- <td property="dcterms:description">RDF</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2004/REC-rdf-mt-20040210/">RDF
- Semantics</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">rdfa</td>
- <td property="rdfa:uri">http://www.w3.org/ns/rdfa#</td>
- <td property="dcterms:description">RDFa Vocabulary</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/rdfa-core/">RDFa Core
- 1.1</a></td>
- <td>W3C Working Draft on Recommendation track</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">rdfs</td>
- <td property="rdfa:uri">http://www.w3.org/2000/01/rdf-schema#</td>
- <td property="dcterms:description">RDF Schema</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2004/REC-rdf-mt-20040210/">RDF
- Semantics</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">rif</td>
- <td property="rdfa:uri">http://www.w3.org/2007/rif#</td>
- <td property="dcterms:description">RIF</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2010/NOTE-rif-overview-20100622/">RIF
- Overview</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">skos</td>
- <td property="rdfa:uri">http://www.w3.org/2004/02/skos/core#</td>
- <td property="dcterms:description">SKOS Core</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2009/REC-skos-reference-20090818/">SKOS
- Simple Knowledge Organization System Reference</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">skosxl</td>
- <td property="rdfa:uri">http://www.w3.org/2008/05/skos-xl#</td>
- <td property="dcterms:description">SKOS eXtension for Labels</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2009/REC-skos-reference-20090818/">SKOS
- Simple Knowledge Organization System Reference</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">wdr</td>
- <td property="rdfa:uri">http://www.w3.org/2007/05/powder#</td>
- <td property="dcterms:description">POWDER</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2009/REC-powder-formal-20090901/">Protocol
- for Web Description Resources (POWDER): Formal Semantics</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">void</td>
- <td property="rdfa:uri">http://rdfs.org/ns/void#</td>
- <td property="dcterms:description">VoID</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/void/">Describing
- Linked Datasets with the VoID Vocabulary</a></td>
- <td>W3C Interest Group Note</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">wdrs</td>
- <td property="rdfa:uri">http://www.w3.org/2007/05/powder-s#</td>
- <td property="dcterms:description">POWDER-S</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2009/REC-powder-formal-20090901/">Protocol
- for Web Description Resources (POWDER): Formal Semantics</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">xhv</td>
- <td property="rdfa:uri">http://www.w3.org/1999/xhtml/vocab#</td>
- <td property="dcterms:description">RDFa Default Prefix</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/rdfa-core/">RDFa Core
- 1.1</a></td>
- <td>W3C Recommendation (although the reference is on RDFa 1.1, the vocabulary is
- already defined in RDFa 1.0)
- </td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">xml</td>
- <td property="rdfa:uri">http://www.w3.org/XML/1998/namespace</td>
- <td property="dcterms:description">XML Reserved Prefix</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/REC-xml-names/">Namespaces
- in XML 1.0</a></td>
- <td>W3C Recommendation</td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">xsd</td>
- <td property="rdfa:uri">http://www.w3.org/2001/XMLSchema#</td>
- <td property="dcterms:description">XML Schema Datatypes</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/xmlschema-2/">XML
- Schema Part 2: Datatypes Second Edition</a></td>
- <td>W3C Recommendation</td>
- </tr>
- </tbody>
-</table>
-<p>Some vocabularies are currently in development at W3C and they <em>may</em> become
- W3C Recommendations or Notes, i.e., may become part of the table above. It is
- therefore advisable to consider their prefixes reserved for now. These are:</p>
-<dl>
- <dt>sd</dt>
- <dd>for “http://www.w3.org/ns/sparql-service-description#”, see <a
- href="http://www.w3.org/TR/sparql11-service-description/">“SPARQL
- 1.1 Service Description”</a></dd>
- <dt>org</dt>
- <dd>for “http://www.w3.org/ns/org#”, see <a href="http://www.w3.org/TR/vocab-org/">“An
- organization ontology”</a></dd>
- <dt>gldp</dt>
- <dd>for “http://www.w3.org/ns/people#”, see <a href="http://www.w3.org/TR/vocab-people/">“Terms
- for describing people”</a></dd>
- <dt>cnt</dt>
- <dd>for “http://www.w3.org/2008/content#”, see <a href="http://www.w3.org/TR/Content-in-RDF10/">“Representing
- Content in RDF 1.0”</a></dd>
- <dt>dcat</dt>
- <dd>for “http://www.w3.org/ns/dcat#”, see <a href="http://www.w3.org/TR/vocab-dcat/">“Data
- Catalog Vocabulary (DCAT)”</a></dd>
- <dt>earl</dt>
- <dd>for “http://www.w3.org/ns/earl#”, see <a href="http://www.w3.org/TR/EARL10-Guide/">“Evaluation
- and Report Language (EARL) 1.0 Guide”</a></dd>
- <dt>ht</dt>
- <dd>for “http://www.w3.org/2006/http#”, see <a href="http://www.w3.org/TR/HTTP-in-RDF10/">“HTTP
- Vocabulary in RDF 1.0”</a></dd>
- <dt>ptr</dt>
- <dd>for “http://www.w3.org/2009/pointers#”, see <a href="http://www.w3.org/TR/Pointers-in-RDF10/">“Pointer
- Methods in RDF 1.0”</a></dd>
-</dl>
-<table style="margin-top: 10ex;" id="crawl">
- <caption>Widely used Vocabulary prefixes based on the <a href="/2010/02/rdfa/profile/data/">vocabulary
- usage on the Semantic Web</a></caption>
- <thead>
- <tr>
- <th>Prefix</th>
- <th>URI</th>
- <th>Description</th>
- <th>For more details see</th>
- </tr>
- </thead>
- <tbody>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">cc</td>
- <td property="rdfa:uri">http://creativecommons.org/ns#</td>
- <td property="dcterms:description">ccREL</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/Submission/2008/SUBM-ccREL-20080501/">ccREL:
- The Creative Commons Rights Expression Language</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">ctag</td>
- <td property="rdfa:uri">http://commontag.org/ns#</td>
- <td property="dcterms:description">Common Tag Ontology</td>
- <td><a rel="rdfs:isDefinedBy" href="http://commontag.org/Specification">Common
- Tag Specification</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">dc</td>
- <td property="rdfa:uri">http://purl.org/dc/terms/</td>
- <td property="dcterms:description">Dublin Core Metadata Terms</td>
- <td><a rel="rdfs:isDefinedBy" href="http://dublincore.org/documents/dcmi-terms/#H2">DCMI
- Metadata Terms</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">dcterms</td>
- <td property="rdfa:uri">http://purl.org/dc/terms/</td>
- <td property="dcterms:description">Dublin Core Metadata Terms</td>
- <td><a rel="rdfs:isDefinedBy" href="http://dublincore.org/documents/dcmi-terms/#H2">DCMI
- Metadata Terms</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">foaf</td>
- <td property="rdfa:uri">http://xmlns.com/foaf/0.1/</td>
- <td property="dcterms:description">FOAF</td>
- <td><a rel="rdfs:isDefinedBy" href="http://xmlns.com/foaf/spec/">FOAF Vocabulary
- Specification</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">gr</td>
- <td property="rdfa:uri">http://purl.org/goodrelations/v1#</td>
- <td property="dcterms:description">GoodRelations Ontology</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.heppnetz.de/ontologies/goodrelations/v1">GoodRelations
- Language Reference</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">ical</td>
- <td property="rdfa:uri">http://www.w3.org/2002/12/cal/icaltzd#</td>
- <td property="dcterms:description">iCalendar terms in RDF</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/2002/12/cal/icaltzd#">iCalendar
- terms in RDF</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">og</td>
- <td property="rdfa:uri">http://ogp.me/ns#</td>
- <td property="dcterms:description">Facebook's Open Graph protocol</td>
- <td><a rel="rdfs:isDefinedBy" href="http://ogp.me/">Open Graph Protocol</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">rev</td>
- <td property="rdfa:uri">http://purl.org/stuff/rev#</td>
- <td property="dcterms:description">RDF Review Vocabulary</td>
- <td><a rel="rdfs:isDefinedBy" href="http://vocab.org/review/terms.html">RDF
- Review Vocabulary</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">sioc</td>
- <td property="rdfa:uri">http://rdfs.org/sioc/ns#</td>
- <td property="dcterms:description">SIOC Core Ontology</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/Submission/2007/SUBM-sioc-spec-20070612/">SIOC
- Core Ontology Specification</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">v</td>
- <td property="rdfa:uri">http://rdf.data-vocabulary.org/#</td>
- <td property="dcterms:description">Google Rich Snippets' Vocabularies</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.google.com/support/webmasters/bin/answer.py?answer=99170">Rich
- snippets (microdata, microformats, and RDFa)</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">vcard</td>
- <td property="rdfa:uri">http://www.w3.org/2006/vcard/ns#</td>
- <td property="dcterms:description">vCard in RDF</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/Submission/2010/SUBM-vcard-rdf-20100120/">Representing
- vCard Objects in RDF</a></td>
- </tr>
- <tr typeof="rdfa:PrefixMapping">
- <td property="rdfa:prefix">schema</td>
- <td property="rdfa:uri">http://schema.org/</td>
- <td property="dcterms:description">The Schema.org vocabulary</td>
- <td><a rel="rdfs:isDefinedBy" href="http://schema.org/docs/full.html">Full
- Schema.org documentation</a></td>
- </tr>
- </tbody>
-</table>
-<h2>Vocabulary Terms</h2>
-<table>
- <caption>Terms defined by W3C Documents</caption>
- <thead>
- <tr>
- <th>Term</th>
- <th>URI</th>
- <th>Description</th>
- <th>For more details see</th>
- <th>Origin</th>
- </tr>
- </thead>
- <tbody>
- <tr typeof="rdfa:TermMapping">
- <td property="rdfa:term">describedby</td>
- <td property="rdfa:uri">http://www.w3.org/2007/05/powder-s#describedby</td>
- <td property="dcterms:description">Refers to resource providing a description.</td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/2009/REC-powder-formal-20090901/#pp">POWDER:
- Formal Semantics, Section 5, POWDER Processor Semantics</a></td>
- </tr>
- <tr typeof="rdfa:TermMapping">
- <td property="rdfa:term">license</td>
- <td property="rdfa:uri">http://www.w3.org/1999/xhtml/vocab#license</td>
- <!-- <td property='rdfa:uri'>http://creativecommons.org/ns#license</td> -->
- <td property="dcterms:description">Refers to a license associated with this
- context.
- </td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.iana.org/assignments/link-relations/link-relations.xml">IANA
- Link Relations</a></td>
- </tr>
- <tr typeof="rdfa:TermMapping">
- <td property="rdfa:term">role</td>
- <td property="rdfa:uri">http://www.w3.org/1999/xhtml/vocab#role</td>
- <td property="dcterms:description" datatype="">indicates the purpose of the
- resource. See the <a href="http://www.w3.org/1999/xhtml/vocab#XHTMLRoleVocabulary">XHTML
- Role Vocabulary</a> for roles in this vocabulary space
- </td>
- <td><a rel="rdfs:isDefinedBy" href="http://www.w3.org/TR/xhtml-role">XHTML Role
- Attribute Module</a></td>
- </tr>
- </tbody>
-</table>
-<hr />
-<address> <span rel="dcterms:creator"> <span about="http://www.ivan-herman.net/foaf#me"
- typeof="foaf:Person"> <span property="foaf:name" datatype=""><a
- href="http://www.w3.org/People/Ivan">Ivan
- Herman</a></span>, <a rel="foaf:mbox" href="mailto:ivan@w3.org">ivan@w3.org</a>,
- <a rel="foaf:workplaceHomepage" href="http://www.w3.org">W3C</a>, <span rel="rdfs:seeAlso"
- resource="http://www.ivan-herman.net/foaf"
- property="foaf:title">Semantic Web
- Activity Lead</span>, </span> </span> <span property="dcterms:date">2012-05-27</span>
- <br />
- <span>$Date: 2012/05/27 05:06:15 $</span></address>
-</body>
-</html>