pax_global_header 0000666 0000000 0000000 00000000064 12571703675 0014527 g ustar 00root root 0000000 0000000 52 comment=d48cb762056c1356c9575ffbeb91709f9cac0fd3
xmlcatalog-org.protege.xmlcatalog-1.0.5/ 0000775 0000000 0000000 00000000000 12571703675 0020250 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/.gitignore 0000664 0000000 0000000 00000000100 12571703675 0022227 0 ustar 00root root 0000000 0000000 #
# Maven
#
target
#
# Eclipse
#
.classpath
.project
.settings
xmlcatalog-org.protege.xmlcatalog-1.0.5/.travis.yml 0000664 0000000 0000000 00000000304 12571703675 0022356 0 ustar 00root root 0000000 0000000 language: java
jdk:
- oraclejdk7
- openjdk7
notifications:
email:
recipients:
- vendetti@stanford.edu
- tredmond@stanford.edu
on_success: never
on_failure: always
xmlcatalog-org.protege.xmlcatalog-1.0.5/LICENSE 0000664 0000000 0000000 00000016720 12571703675 0021263 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
xmlcatalog-org.protege.xmlcatalog-1.0.5/pom.xml 0000664 0000000 0000000 00000014202 12571703675 0021564 0 ustar 00root root 0000000 0000000
4.0.0org.sonatype.ossoss-parent7edu.stanford.protegeorg.protege.xmlcatalog1.0.5bundleXML Catalog Management ToolXML Catalog Management Toolhttp://protege.stanford.eduStanford Center for Biomedical Informatics Researchhttp://bmir.stanford.edu/GNU Lesser General Public Licensehttp://www.gnu.org/copyleft/lesser.htmlTimothy Redmondtredmond@stanford.eduprotege-userhttps://mailman.stanford.edu/mailman/listinfo/protege-userhttps://mailman.stanford.edu/mailman/listinfo/protege-userprotege-user@lists.stanford.eduhttp://protege-project.136.n4.nabble.com/https://mailman.stanford.edu/pipermail/protege-user/scm:git:git@github.com:protegeproject/xmlcatalog.gitscm:git:git@github.com:protegeproject/xmlcatalog.gitgit@github.com:protegeproject/xmlcatalog.gitUTF-8log4jlog4j[1.2.0,1.3)org.testngtestng5.10jdk15testxml-resolverxml-resolver1.2net.sourceforge.owlapiowlapi-osgidistribution[3.5.2,3.9)org.apache.maven.pluginsmaven-compiler-plugin3.21.61.6org.apache.felixmaven-bundle-plugin2.5.3trueorg.protege.xmlcatalogThe Protege Development Teamorg.protege.xmlcatalog.**.org.apache.maven.pluginsmaven-surefire-plugin2.13trueunit-teststesttestfalsesrc/test/resources/unit-tests.xmlmaven-pmd-plugin3.01.6prepare-releasefalseorg.apache.maven.pluginsmaven-source-plugin2.2.1attach-sourcesjarorg.apache.maven.pluginsmaven-javadoc-plugin2.9.1attach-javadocsjarorg.apache.maven.pluginsmaven-gpg-plugin1.5sign-artifactsverifysign
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/ 0000775 0000000 0000000 00000000000 12571703675 0021037 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/ 0000775 0000000 0000000 00000000000 12571703675 0021763 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/ 0000775 0000000 0000000 00000000000 12571703675 0022704 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/ 0000775 0000000 0000000 00000000000 12571703675 0023473 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/ 0000775 0000000 0000000 00000000000 12571703675 0025140 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/ 0000775 0000000 0000000 00000000000 12571703675 0027273 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/CatalogUtilities.java 0000664 0000000 0000000 00000007204 12571703675 0033407 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.TransformerException;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.exception.CatalogParseException;
import org.protege.xmlcatalog.parser.Handler;
import org.protege.xmlcatalog.redirect.UriRedirectVisitor;
import org.protege.xmlcatalog.write.XMLCatalogWriter;
import org.xml.sax.InputSource;
public class CatalogUtilities {
public static XMLCatalog parseDocument(URL catalog) throws IOException {
try {
URI xmlbase = catalog.toURI();
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
Handler handler = new Handler(xmlbase);
InputSource is = new InputSource(catalog.openStream());
is.setEncoding("UTF-8"); // is this necessary?
SAXParser parser = factory.newSAXParser();
parser.parse(is, handler);
return handler.getCatalog();
}
catch (Exception e) {
throw new CatalogParseException(e);
}
}
public static void save(XMLCatalog catalog, File f) throws IOException {
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
XMLCatalogWriter xwriter = new XMLCatalogWriter(catalog, writer);
try {
xwriter.write();
writer.flush();
writer.close();
}
catch (ParserConfigurationException pce) {
IOException ioe = new IOException("Error writing catalog to file " + f);
ioe.initCause(pce);
throw ioe;
}
catch (TransformerException te) {
IOException ioe = new IOException("Error writing catalog to file " + f);
ioe.initCause(te);
throw ioe;
}
}
public static URI getRedirect(URI original, XMLCatalog catalog) {
UriRedirectVisitor visitor = new UriRedirectVisitor(original);
for (Entry subEntry : catalog.getEntries()) {
subEntry.accept(visitor);
if (visitor.getRedirect() != null) {
break;
}
}
return visitor.getRedirect() == null ? null : visitor.getRedirect();
}
public static URI resolveXmlBase(XmlBaseContext context) {
URI xmlbase = null;
while (xmlbase == null && context != null) {
xmlbase = context.getXmlBase();
context = context.getXmlBaseContext();
}
if (!xmlbase.isAbsolute()) {
URI outerBase = resolveXmlBase(context);
xmlbase = outerBase.resolve(xmlbase);
}
return xmlbase;
}
public static URI relativize(URI u, XmlBaseContext context) {
URI xmlbase = resolveXmlBase(context);
if (xmlbase == null) {
return u;
}
String path = xmlbase.getPath();
int index;
if (path != null && (index = path.lastIndexOf("/")) != -1) {
path = path.substring(0, index + 1);
try {
xmlbase = new URI(xmlbase.getScheme(), xmlbase.getUserInfo(), xmlbase.getHost(), xmlbase.getPort(),
path, null, null);
}
catch (URISyntaxException e) {
;
}
}
return xmlbase.relativize(u);
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/EntryVisitor.java 0000664 0000000 0000000 00000001716 12571703675 0032624 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog;
import org.protege.xmlcatalog.entry.DelegatePublicEntry;
import org.protege.xmlcatalog.entry.DelegateSystemEntry;
import org.protege.xmlcatalog.entry.DelegateUriEntry;
import org.protege.xmlcatalog.entry.GroupEntry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
import org.protege.xmlcatalog.entry.PublicEntry;
import org.protege.xmlcatalog.entry.RewriteSystemEntry;
import org.protege.xmlcatalog.entry.RewriteUriEntry;
import org.protege.xmlcatalog.entry.SystemEntry;
import org.protege.xmlcatalog.entry.UriEntry;
public interface EntryVisitor {
void visit(GroupEntry entry);
void visit(PublicEntry entry);
void visit(SystemEntry entry);
void visit(RewriteSystemEntry entry);
void visit(DelegatePublicEntry entry);
void visit(DelegateSystemEntry entry);
void visit(UriEntry entry);
void visit(RewriteUriEntry entry);
void visit(DelegateUriEntry entry);
void visit(NextCatalogEntry entry);
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/Prefer.java 0000664 0000000 0000000 00000000543 12571703675 0031363 0 ustar 00root root 0000000 0000000 /**
*
*/
package org.protege.xmlcatalog;
import org.protege.xmlcatalog.parser.Handler;
public enum Prefer {
PUBLIC(Handler.PREFER_PUBLIC_VALUE), SYSTEM(Handler.PREFER_SYSTEM_VALUE);
private String name;
private Prefer(String name) {
this.name = name;
}
public String getName() {
return name;
}
} xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/XMLCatalog.java 0000664 0000000 0000000 00000003245 12571703675 0032075 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.parser.OuterXmlBaseContext;
public class XMLCatalog implements XmlBaseContext {
private XmlBaseContext context;
private Prefer prefer;
private URI xmlBase;
private List entries = new ArrayList();
public XMLCatalog(URI xmlBase) {
this(null, new OuterXmlBaseContext(xmlBase), Prefer.PUBLIC, null);
}
public XMLCatalog(String id, XmlBaseContext context, Prefer prefer, URI xmlBase) {
this.context = context;
this.prefer = prefer;
this.xmlBase = xmlBase;
}
public XmlBaseContext getXmlBaseContext() {
return context;
}
public void setXmlBaseContext(XmlBaseContext context) {
this.context = context;
}
public Prefer getPrefer() {
return prefer;
}
public void setPrefer(Prefer prefer) {
this.prefer = prefer;
}
public URI getXmlBase() {
return xmlBase;
}
public void setXmlBase(URI xmlBase) {
this.xmlBase = xmlBase;
}
public List getEntries() {
return new ArrayList(entries);
}
public void addEntry(Entry e) {
entries.add(e);
}
public void addEntry(int index, Entry e) {
entries.add(index, e);
}
public void removeEntry(Entry e) {
entries.remove(e);
}
public void replaceEntry(Entry original, Entry changed) {
int i = entries.indexOf(original);
entries.remove(original);
entries.add(i, changed);
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/XmlBaseContext.java 0000664 0000000 0000000 00000000301 12571703675 0033030 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog;
import java.net.URI;
public interface XmlBaseContext {
void setXmlBase(URI xmlbase);
URI getXmlBase();
XmlBaseContext getXmlBaseContext();
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry/ 0000775 0000000 0000000 00000000000 12571703675 0030434 5 ustar 00root root 0000000 0000000 AbstractDelegateEntry.java 0000664 0000000 0000000 00000003070 12571703675 0035440 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.XmlBaseContext;
import org.protege.xmlcatalog.XMLCatalog;
public abstract class AbstractDelegateEntry extends Entry implements XmlBaseContext {
private URI catalog;
private XMLCatalog delegate;
private URI xmlbase;
public AbstractDelegateEntry(String id, XmlBaseContext xmlBaseContext, URI catalog, URI xmlbase) {
super(id, xmlBaseContext);
this.catalog = catalog;
this.xmlbase = xmlbase;
}
public URI getCatalog() {
return catalog;
}
public void setCatalog(URI catalog) {
this.catalog = catalog;
}
public XMLCatalog getParsedCatalog() throws IOException {
if (delegate == null) {
try {
URI base = CatalogUtilities.resolveXmlBase(this);
URI doc = base.resolve(catalog);
delegate = CatalogUtilities.parseDocument(doc.toURL());
}
catch (MalformedURLException mue) {
IOException ioe = new IOException(mue.getMessage());
ioe.initCause(mue);
throw ioe;
}
}
return delegate;
}
public URI getXmlBase() {
return xmlbase;
}
public void setXmlBase(URI xmlbase) {
this.xmlbase = xmlbase;
}
public String toString() {
return "--> Delegate Catalog(@" + delegate.getXmlBase() + ")";
}
}
AbstractUriEntry.java 0000664 0000000 0000000 00000002334 12571703675 0034467 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.XmlBaseContext;
public abstract class AbstractUriEntry extends Entry implements XmlBaseContext {
private URI uri;
private URI xmlBase;
protected AbstractUriEntry(String id, XmlBaseContext context, URI uri, URI xmlBase) {
super(id, context);
this.uri = uri;
this.xmlBase = xmlBase;
}
public URI getUri() {
return uri;
}
public void setUri(URI uri) {
this.uri = uri;
}
public URI getXmlBase() {
return xmlBase;
}
public void setXmlBase(URI xmlbase) {
this.xmlBase = xmlbase;
}
public URI getAbsoluteURI() {
return AbstractUriEntry.resolveUriAgainstXmlBase(getUri(), this);
}
public static URI resolveUriAgainstXmlBase(URI relative, XmlBaseContext context) {
URI xmlbase = CatalogUtilities.resolveXmlBase(context);
if (xmlbase == null) {
return relative;
}
else {
return xmlbase.resolve(relative);
}
}
@Override
public String toString() {
return "--> " + getUri();
}
}
DelegatePublicEntry.java 0000664 0000000 0000000 00000001655 12571703675 0035122 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class DelegatePublicEntry extends AbstractDelegateEntry {
private String publicIdStartString;
public DelegatePublicEntry(String id, XmlBaseContext xmlBaseContext, String publicIdStartString, URI catalog, URI xmlbase) {
super(id, xmlBaseContext, catalog, xmlbase);
this.publicIdStartString = publicIdStartString;
}
public String getPublicIdStartString() {
return publicIdStartString;
}
public void setPublicIdStartString(String publicIdStartString) {
this.publicIdStartString = publicIdStartString;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
@Override
public String toString() {
return "Public " + publicIdStartString + super.toString();
}
}
DelegateSystemEntry.java 0000664 0000000 0000000 00000001661 12571703675 0035165 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class DelegateSystemEntry extends AbstractDelegateEntry {
private String systemIdStartString;
public DelegateSystemEntry(String id, XmlBaseContext xmlBaseContext, String systemIdStartString, URI catalog, URI xmlbase) {
super(id, xmlBaseContext, catalog, xmlbase);
this.systemIdStartString = systemIdStartString;
}
public String getSystemIdStartString() {
return systemIdStartString;
}
public void setSystemIdStartString(String systemIdStartString) {
this.systemIdStartString = systemIdStartString;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
@Override
public String toString() {
return "System " + systemIdStartString + super.toString();
}
}
DelegateUriEntry.java 0000664 0000000 0000000 00000001562 12571703675 0034440 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class DelegateUriEntry extends AbstractDelegateEntry {
private String uriStartString;
public DelegateUriEntry(String id, XmlBaseContext xmlBaseContext, String uriStartString, URI catalog, URI xmlbase) {
super(id, xmlBaseContext, catalog, xmlbase);
this.uriStartString = uriStartString;
}
public String getUriStartString() {
return uriStartString;
}
public void setUriStartString(String uriStartString) {
this.uriStartString = uriStartString;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
@Override
public String toString() {
return "Uri " + uriStartString + super.toString();
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry/Entry.java 0000664 0000000 0000000 00000001210 12571703675 0032372 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.entry;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public abstract class Entry {
private String id;
private XmlBaseContext xmlBaseContext;
protected Entry(String id, XmlBaseContext xmlBaseContext) {
super();
this.id = id;
this.xmlBaseContext = xmlBaseContext;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public XmlBaseContext getXmlBaseContext() {
return xmlBaseContext;
}
public abstract void accept(EntryVisitor visitor);
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry/GroupEntry.java 0000664 0000000 0000000 00000002673 12571703675 0033425 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.entry;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.Prefer;
import org.protege.xmlcatalog.XmlBaseContext;
public class GroupEntry extends Entry implements XmlBaseContext {
private Prefer prefer;
private URI xmlBase;
private List entries = new ArrayList();
public GroupEntry(String id, XmlBaseContext xmlBaseContext, Prefer prefer, URI xmlBase) {
super(id, xmlBaseContext);
this.prefer = prefer;
this.xmlBase = xmlBase;
}
public Prefer getPrefer() {
return prefer;
}
public void setPrefer(Prefer prefer) {
this.prefer = prefer;
}
public URI getXmlBase() {
return xmlBase;
}
public void setXmlBase(URI xmlBase) {
this.xmlBase = xmlBase;
}
public List getEntries() {
return new ArrayList(entries);
}
public void addEntry(Entry e) {
entries.add(e);
}
public void addEntry(int index, Entry e) {
entries.add(index, e);
}
public void removeEntry(Entry e) {
entries.remove(e);
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
@Override
public String toString() {
return "Group Entry(" + getId() + ") with " + entries.size() + " entries";
}
}
NextCatalogEntry.java 0000664 0000000 0000000 00000000740 12571703675 0034454 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class NextCatalogEntry extends AbstractDelegateEntry {
public NextCatalogEntry(String id, XmlBaseContext xmlBaseContext, URI catalog, URI xmlbase) {
super(id, xmlBaseContext, catalog, xmlbase);
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry/PublicEntry.java 0000664 0000000 0000000 00000001453 12571703675 0033542 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class PublicEntry extends AbstractUriEntry {
private String publicId;
public PublicEntry(String id, XmlBaseContext xmlBaseContext, String publicId, URI uri, URI xmlbase) {
super(id, xmlBaseContext, uri, xmlbase);
this.publicId = publicId;
}
public String getPublicId() {
return publicId;
}
public void setPublicId(String publicId) {
this.publicId = publicId;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
@Override
public String toString() {
return "Public id " + getPublicId() + super.toString();
}
}
RewriteSystemEntry.java 0000664 0000000 0000000 00000002013 12571703675 0035064 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class RewriteSystemEntry extends Entry {
private String systemIdStartString;
private URI rewritePrefix;
public RewriteSystemEntry(String id, XmlBaseContext xmlBaseContext, String systemIdStartString, URI rewritePrefix) {
super(id, xmlBaseContext);
this.systemIdStartString = systemIdStartString;
this.rewritePrefix = rewritePrefix;
}
public String getSystemIdStartString() {
return systemIdStartString;
}
public void setSystemIdStartString(String systemIdStartString) {
this.systemIdStartString = systemIdStartString;
}
public URI getRewritePrefix() {
return rewritePrefix;
}
public void setRewritePrefix(URI rewritePrefix) {
this.rewritePrefix = rewritePrefix;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
}
RewriteUriEntry.java 0000664 0000000 0000000 00000001724 12571703675 0034347 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class RewriteUriEntry extends Entry {
private String uriStartString;
private URI rewritePrefix;
public RewriteUriEntry(String id, XmlBaseContext xmlBaseContext, String uriStartString, URI rewritePrefix) {
super(id, xmlBaseContext);
this.uriStartString = uriStartString;
this.rewritePrefix = rewritePrefix;
}
public String getUriStartString() {
return uriStartString;
}
public void setUriStartString(String uriStartString) {
this.uriStartString = uriStartString;
}
public URI getRewritePrefix() {
return rewritePrefix;
}
public void setRewritePrefix(URI rewritePrefix) {
this.rewritePrefix = rewritePrefix;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry/SystemEntry.java 0000664 0000000 0000000 00000001257 12571703675 0033612 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class SystemEntry extends AbstractUriEntry {
private String systemId;
public SystemEntry(String id, XmlBaseContext xmlBaseContext, String systemId, URI uri, URI xmlbase) {
super(id, xmlBaseContext, uri, xmlbase);
this.systemId = systemId;
}
public String getSystemId() {
return systemId;
}
public void setSystemId(String systemId) {
this.systemId = systemId;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/entry/UriEntry.java 0000664 0000000 0000000 00000001332 12571703675 0033057 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.entry;
import java.net.URI;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
public class UriEntry extends AbstractUriEntry {
private String name;
public UriEntry(String id, XmlBaseContext xmlBaseContext, String name, URI uri, URI xmlbase) {
super(id, xmlBaseContext, uri, xmlbase);
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public void accept(EntryVisitor visitor) {
visitor.visit(this);
}
@Override
public String toString() {
return name + super.toString();
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/exception/ 0000775 0000000 0000000 00000000000 12571703675 0031271 5 ustar 00root root 0000000 0000000 CatalogParseException.java 0000664 0000000 0000000 00000000755 12571703675 0036310 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/exception package org.protege.xmlcatalog.exception;
import java.io.IOException;
public class CatalogParseException extends IOException {
private static final long serialVersionUID = -2087487036403016848L;
public CatalogParseException() {
}
public CatalogParseException(String msg) {
super(msg);
}
public CatalogParseException(Throwable t) {
super(t.getMessage());
initCause(t);
}
public CatalogParseException(String msg, Throwable t) {
super(msg);
initCause(t);
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/owlapi/ 0000775 0000000 0000000 00000000000 12571703675 0030566 5 ustar 00root root 0000000 0000000 XMLCatalogIRIMapper.java 0000664 0000000 0000000 00000001556 12571703675 0035025 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/owlapi package org.protege.xmlcatalog.owlapi;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.XMLCatalog;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyIRIMapper;
public class XMLCatalogIRIMapper implements OWLOntologyIRIMapper {
private XMLCatalog catalog;
public XMLCatalogIRIMapper(File f) throws MalformedURLException, IOException {
this(CatalogUtilities.parseDocument(f.toURI().toURL()));
}
public XMLCatalogIRIMapper(XMLCatalog catalog) {
this.catalog = catalog;
}
@Override
public IRI getDocumentIRI(IRI original) {
URI redirect = CatalogUtilities.getRedirect(original.toURI(), catalog);
if (redirect != null) {
return IRI.create(redirect);
}
else return null;
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/parser/ 0000775 0000000 0000000 00000000000 12571703675 0030567 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/parser/Handler.java 0000664 0000000 0000000 00000023650 12571703675 0033015 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.parser;
import java.net.URI;
import java.util.Stack;
import org.apache.log4j.Logger;
import org.protege.xmlcatalog.Prefer;
import org.protege.xmlcatalog.XMLCatalog;
import org.protege.xmlcatalog.XmlBaseContext;
import org.protege.xmlcatalog.entry.DelegatePublicEntry;
import org.protege.xmlcatalog.entry.DelegateSystemEntry;
import org.protege.xmlcatalog.entry.DelegateUriEntry;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.entry.GroupEntry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
import org.protege.xmlcatalog.entry.PublicEntry;
import org.protege.xmlcatalog.entry.RewriteSystemEntry;
import org.protege.xmlcatalog.entry.RewriteUriEntry;
import org.protege.xmlcatalog.entry.SystemEntry;
import org.protege.xmlcatalog.entry.UriEntry;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class Handler extends DefaultHandler {
private static final Logger logger = Logger.getLogger(Handler.class);
public final static String CATALOG_NAMESPACE = "urn:oasis:names:tc:entity:xmlns:xml:catalog";
/* *********************** Elements *********************** */
public final static String CATALOG_ELEMENT = "catalog";
public final static String GROUP_ELEMENT = "group";
public final static String PUBLIC_ELEMENT = "public";
public final static String SYSTEM_ELEMENT = "system";
public final static String REWRITE_SYSTEM_ELEMENT = "rewriteSystem";
public final static String DELEGATE_PUBLIC_ELEMENT = "delegatePublic";
public final static String DELEGATE_SYSTEM_ELEMENT = "delegateSystem";
public final static String URI_ELEMENT = "uri";
public final static String REWRITE_URI_ELEMENT = "rewriteURI";
public final static String DELEGATE_URI_ELEMENT = "delegateURI";
public final static String NEXT_CATALOG_ELEMENT = "nextCatalog";
/* *********************** Attributes *********************** */
public final static String ID_ATTRIBUTE = "id";
public final static String PREFER_ATTRIBUTE = "prefer";
public final static String XML_BASE_ATTRIBUTE = "xml:base";
/* public element */
public final static String PUBLIC_ID_ATTRIBUTE = "publicId";
public final static String URI_ATTRIBUTE = "uri";
/* system element */
public final static String SYSTEM_ID_ATTRIBUTE = "systemId";
/* rewriteSystem element */
public final static String SYSTEM_ID_START_ATTRIBUTE = "systemIdStartString";
public final static String REWRITE_PREFIX_ATTRIBUTE = "rewritePrefix";
/* delegatePublic element */
public final static String PUBLIC_ID_START_ATTRIBUTE = "publicIdStartString";
/* uri element */
public final static String URI_NAME_ATTRIBUTE = "name";
/* rewriteURI element */
public final static String URI_START_STRING = "uriStartString";
/* nextCatalog element */
public final static String CATALOG_ATTRIBUTE = "catalog";
/* *********************** Values *********************** */
/* public element */
public final static String PREFER_PUBLIC_VALUE = "public";
public final static String PREFER_SYSTEM_VALUE = "system";
private XMLCatalog catalog;
private XmlBaseContext outerContext;
private Stack groupStack = new Stack();
public Handler() {
}
public Handler(URI xmlbase) {
this(new OuterXmlBaseContext(xmlbase));
}
public Handler(XmlBaseContext context) {
outerContext = context;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (!CATALOG_NAMESPACE.equals(uri)) {
logger.warn("Found entry outside the XML Catalogs namespace - ignored");
}
else if (localName.equals(CATALOG_ELEMENT)) {
catalog = new XMLCatalog(getId(attributes), outerContext, getPrefer(attributes), getXmlBase(attributes));
}
else if (localName.equals(GROUP_ELEMENT)) {
GroupEntry group = new GroupEntry(getId(attributes), getXmlBaseContext(), getPrefer(attributes), getXmlBase(attributes));
addEntry(group);
groupStack.push(group);
}
else if (localName.equals(PUBLIC_ELEMENT)) {
addEntry(new PublicEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(PUBLIC_ID_ATTRIBUTE),
URI.create(attributes.getValue(URI_ATTRIBUTE)),
getXmlBase(attributes)));
}
else if (localName.equals(SYSTEM_ELEMENT)) {
addEntry(new SystemEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(SYSTEM_ID_ATTRIBUTE),
URI.create(attributes.getValue(URI_ATTRIBUTE)),
getXmlBase(attributes)));
}
else if (localName.equals(REWRITE_SYSTEM_ELEMENT)) {
addEntry(new RewriteSystemEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(SYSTEM_ID_START_ATTRIBUTE),
URI.create(attributes.getValue(REWRITE_PREFIX_ATTRIBUTE))));
}
else if (localName.equals(DELEGATE_PUBLIC_ELEMENT)) {
addEntry(new DelegatePublicEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(PUBLIC_ID_START_ATTRIBUTE),
URI.create(attributes.getValue(CATALOG_ATTRIBUTE)),
getXmlBase(attributes)));
}
else if (localName.equals(DELEGATE_SYSTEM_ELEMENT)) {
addEntry(new DelegateSystemEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(SYSTEM_ID_START_ATTRIBUTE),
URI.create(attributes.getValue(CATALOG_ATTRIBUTE)),
getXmlBase(attributes)));
}
else if (localName.equals(URI_ELEMENT)) {
addEntry(new UriEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(URI_NAME_ATTRIBUTE),
URI.create(attributes.getValue(URI_ATTRIBUTE)),
getXmlBase(attributes)));
}
else if (localName.equals(REWRITE_URI_ELEMENT)) {
addEntry(new RewriteUriEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(URI_START_STRING),
URI.create(attributes.getValue(REWRITE_PREFIX_ATTRIBUTE))));
}
else if (localName.equals(DELEGATE_URI_ELEMENT)) {
addEntry(new DelegateUriEntry(getId(attributes),
getXmlBaseContext(),
attributes.getValue(URI_START_STRING),
URI.create(attributes.getValue(CATALOG_ATTRIBUTE)),
getXmlBase(attributes)));
}
else if (localName.equals(NEXT_CATALOG_ELEMENT)) {
addEntry(new NextCatalogEntry(getId(attributes),
getXmlBaseContext(),
URI.create(attributes.getValue(CATALOG_ATTRIBUTE)),
getXmlBase(attributes)));
}
else {
logger.error("Found unsupported element in xmlcatalog: " + localName);
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (uri.equals(CATALOG_NAMESPACE) && localName.equals(GROUP_ELEMENT)) {
groupStack.pop();
}
}
public XMLCatalog getCatalog() {
return catalog;
}
private void addEntry(Entry entry) {
if (groupStack.isEmpty()) {
catalog.addEntry(entry);
}
else {
groupStack.peek().addEntry(entry);
}
}
private String getId(Attributes attributes) {
return attributes.getValue(ID_ATTRIBUTE);
}
private Prefer getPrefer() {
if (groupStack.isEmpty()) {
return catalog.getPrefer();
}
else {
return groupStack.peek().getPrefer();
}
}
private Prefer getPrefer(Attributes attributes) {
String preferString = attributes.getValue(PREFER_ATTRIBUTE);
if (preferString == null && catalog == null) {
return null;
}
else if (preferString == null) {
return getPrefer();
}
else if (preferString.toLowerCase().equals(PREFER_PUBLIC_VALUE)) {
return Prefer.PUBLIC;
}
else if (preferString.toLowerCase().equals(PREFER_SYSTEM_VALUE)) {
return Prefer.SYSTEM;
}
else {
return null;
}
}
private URI getXmlBase(Attributes attributes) {
String baseString = attributes.getValue(XML_BASE_ATTRIBUTE);
if (baseString != null) {
return URI.create(baseString);
}
else {
return null;
}
}
private XmlBaseContext getXmlBaseContext() {
if (groupStack.isEmpty()) {
return catalog;
}
else {
return groupStack.peek();
}
}
}
OuterXmlBaseContext.java 0000664 0000000 0000000 00000000771 12571703675 0035277 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/parser package org.protege.xmlcatalog.parser;
import java.net.URI;
import org.protege.xmlcatalog.XmlBaseContext;
public class OuterXmlBaseContext implements XmlBaseContext {
private URI xmlbase;
public OuterXmlBaseContext(URI xmlbase) {
this.xmlbase = xmlbase;
}
public URI getXmlBase() {
return xmlbase;
}
public XmlBaseContext getXmlBaseContext() {
return null;
}
public void setXmlBase(URI xmlbase) {
this.xmlbase = xmlbase;
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/redirect/ 0000775 0000000 0000000 00000000000 12571703675 0031074 5 ustar 00root root 0000000 0000000 UriRedirectVisitor.java 0000664 0000000 0000000 00000006353 12571703675 0035470 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/redirect package org.protege.xmlcatalog.redirect;
import java.io.IOException;
import java.net.URI;
import org.apache.log4j.Logger;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XMLCatalog;
import org.protege.xmlcatalog.entry.DelegatePublicEntry;
import org.protege.xmlcatalog.entry.DelegateSystemEntry;
import org.protege.xmlcatalog.entry.DelegateUriEntry;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.entry.GroupEntry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
import org.protege.xmlcatalog.entry.PublicEntry;
import org.protege.xmlcatalog.entry.RewriteSystemEntry;
import org.protege.xmlcatalog.entry.RewriteUriEntry;
import org.protege.xmlcatalog.entry.SystemEntry;
import org.protege.xmlcatalog.entry.UriEntry;
public class UriRedirectVisitor implements EntryVisitor {
private static Logger log = Logger.getLogger(UriRedirectVisitor.class);
private URI original;
private URI redirect;
public UriRedirectVisitor(URI original) {
this.original = original;
}
public URI getRedirect() {
return redirect;
}
public void visit(GroupEntry entry) {
for (Entry subEntry : entry.getEntries()) {
subEntry.accept(this);
if (redirect != null) {
break;
}
}
}
public void visit(PublicEntry entry) {
;
}
public void visit(SystemEntry entry) {
;
}
public void visit(RewriteSystemEntry entry) {
;
}
public void visit(DelegatePublicEntry entry) {
;
}
public void visit(DelegateSystemEntry entry) {
;
}
public void visit(UriEntry entry) {
if (original.equals(URI.create(entry.getName()))) {
redirect = entry.getAbsoluteURI();
}
}
public void visit(RewriteUriEntry entry) {
try {
String originalString = original.toString();
if (originalString.startsWith(entry.getUriStartString())) {
String suffix = originalString.substring(entry.getUriStartString().length());
redirect = URI.create(entry.getRewritePrefix().toString() + suffix);
}
}
catch (Throwable e) {
log.error("Exception caught trying to resolve " + original, e);
}
}
public void visit(DelegateUriEntry entry) {
try {
if (original.isAbsolute()) {
String originalString = original.toString();
if (originalString.startsWith(entry.getUriStartString())) {
visitCatalog(entry.getParsedCatalog());
}
}
}
catch (IOException ioe) {
log.error("Exception caught trying to resolve " + original, ioe);
}
}
public void visit(NextCatalogEntry entry) {
try {
visitCatalog(entry.getParsedCatalog());
}
catch (IOException ioe) {
log.error("Exception caught trying to resolve " + original, ioe);
}
}
private void visitCatalog(XMLCatalog catalog) {
for (Entry subEntry : catalog.getEntries()) {
subEntry.accept(this);
if (redirect != null) {
break;
}
}
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing/ 0000775 0000000 0000000 00000000000 12571703675 0030422 5 ustar 00root root 0000000 0000000 AltCellRenderer.java 0000664 0000000 0000000 00000005312 12571703675 0034216 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing package org.protege.xmlcatalog.swing;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.entry.DelegatePublicEntry;
import org.protege.xmlcatalog.entry.DelegateSystemEntry;
import org.protege.xmlcatalog.entry.DelegateUriEntry;
import org.protege.xmlcatalog.entry.GroupEntry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
import org.protege.xmlcatalog.entry.PublicEntry;
import org.protege.xmlcatalog.entry.RewriteSystemEntry;
import org.protege.xmlcatalog.entry.RewriteUriEntry;
import org.protege.xmlcatalog.entry.SystemEntry;
import org.protege.xmlcatalog.entry.UriEntry;
public class AltCellRenderer extends DefaultTreeCellRenderer {
private static final long serialVersionUID = 5872637762761958584L;
private EntryRenderingVisitor visitor = new EntryRenderingVisitor();
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof CatalogTreeNode) {
label.setText("" + ((CatalogTreeNode) value).getCatalog().getXmlBase());
} else {
EntryTreeNode node = (EntryTreeNode) value;
if (node.getEditor() != null) {
label.setText(node.getEditor().getDescription(node.getEntry()));
} else {
node.getEntry().accept(visitor);
label.setText(visitor.getText());
}
}
if (selected) {
label.setBackground(backgroundSelectionColor);
} else {
label.setBackground(backgroundNonSelectionColor);
}
return label;
}
private class EntryRenderingVisitor implements EntryVisitor {
private String text;
public String getText() {
return text;
}
public void visit(GroupEntry entry) {
text = "Group Entry";
}
public void visit(PublicEntry entry) {
text = "Not implemented yet";
}
public void visit(SystemEntry entry) {
text = "Not implemented yet";
}
public void visit(RewriteSystemEntry entry) {
text = "Not implemented yet";
}
public void visit(DelegatePublicEntry entry) {
text = "Not implemented yet";
}
public void visit(DelegateSystemEntry entry) {
text = "Not implemented yet";
}
public void visit(UriEntry entry) {
text = entry.getName() + " \u2192 " + entry.getUri();
}
public void visit(RewriteUriEntry entry) {
text = "Not implemented yet";
}
public void visit(DelegateUriEntry entry) {
text = "Not implemented yet";
}
public void visit(NextCatalogEntry entry) {
text = "Not implemented yet";
}
}
}
CatalogEditor.java 0000664 0000000 0000000 00000002440 12571703675 0033727 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing package org.protege.xmlcatalog.swing;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.XMLCatalog;
public class CatalogEditor extends JPanel {
private static final long serialVersionUID = 4105691012851258776L;
public CatalogEditor(XMLCatalog catalog, List editors) {
setLayout(new BorderLayout());
add(new CatalogJTree(catalog, editors), BorderLayout.CENTER);
}
public static void main(String[] args) {
try {
JFrame frame = new JFrame("Catalog Viewer");
frame.setLayout(new BorderLayout());
frame.setPreferredSize(new Dimension(1024, 768));
JFileChooser jfc = new JFileChooser();
int ret = jfc.showOpenDialog(frame);
if (ret == JFileChooser.APPROVE_OPTION) {
File f = jfc.getSelectedFile();
XMLCatalog catalog = CatalogUtilities.parseDocument(f.toURI().toURL());
frame.add(new CatalogEditor(catalog, new ArrayList()));
frame.setVisible(true);
frame.repaint();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}
CatalogEditorTransferHandler.java 0000664 0000000 0000000 00000005020 12571703675 0036727 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing package org.protege.xmlcatalog.swing;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import javax.swing.JComponent;
import javax.swing.TransferHandler;
import org.apache.log4j.Logger;
public class CatalogEditorTransferHandler extends TransferHandler {
private static final long serialVersionUID = 1160492460896419035L;
public static final Logger LOGGER = Logger.getLogger(CatalogEditorTransferHandler.class);
public int getSourceActions(JComponent c) {
EntryTreeNode e = getEntryTreeNode(c);
if (e == null) {
return NONE;
}
else if (e.isAutoGenerated()) {
return COPY;
}
else {
return MOVE;
}
}
protected Transferable createTransferable(JComponent c) {
final EntryTreeNode e = getEntryTreeNode(c);
if (e == null) {
return null;
}
return new Transferable() {
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.getRepresentationClass().equals(EntryTreeNode.class);
}
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] { new DataFlavor(EntryTreeNode.class, "XML Catalog Entry")};
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
return e;
}
};
}
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
if (LOGGER.isDebugEnabled() && comp instanceof CatalogJTree) {
LOGGER.debug("Last selected component " + ((CatalogJTree) comp).getLastSelectedPathComponent());
}
EntryTreeNode e = getEntryTreeNode(comp);
if (e != null && (e.isAutoGenerated() || e.getEditor() != null)) {
return false;
}
else if (e == null && getCatalogTreeNode(comp) == null) {
return false;
}
for (DataFlavor flavor : transferFlavors) {
if (EntryTreeNode.class.equals(flavor.getRepresentationClass())) {
return true;
}
}
return false;
}
private EntryTreeNode getEntryTreeNode(JComponent c) {
if (!(c instanceof CatalogJTree)) {
return null;
}
CatalogJTree tree = (CatalogJTree) c;
Object o = tree.getLastSelectedPathComponent();
if (!(o instanceof EntryTreeNode)) {
return null;
}
return (EntryTreeNode) o;
}
private CatalogTreeNode getCatalogTreeNode(JComponent c) {
if (!(c instanceof CatalogJTree)) {
return null;
}
CatalogJTree tree = (CatalogJTree) c;
Object o = tree.getLastSelectedPathComponent();
if (!(o instanceof CatalogTreeNode)) {
return null;
}
return (CatalogTreeNode) o;
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing/CatalogJTree.java0000664 0000000 0000000 00000000767 12571703675 0033603 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.swing;
import java.util.List;
import javax.swing.JTree;
import org.protege.xmlcatalog.XMLCatalog;
public class CatalogJTree extends JTree {
private static final long serialVersionUID = -8502646155443727063L;
public CatalogJTree(XMLCatalog catalog, List editors) {
super(new CatalogTreeNode(catalog, editors), true);
setCellRenderer(new AltCellRenderer());
setDragEnabled(true);
setTransferHandler(new CatalogEditorTransferHandler());
}
}
CatalogTreeNode.java 0000664 0000000 0000000 00000004003 12571703675 0034203 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing package org.protege.xmlcatalog.swing;
import java.util.Enumeration;
import java.util.List;
import java.util.NoSuchElementException;
import javax.swing.tree.TreeNode;
import org.protege.xmlcatalog.XMLCatalog;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
public class CatalogTreeNode implements TreeNode {
private TreeNode parent;
private XMLCatalog catalog;
private List editors;
public CatalogTreeNode(XMLCatalog catalog, List editors) {
this(null, catalog, editors);
}
public CatalogTreeNode(TreeNode parent, XMLCatalog catalog, List editors) {
this.parent = parent;
this.catalog = catalog;
this.editors = editors;
}
public XMLCatalog getCatalog() {
return catalog;
}
public List getEditors() {
return editors;
}
/* ************************************************
* TreeNode interfaces.
*/
public TreeNode getChildAt(int childIndex) {
Entry e = catalog.getEntries().get(childIndex);
return new EntryTreeNode(this, e, editors);
}
public int getChildCount() {
return catalog.getEntries().size();
}
public TreeNode getParent() {
return parent;
}
public int getIndex(TreeNode node) {
if (parent instanceof EntryTreeNode &&
((EntryTreeNode) parent).getEditor() instanceof NextCatalogEntry &&
parent.getChildAt(0) == catalog) {
return 0;
}
return -1;
}
public boolean getAllowsChildren() {
return true;
}
public boolean isLeaf() {
return catalog.getEntries().size() == 0;
}
public Enumeration children() {
return new Enumeration() {
int currentIndex = 0;
public boolean hasMoreElements() {
return currentIndex < getChildCount();
}
public TreeNode nextElement() throws NoSuchElementException {
if (!hasMoreElements()) {
throw new NoSuchElementException("No such element");
}
try {
return getChildAt(currentIndex);
}
finally {
currentIndex++;
}
}
};
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing/CellRenderer.java0000664 0000000 0000000 00000006565 12571703675 0033647 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.swing;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.tree.TreeCellRenderer;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.entry.DelegatePublicEntry;
import org.protege.xmlcatalog.entry.DelegateSystemEntry;
import org.protege.xmlcatalog.entry.DelegateUriEntry;
import org.protege.xmlcatalog.entry.GroupEntry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
import org.protege.xmlcatalog.entry.PublicEntry;
import org.protege.xmlcatalog.entry.RewriteSystemEntry;
import org.protege.xmlcatalog.entry.RewriteUriEntry;
import org.protege.xmlcatalog.entry.SystemEntry;
import org.protege.xmlcatalog.entry.UriEntry;
public class CellRenderer implements TreeCellRenderer {
private JLabel label = new JLabel();
private EntryRenderingVisitor visitor = new EntryRenderingVisitor();
private boolean colorsInitialized = false;
// Colors
/** Color to use for the foreground for selected nodes. */
protected Color textSelectionColor;
/** Color to use for the foreground for non-selected nodes. */
protected Color textNonSelectionColor;
/** Color to use for the background when a node is selected. */
protected Color backgroundSelectionColor;
/** Color to use for the background when the node isn't selected. */
protected Color backgroundNonSelectionColor;
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
initColors(tree);
if (value instanceof CatalogTreeNode) {
label.setText("" + ((CatalogTreeNode) value).getCatalog().getXmlBase());
}
else {
EntryTreeNode node = (EntryTreeNode) value;
if (node.getEditor() != null) {
label.setText(node.getEditor().getDescription(node.getEntry()));
}
else {
node.getEntry().accept(visitor);
}
}
if (selected) {
label.setBackground(backgroundSelectionColor);
}
else {
label.setBackground(backgroundNonSelectionColor);
}
return label;
}
private void initColors(JTree tree) {
if (!colorsInitialized) {
backgroundSelectionColor = UIManager.getColor("Tree.selectionBackground");
backgroundNonSelectionColor = UIManager.getColor("Tree.textBackground");
colorsInitialized = true;
}
}
private class EntryRenderingVisitor implements EntryVisitor {
public void visit(GroupEntry entry) {
label.setText("Group Entry");
}
public void visit(PublicEntry entry) {
label.setText("Not implemented yet");
}
public void visit(SystemEntry entry) {
label.setText("Not implemented yet");
}
public void visit(RewriteSystemEntry entry) {
label.setText("Not implemented yet");
}
public void visit(DelegatePublicEntry entry) {
label.setText("Not implemented yet");
}
public void visit(DelegateSystemEntry entry) {
label.setText("Not implemented yet");
}
public void visit(UriEntry entry) {
label.setText(entry.getName() + " \u2192 " + entry.getUri());
}
public void visit(RewriteUriEntry entry) {
label.setText("Not implemented yet");
}
public void visit(DelegateUriEntry entry) {
label.setText("Not implemented yet");
}
public void visit(NextCatalogEntry entry) {
label.setText("Not implemented yet");
}
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing/EntryEditor.java 0000664 0000000 0000000 00000000617 12571703675 0033541 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog.swing;
import java.awt.Frame;
import org.protege.xmlcatalog.XmlBaseContext;
import org.protege.xmlcatalog.entry.Entry;
public interface EntryEditor {
boolean isSuitable(Entry ge);
Entry newEntryDialog(Frame parent, XmlBaseContext context);
Entry editEntryDialog(Frame parent, XmlBaseContext context, Entry input);
String getDescription(Entry ge);
}
EntryTreeNode.java 0000664 0000000 0000000 00000007260 12571703675 0033742 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/swing package org.protege.xmlcatalog.swing;
import java.util.Enumeration;
import java.util.List;
import java.util.NoSuchElementException;
import javax.swing.tree.TreeNode;
import org.apache.log4j.Logger;
import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.XMLCatalog;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.entry.GroupEntry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
public class EntryTreeNode implements TreeNode {
public static final Logger LOGGER = Logger.getLogger(EntryTreeNode.class);
private TreeNode parent;
private Entry entry;
private List editors;
private EntryEditor editor;
private boolean autoGenerated;
private XMLCatalog childCatalog; // only if the entry is a NextCatalogEntry.
public EntryTreeNode(TreeNode parent, Entry entry, List editors) {
if (!(parent instanceof CatalogTreeNode) && !(parent instanceof EntryTreeNode)) {
throw new IllegalArgumentException("Invalid Parent!");
}
this.entry = entry;
this.editors = editors;
this.parent = parent;
editor = null;
autoGenerated = false;
boolean isParentAutoGenerated;
if (parent instanceof CatalogTreeNode) {
isParentAutoGenerated = false;
}
else {
isParentAutoGenerated = ((EntryTreeNode) parent).isAutoGenerated();
}
if (isParentAutoGenerated) {
autoGenerated = true;
}
else {
for (EntryEditor editor : editors) {
if (editor.isSuitable(entry)) {
this.editor = editor;
}
}
}
}
public Entry getEntry() {
return entry;
}
public List getEditors() {
return editors;
}
public EntryEditor getEditor() {
return editor;
}
public boolean isAutoGenerated() {
return autoGenerated;
}
/* *********************************************
* TreeNode Interfaces
*/
public TreeNode getChildAt(int childIndex) {
if (entry instanceof GroupEntry) {
Entry childEntry = ((GroupEntry) entry).getEntries().get(childIndex);
return new EntryTreeNode(this, childEntry, editors);
}
else if (entry instanceof NextCatalogEntry && childIndex == 0) {
try {
if (childCatalog == null) {
childCatalog = CatalogUtilities.parseDocument(((NextCatalogEntry) entry).getCatalog().toURL());
}
}
catch (Exception e) {
LOGGER.error("Exception caught trying to parse nested catalog in xml catalog", e);
}
return new CatalogTreeNode(childCatalog, editors);
}
return null;
}
public int getChildCount() {
if (entry instanceof GroupEntry) {
return ((GroupEntry) entry).getEntries().size();
}
else if (entry instanceof NextCatalogEntry) {
return 1;
}
else {
return 0;
}
}
public TreeNode getParent() {
return parent;
}
public int getIndex(TreeNode node) {
if (node instanceof EntryTreeNode && ((EntryTreeNode) node).getEntry() instanceof GroupEntry) {
return ((GroupEntry) ((EntryTreeNode) node).getEntry()).getEntries().indexOf(entry);
}
return -1;
}
public boolean getAllowsChildren() {
return entry instanceof GroupEntry || entry instanceof NextCatalogEntry;
}
public boolean isLeaf() {
if (entry instanceof GroupEntry) {
return ((GroupEntry) entry).getEntries().size() == 0;
}
return entry instanceof NextCatalogEntry;
}
public Enumeration children() {
return new Enumeration() {
int currentIndex = 0;
public boolean hasMoreElements() {
return currentIndex < getChildCount();
}
public TreeNode nextElement() throws NoSuchElementException {
if (!hasMoreElements()) {
throw new NoSuchElementException("No such element");
}
try {
return getChildAt(currentIndex);
}
finally {
currentIndex++;
}
}
};
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/write/ 0000775 0000000 0000000 00000000000 12571703675 0030425 5 ustar 00root root 0000000 0000000 XMLCatalogWriter.java 0000664 0000000 0000000 00000005601 12571703675 0034343 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/write package org.protege.xmlcatalog.write;
import java.io.IOException;
import java.io.Writer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.XMLCatalog;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.parser.Handler;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class XMLCatalogWriter {
public static String XML_CATALOG_NS="urn:oasis:names:tc:entity:xmlns:xml:catalog";
private XMLCatalog catalog;
private Writer out;
public XMLCatalogWriter(XMLCatalog catalog, Writer out) {
this.catalog = catalog;
this.out = out;
}
public void write() throws IOException, ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbf.newDocumentBuilder();
Document document = builder.newDocument();
Element root = document.createElementNS(XML_CATALOG_NS, Handler.CATALOG_ELEMENT);
if (catalog.getXmlBase() != null) {
root.setAttribute(Handler.XML_BASE_ATTRIBUTE, catalog.getXmlBase().toString());
}
if (catalog.getPrefer() != null) {
root.setAttribute(Handler.PREFER_ATTRIBUTE, catalog.getPrefer().getName());
}
document.appendChild(root);
XMLRenderingVisitor renderer = new XMLRenderingVisitor(document, root, CatalogUtilities.resolveXmlBase(catalog));
for (Entry entry : catalog.getEntries()) {
entry.accept(renderer);
}
save(document);
}
private void save(Document document) throws TransformerFactoryConfigurationError, TransformerException {
Source source = new DOMSource(document);
Result result = new StreamResult(out);
TransformerFactory factory = TransformerFactory.newInstance();
/* Hopefully this guards against residual effects from GForge ticket 2734 */
try {
factory.setAttribute("indent-number", 4);
}
catch (IllegalArgumentException e) {
// ok - be that way.
}
Transformer xformer = factory.newTransformer();
xformer.setOutputProperty(OutputKeys.METHOD, "xml");
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
xformer.transform(source, result);
}
}
XMLRenderingVisitor.java 0000664 0000000 0000000 00000015150 12571703675 0035071 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/main/java/org/protege/xmlcatalog/write package org.protege.xmlcatalog.write;
import java.net.URI;
import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.EntryVisitor;
import org.protege.xmlcatalog.XmlBaseContext;
import org.protege.xmlcatalog.entry.AbstractDelegateEntry;
import org.protege.xmlcatalog.entry.DelegatePublicEntry;
import org.protege.xmlcatalog.entry.DelegateSystemEntry;
import org.protege.xmlcatalog.entry.DelegateUriEntry;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.entry.GroupEntry;
import org.protege.xmlcatalog.entry.NextCatalogEntry;
import org.protege.xmlcatalog.entry.PublicEntry;
import org.protege.xmlcatalog.entry.RewriteSystemEntry;
import org.protege.xmlcatalog.entry.RewriteUriEntry;
import org.protege.xmlcatalog.entry.SystemEntry;
import org.protege.xmlcatalog.entry.UriEntry;
import org.protege.xmlcatalog.parser.Handler;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class XMLRenderingVisitor implements EntryVisitor {
private Document document;
private Element parent;
public XMLRenderingVisitor(Document document, Element parent, URI xmlbase) {
this.document = document;
this.parent = parent;
}
public void visit(GroupEntry entry) {
Element groupElement = document.createElement(Handler.GROUP_ELEMENT);
addId(groupElement, entry);
addXmlBase(groupElement, entry);
if (entry.getPrefer() != null) {
groupElement.setAttribute(Handler.PREFER_ATTRIBUTE, entry.getPrefer().getName());
}
parent.appendChild(groupElement);
XMLRenderingVisitor subEntryVisitor = new XMLRenderingVisitor(document, groupElement, CatalogUtilities.resolveXmlBase(entry));
for (Entry subEntry : entry.getEntries()) {
subEntry.accept(subEntryVisitor);
}
}
public void visit(PublicEntry entry) {
Element publicElement = document.createElement(Handler.PUBLIC_ELEMENT);
addId(publicElement, entry);
addXmlBase(publicElement, entry);
publicElement.setAttribute(Handler.PUBLIC_ID_ATTRIBUTE, entry.getPublicId());
publicElement.setAttribute(Handler.URI_ATTRIBUTE, entry.getUri().toString());
parent.appendChild(publicElement);
}
public void visit(SystemEntry entry) {
Element systemElement = document.createElement(Handler.SYSTEM_ELEMENT);
addId(systemElement, entry);
addXmlBase(systemElement, entry);
systemElement.setAttribute(Handler.SYSTEM_ID_ATTRIBUTE, entry.getSystemId());
systemElement.setAttribute(Handler.URI_ATTRIBUTE, entry.getUri().toString());
parent.appendChild(systemElement);
}
public void visit(RewriteSystemEntry entry) {
Element rewriteSystemElement = document.createElement(Handler.REWRITE_SYSTEM_ELEMENT);
addId(rewriteSystemElement, entry);
rewriteSystemElement.setAttribute(Handler.SYSTEM_ID_START_ATTRIBUTE, entry.getSystemIdStartString());
rewriteSystemElement.setAttribute(Handler.REWRITE_PREFIX_ATTRIBUTE, entry.getRewritePrefix().toString());
parent.appendChild(rewriteSystemElement);
}
public void visit(DelegatePublicEntry entry) {
Element delgatePublicElement = document.createElement(Handler.DELEGATE_PUBLIC_ELEMENT);
addId(delgatePublicElement, entry);
addDelegate(delgatePublicElement, entry);
delgatePublicElement.setAttribute(Handler.PUBLIC_ID_START_ATTRIBUTE, entry.getPublicIdStartString());
parent.appendChild(delgatePublicElement);
}
public void visit(DelegateSystemEntry entry) {
Element delegateSystemElement = document.createElement(Handler.DELEGATE_SYSTEM_ELEMENT);
addId(delegateSystemElement, entry);
addDelegate(delegateSystemElement, entry);
delegateSystemElement.setAttribute(Handler.SYSTEM_ID_START_ATTRIBUTE, entry.getSystemIdStartString());
parent.appendChild(delegateSystemElement);
}
public void visit(UriEntry entry) {
Element uriElement = document.createElement(Handler.URI_ELEMENT);
addId(uriElement, entry);
addXmlBase(uriElement, entry);
uriElement.setAttribute(Handler.URI_NAME_ATTRIBUTE, entry.getName());
uriElement.setAttribute(Handler.URI_ELEMENT, entry.getUri().toString());
parent.appendChild(uriElement);
}
public void visit(RewriteUriEntry entry) {
Element rewriteElement = document.createElement(Handler.REWRITE_URI_ELEMENT);
addId(rewriteElement, entry);
rewriteElement.setAttribute(Handler.URI_START_STRING, entry.getUriStartString());
rewriteElement.setAttribute(Handler.REWRITE_PREFIX_ATTRIBUTE, entry.getRewritePrefix().toString());
parent.appendChild(rewriteElement);
}
public void visit(DelegateUriEntry entry) {
Element delegateUriElement = document.createElement(Handler.DELEGATE_URI_ELEMENT);
addId(delegateUriElement, entry);
addXmlBase(delegateUriElement, entry);
delegateUriElement.setAttribute(Handler.URI_START_STRING, entry.getUriStartString());
delegateUriElement.setAttribute(Handler.CATALOG_ATTRIBUTE, entry.getCatalog().toString());
parent.appendChild(delegateUriElement);
}
public void visit(NextCatalogEntry entry) {
Element nextCatalogElement = document.createElement(Handler.NEXT_CATALOG_ELEMENT);
addId(nextCatalogElement, entry);
addXmlBase(nextCatalogElement, entry);
nextCatalogElement.setAttribute(Handler.CATALOG_ATTRIBUTE, entry.getCatalog().toString());
parent.appendChild(nextCatalogElement);
}
private void addId(Element entryElement, Entry entry) {
if (entry.getId() != null) {
entryElement.setAttribute(Handler.ID_ATTRIBUTE, entry.getId());
}
}
private void addXmlBase(Element element, XmlBaseContext entry) {
URI xmlbase = entry.getXmlBase();
if (xmlbase != null) {
URI parentBase;
if ((entry.getXmlBaseContext() != null) && ((parentBase = CatalogUtilities.resolveXmlBase(entry.getXmlBaseContext())) != null)) {
xmlbase = parentBase.relativize(xmlbase);
}
element.setAttribute(Handler.XML_BASE_ATTRIBUTE, xmlbase.toString());
}
}
private void addDelegate(Element entryElement, AbstractDelegateEntry delegateEntry) {
addXmlBase(entryElement, delegateEntry);
entryElement.setAttribute(Handler.CATALOG_ATTRIBUTE, delegateEntry.getCatalog().toString());
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/ 0000775 0000000 0000000 00000000000 12571703675 0022016 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/ 0000775 0000000 0000000 00000000000 12571703675 0022737 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/ 0000775 0000000 0000000 00000000000 12571703675 0023526 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/ 0000775 0000000 0000000 00000000000 12571703675 0025173 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/xmlcatalog/ 0000775 0000000 0000000 00000000000 12571703675 0027326 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/xmlcatalog/CatalogTest.java 0000664 0000000 0000000 00000002043 12571703675 0032402 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog;
import java.io.File;
import junit.framework.TestCase;
import org.apache.log4j.Logger;
public class CatalogTest extends TestCase {
private static final Logger log = Logger.getLogger(CatalogTest.class);
public void testExample1() {
try {
CatalogUtilities.parseDocument(new File("src/test/resources/Example1.xml").toURI().toURL());
}
catch (Throwable t) {
log.warn("Test failed", t);
fail();
}
}
public void testExample2() {
try {
CatalogUtilities.parseDocument(new File("src/test/resources/Example2.xml").toURI().toURL());
}
catch (Throwable t) {
log.warn("Test failed", t);
fail();
}
}
public void testCatalog8() {
try {
CatalogUtilities.parseDocument(new File("src/test/resources/catalog08.xml").toURI().toURL());
}
catch (Throwable t) {
log.warn("Test failed", t);
fail();
}
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/xmlcatalog/JunitUtilities.java 0000664 0000000 0000000 00000000263 12571703675 0033157 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog;
public class JunitUtilities {
public static boolean isJava5() {
return System.getProperty("java.version").startsWith("1.5");
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/xmlcatalog/ResolveTest.java 0000664 0000000 0000000 00000013647 12571703675 0032463 0 ustar 00root root 0000000 0000000 package org.protege.xmlcatalog;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import javax.xml.transform.TransformerException;
import junit.framework.TestCase;
import org.apache.xml.resolver.CatalogManager;
import org.apache.xml.resolver.tools.CatalogResolver;
public class ResolveTest extends TestCase {
private CatalogResolver resolver;
private XMLCatalog catalog;
public void test01() throws TransformerException, MalformedURLException, IOException {
readCatalog("src/test/resources/catalog01.xml");
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = URI.create("file:/home/tredmond/Shared/ontologies/simple/ontology1.owl");
checkBothAlgorithmsSame(u, false);
assertTrue(CatalogUtilities.getRedirect(u, catalog).equals(redirect));
}
public void test02() throws MalformedURLException, IOException, TransformerException {
readCatalog("src/test/resources/catalog02.xml");
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = URI.create("file:/home/tredmond/Shared/simple/ontology1.owl");
checkBothAlgorithmsSame(u, false);
assertTrue(CatalogUtilities.getRedirect(u, catalog).equals(redirect));
}
public void test03() throws MalformedURLException, IOException, TransformerException {
readCatalog("src/test/resources/catalog03.xml");
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = new File("src/test/resources/simple/ontology1.owl").toURI();
// needs trim because of a seemingly silly problem involving the URI for the outer xml base.
checkBothAlgorithmsSame(u, true);
assertTrue(CatalogUtilities.getRedirect(u, catalog).equals(redirect));
}
public void test04() throws MalformedURLException, IOException, TransformerException {
readCatalog("src/test/resources/catalog04.xml");
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = new File("src/test/resources/dir1/dir2/simple/ontology1.owl").toURI();
// The apache resolver behaves differently in Java 1.5 and Java 1.6
// I have aligned this library with the 1.6 behavior
if (!JunitUtilities.isJava5()) {
checkBothAlgorithmsSame(u, true);
}
assertTrue(CatalogUtilities.getRedirect(u, catalog).equals(redirect));
}
public void test05() throws MalformedURLException, IOException, TransformerException {
readCatalog("src/test/resources/catalog05.xml");
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = new File("src/test/resources/dir1/dir2/simple/ontology1.owl").toURI();
// The apache resolver behaves differently in Java 1.5 and Java 1.6
// I have aligned this library with the 1.6 behavior
if (!JunitUtilities.isJava5()) {
checkBothAlgorithmsSame(u, true);
}
assertTrue(CatalogUtilities.getRedirect(u, catalog).equals(redirect));
}
public void test06() throws MalformedURLException, IOException, TransformerException {
readCatalog("src/test/resources/catalog06.xml");
URI u = URI.create("http://www.tigraworld.com/protege/pizza.owl");
// Predicting redirect is hard because it's system dependent. Windows adds a "C:".
checkBothAlgorithmsSame(u, true);
}
public void test07() throws TransformerException, MalformedURLException, IOException {
readCatalog("src/test/resources/catalog07.xml");
doTest07();
}
public void test08() throws TransformerException, MalformedURLException, IOException {
readCatalog("src/test/resources/catalog08.xml");
doTest07();
}
public void test09() throws TransformerException, MalformedURLException, IOException {
readCatalog("src/test/resources/catalog09.xml");
doTest07();
}
private void doTest07() throws TransformerException {
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = URI.create("file:/home/tredmond/Shared/ontologies/simple/ontology1.owl");
checkBothAlgorithmsSame(u, false);
assertTrue(CatalogUtilities.getRedirect(u, catalog).equals(redirect));
}
private void readCatalog(String catalogLocation) throws MalformedURLException, IOException {
System.setProperty("xml.catalog.ignoreMissing", "true");
CatalogManager manager = new CatalogManager();
manager.setUseStaticCatalog(false);
manager.setCatalogFiles(catalogLocation);
resolver = new CatalogResolver(manager);
catalog = parseCatalog(new File(catalogLocation));
}
protected XMLCatalog parseCatalog(File location) throws MalformedURLException, IOException {
return CatalogUtilities.parseDocument(location.toURI().toURL());
}
private void checkBothAlgorithmsSame(URI u, boolean trim) throws TransformerException {
String result1 = resolver.resolve(u.toString(), null).getSystemId();
String result2 = CatalogUtilities.getRedirect(u, catalog).toString();
if (trim) {
result1 = trimFileScheme(result1);
result2 = trimFileScheme(result2);
}
assertTrue(result1.equals(result2));
}
/*
* This is a hack to avoid losing test cases because of differences like
* file:/foo vs. file://foo.
* I am not sure why these differences come up and am not sure if the second
* version makes sense.
*/
private String trimFileScheme(String uri) {
String filePrefix="file:";
if (uri.startsWith(filePrefix)) {
uri = uri.substring(filePrefix.length());
while (uri.startsWith("/")) {
uri = uri.substring(1);
}
}
return uri;
}
}
ResolveWithRoundTripTest.java 0000664 0000000 0000000 00000001322 12571703675 0035072 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/xmlcatalog package org.protege.xmlcatalog;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import org.protege.xmlcatalog.parser.OuterXmlBaseContext;
public class ResolveWithRoundTripTest extends ResolveTest {
@Override
protected XMLCatalog parseCatalog(File location) throws MalformedURLException, IOException {
XMLCatalog catalog = super.parseCatalog(location);
File tmpLocation = File.createTempFile("catalog-", ".xml");
CatalogUtilities.save(catalog, tmpLocation);
catalog = CatalogUtilities.parseDocument(tmpLocation.toURI().toURL());
catalog.setXmlBaseContext(new OuterXmlBaseContext(location.toURI()));
return catalog;
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/xmlcatalog/owlapi/ 0000775 0000000 0000000 00000000000 12571703675 0030621 5 ustar 00root root 0000000 0000000 IRIMapperTest.java 0000664 0000000 0000000 00000003441 12571703675 0034037 0 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/java/org/protege/xmlcatalog/owlapi package org.protege.xmlcatalog.owlapi;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Set;
import junit.framework.TestCase;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLImportsDeclaration;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
public class IRIMapperTest extends TestCase {
public final static IRI IMPORT_LOCATION = IRI.create("http://test.org/TestPizzaImport.owl");
public final static IRI PIZZA_IRI = IRI.create("http://www.co-ode.org/ontologies/pizza/pizza.owl");
public final static IRI REDIRECT_LOCATION = IRI.create("http://protege.stanford.edu/ontologies/pizza/pizza.owl");
public void testIRIMapper() throws MalformedURLException, IOException, OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.addIRIMapper(new XMLCatalogIRIMapper(new File("src/test/resources/owl/redirect-to-pizza.xml")));
OWLOntology ontology = manager.loadOntology(IRI.create(new File("src/test/resources/owl/TestFunnyPizzaImport.owl")));
Set importDeclarations = ontology.getImportsDeclarations();
assertEquals(1, importDeclarations.size());
assertEquals(IMPORT_LOCATION, importDeclarations.iterator().next().getIRI());
Set importedOntologies = ontology.getImports();
assertEquals(1, importedOntologies.size());
OWLOntology pizzaOntology = importedOntologies.iterator().next();
assertEquals(PIZZA_IRI, pizzaOntology.getOntologyID().getOntologyIRI());
assertEquals(REDIRECT_LOCATION, manager.getOntologyDocumentIRI(pizzaOntology));
}
}
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/ 0000775 0000000 0000000 00000000000 12571703675 0024030 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/Ambiguous.owl 0000664 0000000 0000000 00000002040 12571703675 0026502 0 ustar 00root root 0000000 0000000
]>
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/Example1.xml 0000664 0000000 0000000 00000002172 12571703675 0026230 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/Example2.xml 0000664 0000000 0000000 00000000462 12571703675 0026231 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog01.xml 0000664 0000000 0000000 00000000367 12571703675 0026333 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog02.xml 0000664 0000000 0000000 00000000365 12571703675 0026332 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog03.xml 0000664 0000000 0000000 00000000300 12571703675 0026320 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog04.xml 0000664 0000000 0000000 00000000252 12571703675 0026327 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog05.xml 0000664 0000000 0000000 00000000332 12571703675 0026327 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog06.xml 0000664 0000000 0000000 00000000327 12571703675 0026334 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog07.xml 0000664 0000000 0000000 00000000411 12571703675 0026327 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog08.xml 0000664 0000000 0000000 00000000360 12571703675 0026333 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/catalog09.xml 0000664 0000000 0000000 00000000425 12571703675 0026336 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/dir1/ 0000775 0000000 0000000 00000000000 12571703675 0024667 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/dir1/dir2/ 0000775 0000000 0000000 00000000000 12571703675 0025527 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/dir1/dir2/catalog01.xml 0000664 0000000 0000000 00000000301 12571703675 0030016 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/log4j.xml 0000664 0000000 0000000 00000001632 12571703675 0025573 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/owl/ 0000775 0000000 0000000 00000000000 12571703675 0024631 5 ustar 00root root 0000000 0000000 xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/owl/TestFunnyPizzaImport.owl 0000664 0000000 0000000 00000002252 12571703675 0031525 0 ustar 00root root 0000000 0000000
]>
http://test.org/TestPizzaImport.owl
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/owl/redirect-to-pizza.xml 0000664 0000000 0000000 00000000435 12571703675 0030731 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/pizza-xml.owl 0000664 0000000 0000000 00000436375 12571703675 0026530 0 ustar 00root root 0000000 0000000
]>
http://protege.stanford.edu/plugins/owl/protegeAn example ontology that contains all constructs required for the various versions of the Pizza Tutorial run by Manchester University (see http://www.co-ode.org/resources/tutorials/)enversion 1.3#AmericanAmericana#AmericanHotAmericanaPicante#AnchoviesToppingCoberturaDeAnchovies#ArtichokeToppingCoberturaDeArtichoke#AsparagusToppingCoberturaDeAspargos#CajunCajun#CajunSpiceToppingCoberturaDeCajun#CaperToppingCoberturaDeCaper#CapricciosaCapricciosa#CaprinaCaprina#CheeseToppingCoberturaDeQueijo#CheeseyPizzaAny pizza that has at least 1 cheese topping.#CheeseyPizzaPizzaComQueijo#CheeseyVegetableToppingThis class will be inconsistent. This is because we have given it 2 disjoint parents, which means it could never have any members (as nothing can simultaneously be a CheeseTopping and a VegetableTopping). NB Called ProbeInconsistentTopping in the ProtegeOWL Tutorial.#CheeseyVegetableToppingCoberturaDeQueijoComVegetais#ChickenToppingCoberturaDeFrango#CountryA class that is equivalent to the set of individuals that are described in the enumeration - ie Countries can only be either America, England, France, Germany or Italy and nothing else. Note that these individuals have been asserted to be allDifferent from each other.#CountryPais#DeepPanBaseBaseEspessa#FiorentinaFiorentina#FishToppingCoberturaDePeixe#FourCheesesToppingCoberturaQuatroQueijos#FourSeasonsQuatroQueijos#FruitToppingCoberturaDeFrutas#FruttiDiMareFrutosDoMar#GarlicToppingCoberturaDeAlho#GiardinieraGiardiniera#GoatsCheeseToppingCoberturaDeQueijoDeCabra#GorgonzolaToppingCoberturaDeGorgonzola#GreenPepperToppingCoberturaDePimentaoVerde#HamToppingCoberturaDePresunto#HerbSpiceToppingCoberturaDeErvas#HotPicante#HotGreenPepperToppingCoberturaDePimentaoVerdePicante#HotSpicedBeefToppingCoberturaDeBifePicante#IceCreamA class to demonstrate mistakes made with setting a property domain. The property hasTopping has a domain of Pizza. This means that the reasoner can infer that all individuals using the hasTopping property must be of type Pizza. Because of the restriction on this class, all members of IceCream must use the hasTopping property, and therefore must also be members of Pizza. However, Pizza and IceCream are disjoint, so this causes an inconsistency. If they were not disjoint, IceCream would be inferred to be a subclass of Pizza.#IceCreamSorvete#InterestingPizzaAny pizza that has at least 3 toppings. Note that this is a cardinality constraint on the hasTopping property and NOT a qualified cardinality constraint (QCR). A QCR would specify from which class the members in this relationship must be. eg has at least 3 toppings from PizzaTopping. This is currently not supported in OWL.#InterestingPizzaPizzaInteressante#JalapenoPepperToppingCoberturaDeJalapeno#LaReineLaReine#LeekToppingCoberturaDeLeek#MargheritaMargherita#MeatToppingCoberturaDeCarne#MeatyPizzaAny pizza that has at least one meat topping#MeatyPizzaPizzaDeCarne#MediumMedia#MildNaoPicante#MixedSeafoodToppingCoberturaDeFrutosDoMarMistos#MozzarellaToppingCoberturaDeMozzarella#MushroomCogumelo#MushroomToppingCoberturaDeCogumelo#NamedPizzaA pizza that can be found on a pizza menu#NamedPizzaPizzaComUmNome#NapoletanaNapoletana#NonVegetarianPizzaAny Pizza that is not a VegetarianPizza#NonVegetarianPizzaPizzaNaoVegetariana#NutToppingCoberturaDeCastanha#OliveToppingCoberturaDeAzeitona#OnionToppingCoberturaDeCebola#ParmaHamToppingCoberturaDePrezuntoParma#ParmenseParmense#ParmesanToppingCoberturaDeParmesao#PeperonataToppingCoberturaPeperonata#PeperoniSausageToppingCoberturaDeCalabreza#PepperToppingCoberturaDePimentao#PetitPoisToppingCoberturaPetitPois#PineKernelsCoberturaPineKernels#PizzaPizza#PizzaBaseBaseDaPizza#PizzaToppingCoberturaDaPizza#PolloAdAstraPolloAdAstra#PrawnsToppingCoberturaDeCamarao#PrinceCarloCoberturaPrinceCarlo#QuattroFormaggiQuatroQueijos#RealItalianPizzaThis defined class has conditions that are part of the definition: ie any Pizza that has the country of origin, Italy is a RealItalianPizza. It also has conditions that merely describe the members - that all RealItalianPizzas must only have ThinAndCrispy bases.#RealItalianPizzaPizzaItalianaReal#RedOnionToppingCoberturaDeCebolaVermelha#RocketToppingCoberturaRocket#RosaRosa#RosemaryToppingCoberturaRosemary#SauceToppingCoberturaEmMolho#SicilianaSiciliana#SlicedTomatoToppingCoberturaDeTomateFatiado#SloppyGiuseppeSloppyGiuseppe#SohoSoho#SpicinessA ValuePartition that describes only values from Hot, Medium or Mild. NB Subclasses can themselves be divided up into further partitions.#SpicinessTempero#SpicyPizzaAny pizza that has a spicy topping is a SpicyPizza#SpicyPizzaPizzaTemperada#SpicyPizzaEquivalentAn alternative definition for the SpicyPizza which does away with needing a definition of SpicyTopping and uses a slightly more complicated restriction: Pizzas that have at least one topping that is both a PizzaTopping and has spiciness hot are members of this class.#SpicyPizzaEquivalentPizzaTemperadaEquivalente#SpicyToppingAny pizza topping that has spiciness Hot#SpicyToppingCoberturaTemperada#SpinachToppingCoberturaDeEspinafre#SultanaToppingCoberturaSultana#SundriedTomatoToppingCoberturaDeTomateRessecadoAoSol#SweetPepperToppingCoberturaDePimentaoDoce#ThinAndCrispyBaseBaseFinaEQuebradica#TobascoPepperSauceMolhoTobascoPepper#TomatoToppingCoberturaDeTomate#UnclosedPizzaAn unclosed Pizza cannot be inferred to be either a VegetarianPizza or a NonVegetarianPizza, because it might have other toppings.#UnclosedPizzaPizzaAberta#ValuePartitionA ValuePartition is a pattern that describes a restricted set of classes from which a property can be associated. The parent class is used in restrictions, and the covering axiom means that only members of the subclasses may be used as values. The possible subclasses cannot be extended without updating the ValuePartition class.#ValuePartitionValorDaParticao#VegetableToppingCoberturaDeVegetais#VegetarianPizzaAny pizza that does not have fish topping and does not have meat topping is a VegetarianPizza. Members of this class do not need to have any toppings at all.#VegetarianPizzaPizzaVegetariana#VegetarianPizzaEquivalent1Any pizza that only has vegetarian toppings or no toppings is a VegetarianPizzaEquiv1. Should be inferred to be equivalent to VegetarianPizzaEquiv2. Not equivalent to VegetarianPizza because PizzaTopping is not covering#VegetarianPizzaEquivalent1PizzaVegetarianaEquivalente1#VegetarianPizzaEquivalent2An alternative to VegetarianPizzaEquiv1 that does not require a definition of VegetarianTopping. Perhaps more difficult to maintain. Not equivalent to VegetarianPizza#VegetarianPizzaEquivalent2PizzaVegetarianaEquivalente2#VegetarianToppingAn example of a covering axiom. VegetarianTopping is equivalent to the union of all toppings in the given axiom. VegetarianToppings can only be Cheese or Vegetable or....etc.#VegetarianToppingCoberturaVegetariana#VenezianaVeneziana#hasIngredientNB Transitive - the ingredients of ingredients are ingredients of the whole#hasSpicinessA property created to be used with the ValuePartition - Spiciness.#isIngredientOfThe inverse property tree to hasIngredient - all subproperties and attributes of the properties should reflect those under hasIngredient.
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/pizza.owl 0000664 0000000 0000000 00000376153 12571703675 0025727 0 ustar 00root root 0000000 0000000
]>
enversion 1.3An example ontology that contains all constructs required for the various versions of the Pizza Tutorial run by Manchester University (see http://www.co-ode.org/resources/tutorials/)NB Transitive - the ingredients of ingredients are ingredients of the wholeA property created to be used with the ValuePartition - Spiciness.The inverse property tree to hasIngredient - all subproperties and attributes of the properties should reflect those under hasIngredient.AmericanaAmericanaPicanteCoberturaDeAnchoviesCoberturaDeArtichokeCoberturaDeAspargosCajunCoberturaDeCajunCoberturaDeCaperCapricciosaCaprinaCoberturaDeQueijoPizzaComQueijoAny pizza that has at least 1 cheese topping.CoberturaDeQueijoComVegetaisThis class will be inconsistent. This is because we have given it 2 disjoint parents, which means it could never have any members (as nothing can simultaneously be a CheeseTopping and a VegetableTopping). NB Called ProbeInconsistentTopping in the ProtegeOWL Tutorial.CoberturaDeFrangoPaisA class that is equivalent to the set of individuals that are described in the enumeration - ie Countries can only be either America, England, France, Germany or Italy and nothing else. Note that these individuals have been asserted to be allDifferent from each other.BaseEspessaFiorentinaCoberturaDePeixeCoberturaQuatroQueijosQuatroQueijosCoberturaDeFrutasFrutosDoMarCoberturaDeAlhoGiardinieraCoberturaDeQueijoDeCabraCoberturaDeGorgonzolaCoberturaDePimentaoVerdeCoberturaDePresuntoCoberturaDeErvasPicanteCoberturaDePimentaoVerdePicanteCoberturaDeBifePicanteSorveteA class to demonstrate mistakes made with setting a property domain. The property hasTopping has a domain of Pizza. This means that the reasoner can infer that all individuals using the hasTopping property must be of type Pizza. Because of the restriction on this class, all members of IceCream must use the hasTopping property, and therefore must also be members of Pizza. However, Pizza and IceCream are disjoint, so this causes an inconsistency. If they were not disjoint, IceCream would be inferred to be a subclass of Pizza.PizzaInteressante3Any pizza that has at least 3 toppings. Note that this is a cardinality constraint on the hasTopping property and NOT a qualified cardinality constraint (QCR). A QCR would specify from which class the members in this relationship must be. eg has at least 3 toppings from PizzaTopping. This is currently not supported in OWL.CoberturaDeJalapenoLaReineCoberturaDeLeekMargheritaCoberturaDeCarnePizzaDeCarneAny pizza that has at least one meat toppingMediaNaoPicanteCoberturaDeFrutosDoMarMistosCoberturaDeMozzarellaCogumeloCoberturaDeCogumeloPizzaComUmNomeA pizza that can be found on a pizza menuNapoletanaPizzaNaoVegetarianaAny Pizza that is not a VegetarianPizzaCoberturaDeCastanhaCoberturaDeAzeitonaCoberturaDeCebolaCoberturaDePrezuntoParmaParmenseCoberturaDeParmesaoCoberturaPeperonataCoberturaDeCalabrezaCoberturaDePimentaoCoberturaPetitPoisCoberturaPineKernelsPizzaBaseDaPizzaCoberturaDaPizzaPolloAdAstraCoberturaDeCamaraoCoberturaPrinceCarloQuatroQueijosPizzaItalianaRealThis defined class has conditions that are part of the definition: ie any Pizza that has the country of origin, Italy is a RealItalianPizza. It also has conditions that merely describe the members - that all RealItalianPizzas must only have ThinAndCrispy bases.CoberturaDeCebolaVermelhaCoberturaRocketRosaCoberturaRosemaryCoberturaEmMolhoSicilianaCoberturaDeTomateFatiadoSloppyGiuseppeSohoTemperoA ValuePartition that describes only values from Hot, Medium or Mild. NB Subclasses can themselves be divided up into further partitions.PizzaTemperadaAny pizza that has a spicy topping is a SpicyPizzaPizzaTemperadaEquivalenteAn alternative definition for the SpicyPizza which does away with needing a definition of SpicyTopping and uses a slightly more complicated restriction: Pizzas that have at least one topping that is both a PizzaTopping and has spiciness hot are members of this class.CoberturaTemperadaAny pizza topping that has spiciness HotCoberturaDeEspinafreCoberturaSultanaCoberturaDeTomateRessecadoAoSolCoberturaDePimentaoDoceBaseFinaEQuebradicaMolhoTobascoPepperCoberturaDeTomatePizzaAbertaAn unclosed Pizza cannot be inferred to be either a VegetarianPizza or a NonVegetarianPizza, because it might have other toppings.ValorDaParticaoA ValuePartition is a pattern that describes a restricted set of classes from which a property can be associated. The parent class is used in restrictions, and the covering axiom means that only members of the subclasses may be used as values. The possible subclasses cannot be extended without updating the ValuePartition class.CoberturaDeVegetaisPizzaVegetarianaAny pizza that does not have fish topping and does not have meat topping is a VegetarianPizza. Members of this class do not need to have any toppings at all.PizzaVegetarianaEquivalente1Any pizza that only has vegetarian toppings or no toppings is a VegetarianPizzaEquiv1. Should be inferred to be equivalent to VegetarianPizzaEquiv2. Not equivalent to VegetarianPizza because PizzaTopping is not coveringPizzaVegetarianaEquivalente2An alternative to VegetarianPizzaEquiv1 that does not require a definition of VegetarianTopping. Perhaps more difficult to maintain. Not equivalent to VegetarianPizzaCoberturaVegetarianaAn example of a covering axiom. VegetarianTopping is equivalent to the union of all toppings in the given axiom. VegetarianToppings can only be Cheese or Vegetable or....etc.Veneziana
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/unit-tests.xml 0000664 0000000 0000000 00000001227 12571703675 0026673 0 ustar 00root root 0000000 0000000
xmlcatalog-org.protege.xmlcatalog-1.0.5/src/test/resources/versioned.owl 0000664 0000000 0000000 00000001647 12571703675 0026561 0 ustar 00root root 0000000 0000000
]>