diff options
62 files changed, 713 insertions, 713 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ea5c3aa..72273d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,7 +169,7 @@ ADD_LIBRARY(ousia_core src/core/managed/Managed src/core/managed/Manager src/core/model/Document - src/core/model/Domain + src/core/model/Ontology src/core/model/Index src/core/model/Node src/core/model/Project @@ -181,7 +181,7 @@ ADD_LIBRARY(ousia_core src/core/parser/ParserScope src/core/parser/stack/Callbacks src/core/parser/stack/DocumentHandler - src/core/parser/stack/DomainHandler + src/core/parser/stack/OntologyHandler src/core/parser/stack/GenericParserStates src/core/parser/stack/Handler src/core/parser/stack/ImportIncludeHandler @@ -316,7 +316,7 @@ IF(TEST) test/core/managed/ManagedTest test/core/managed/ManagerTest test/core/managed/VariantObjectTest - test/core/model/DomainTest + test/core/model/OntologyTest test/core/model/DocumentTest test/core/model/IndexTest test/core/model/NodeTest diff --git a/data/domain/bibliography.osxml b/data/ontology/bibliography.osxml index 5953e5f..e133a2b 100644 --- a/data/domain/bibliography.osxml +++ b/data/ontology/bibliography.osxml @@ -1,8 +1,8 @@ <?xml version="1.0"?> -<domain name="bibliography"> +<ontology name="bibliography"> - <import rel="domain" src="book"/> - <import rel="domain" src="meta"/> + <import rel="ontology" src="book"/> + <import rel="ontology" src="meta"/> <struct name="bibliography" transparent="true"> <field> @@ -39,4 +39,4 @@ <!-- here some kind of database reference would be better --> <primitive type="string"/> </struct> -</domain> +</ontology> diff --git a/data/domain/book.osxml b/data/ontology/book.osxml index 8ec60ed..41dc788 100644 --- a/data/domain/book.osxml +++ b/data/ontology/book.osxml @@ -1,5 +1,5 @@ <?xml version="1.0" standalone="yes"?> -<domain name="book"> +<ontology name="book"> <struct name="book" cardinality="{1}" isRoot="true"> <field> <childRef ref="book.chapter"/> @@ -31,4 +31,4 @@ <struct name="text" transparent="true"> <primitive type="string"/> </struct> -</domain> +</ontology> diff --git a/data/domain/comments.osxml b/data/ontology/comments.osxml index cb19bd4..621fe1c 100644 --- a/data/domain/comments.osxml +++ b/data/ontology/comments.osxml @@ -1,6 +1,6 @@ <?xml version="1.0" standalone="yes"?> -<domain name="comments"> - <import rel="domain" src="book"/> +<ontology name="comments"> + <import rel="ontology" src="book"/> <!-- an annotation comment --> <annotation name="comment"> @@ -37,4 +37,4 @@ <childRef ref="book.paragraph"/> </field> </struct> -</domain> +</ontology> diff --git a/data/domain/headings.osxml b/data/ontology/headings.osxml index 055a204..1319306 100644 --- a/data/domain/headings.osxml +++ b/data/ontology/headings.osxml @@ -1,7 +1,7 @@ <?xml version="1.0" standalone="yes"?> -<domain name="headings"> +<ontology name="headings"> - <import rel="domain" src="book"/> + <import rel="ontology" src="book"/> <struct name="heading" cardinality="1" transparent="true"> <!-- The parent mechanism is a curious thing. Remind yourself @@ -26,8 +26,8 @@ <!-- regarding its fields we have a problem here. We do not want to declare a new field, because in fact we want to allow every bit of content that a paragraph would allow - also considering - possible extensions of paragraph by other domains. + possible extensions of paragraph by other ontologys. So we need to reference the default field of paragraph. --> <fieldRef ref="book.paragraph.$default"/> </struct> -</domain> +</ontology> diff --git a/data/domain/lists.osxml b/data/ontology/lists.osxml index 66e77cb..a177cd4 100644 --- a/data/domain/lists.osxml +++ b/data/ontology/lists.osxml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<domain name="lists"> - <import rel="domain" src="book"/> +<ontology name="lists"> + <import rel="ontology" src="book"/> <struct name="ul" isa="book.paragraph"> <!-- Here we solve the problem of parents using the isa @@ -23,4 +23,4 @@ <childRef name="book.paragaph"/> </field> </struct> -</domain> +</ontology> diff --git a/data/domain/meta.osxml b/data/ontology/meta.osxml index b595f39..6b25305 100644 --- a/data/domain/meta.osxml +++ b/data/ontology/meta.osxml @@ -1,11 +1,11 @@ <?xml version="1.0"?> -<domain name="meta"> +<ontology name="meta"> <import rel="typesystem" src="affiliation"/> <import rel="typesystem" src="email"/> <import rel="typesystem" src="version"/> - <import rel="domain" src="book"/> - <import rel="domain" src="headings"/> + <import rel="ontology" src="book"/> + <import rel="ontology" src="headings"/> <struct name="meta" cardinality="{1}" transparent="true"> <field> @@ -47,4 +47,4 @@ <struct name="version" cardinality="{0-1}"> <primitive type="version"/> </struct> -</domain> +</ontology> diff --git a/src/cli/Main.cpp b/src/cli/Main.cpp index d03735d..2fe0585 100644 --- a/src/cli/Main.cpp +++ b/src/cli/Main.cpp @@ -41,7 +41,7 @@ #include <core/frontend/TerminalLogger.hpp> #include <core/managed/Manager.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Project.hpp> #include <core/model/Typesystem.hpp> #include <core/parser/ParserContext.hpp> @@ -120,7 +120,7 @@ int main(int argc, char **argv) "The input document file name")( "include,I", po::value<std::vector<std::string>>(), "Include paths, where resources like the input document " - "or additional domains, typesystems, etc. might be " + "or additional ontologies, typesystems, etc. might be " "found.")( "output,o", po::value<std::string>(&outputPath), "The output file name. Per default the input file name will be used.")( @@ -234,11 +234,11 @@ int main(int argc, char **argv) OsxmlParser osxmlParser; registry.registerParser( {"text/vnd.ousia.osml"}, - {&RttiTypes::Document, &RttiTypes::Domain, &RttiTypes::Typesystem}, + {&RttiTypes::Document, &RttiTypes::Ontology, &RttiTypes::Typesystem}, &osmlParser); registry.registerParser( {"text/vnd.ousia.osml+xml"}, - {&RttiTypes::Document, &RttiTypes::Domain, &RttiTypes::Typesystem}, + {&RttiTypes::Document, &RttiTypes::Ontology, &RttiTypes::Typesystem}, &osxmlParser); registry.registerResourceLocator(&fileLocator); diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index 2fcd20d..fc39348 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -723,7 +723,7 @@ void Document::doResolve(ResolutionState &state) if (root != nullptr) { continueResolveCompositum(root, state); } - continueResolveReferences(domains, state); + continueResolveReferences(ontologies, state); continueResolveReferences(typesystems, state); } @@ -761,8 +761,8 @@ bool Document::doValidate(Logger &logger) const void Document::doReference(Handle<Node> node) { - if (node->isa(&RttiTypes::Domain)) { - referenceDomain(node.cast<Domain>()); + if (node->isa(&RttiTypes::Ontology)) { + referenceOntology(node.cast<Ontology>()); } if (node->isa(&RttiTypes::Typesystem)) { referenceTypesystem(node.cast<Typesystem>()); @@ -771,7 +771,7 @@ void Document::doReference(Handle<Node> node) RttiSet Document::doGetReferenceTypes() const { - return RttiSet{&RttiTypes::Domain, &RttiTypes::Typesystem}; + return RttiSet{&RttiTypes::Ontology, &RttiTypes::Typesystem}; } Rooted<StructuredEntity> Document::createRootStructuredEntity( diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp index a5e40ce..dc0f73f 100644 --- a/src/core/model/Document.hpp +++ b/src/core/model/Document.hpp @@ -22,29 +22,29 @@ * This header contains the class hierarchy of actual document classes. A graph * of connected instances of these nodes is a "Document". How the different * DocumentEntity instances may be connected within the graph is subject to the - * specification in the respective Domain(s) (see also the Domain.hpp). + * specification in the respective Ontology(s) (see also the Ontology.hpp). * * A Document, from top to bottom, consists of "Document" instance, * which "owns" the structural root node of the in-document graph. This might - * for example be a "book" node of the "book" domain. That root node in turn has + * for example be a "book" node of the "book" ontology. That root node in turn has * structure nodes as children, which in turn may have children. This * constitutes a Structure Tree. Additionally annotations may be attached to * Structure Nodes, effectively resulting in a Document Graph instead of a * Document Tree (other references may introduce cycles as well). * - * Consider this XML representation of a document using the "book" domain: + * Consider this XML representation of a document using the "book" ontology: * * \code{.xml} * <doc> * <head> - * <import rel="domain" src="book_domain.oxm"/> - * <import rel="domain" src="emphasized_domain.oxm"/> + * <import rel="ontology" src="book_ontology.oxm"/> + * <import rel="ontology" src="emphasized_ontology.oxm"/> * <alias tag="paragraph" aka="p"/> * </head> * <book> * This might be some introductory text or a dedication. Ideally, of * course, such elements would be semantically specified as such in - * additional domains (or in this one). + * additional ontologies (or in this one). * <chapter name="myFirstChapter"> * Here we might have an introduction to the chapter, including some * overview of the chapters structure. @@ -63,9 +63,9 @@ * \endcode * * As can be seen the StructureEntities inherently follow a tree structure that - * is restricted by the implicit context free grammar of the "book" Domain + * is restricted by the implicit context free grammar of the "book" Ontology * definition (e.g. it is not allowed to have a "book" node inside a "section"; - * refer to te Domain.hpp for more information). + * refer to te Ontology.hpp for more information). * * Another interesting fact is the special place of AnnotationEntities: They are * Defined by start and end Anchors in the text. Note that this allows for @@ -114,7 +114,7 @@ #include <core/common/Variant.hpp> #include "Node.hpp" -#include "Domain.hpp" +#include "Ontology.hpp" #include "RootNode.hpp" #include "Typesystem.hpp" @@ -131,7 +131,7 @@ class Anchor; /** * A DocumentEntity is the common superclass for StructuredEntities and - * AnnotationEntities. Similarly to DescriptorEntity in the Domain.hpp it + * AnnotationEntities. Similarly to DescriptorEntity in the Ontology.hpp it * defines that each node in the Document graph may have attributes (in form * of a struct Variant), and fields. * The fields here are a vector of vectors. The first vector implements all @@ -215,7 +215,7 @@ public: * If the name is unknown an exception is thrown. * * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return a NodeVector of all StructuredEntities in that field. */ const NodeVector<StructureNode> &getField( @@ -243,7 +243,7 @@ public: * If the index is out of bounds an exception is thrown. * * @param idx is the index of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return a NodeVector of all StructuredEntities in that field. */ const NodeVector<StructureNode> &getField(const size_t &idx) const; @@ -257,7 +257,7 @@ public: * * @param s is the StructureNode that shall be added. * @param fieldIdx is the index of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. */ void addStructureNode(Handle<StructureNode> s, const size_t &fieldIdx); /** @@ -271,7 +271,7 @@ public: * * @param s is the StructureNode that shall be added. * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. */ void addStructureNode(Handle<StructureNode> s, const std::string &fieldName = DEFAULT_FIELD_NAME); @@ -287,7 +287,7 @@ public: * * @param ss are the StructureNodes that shall be added. * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. */ void addStructureNodes(const std::vector<Handle<StructureNode>> &ss, const std::string &fieldName = DEFAULT_FIELD_NAME); @@ -298,7 +298,7 @@ public: * * @param s is the StructureNode that shall be removed. * @param fieldIdx is the index of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return true if this StructureNode was a child here and false if * if was not found. */ @@ -313,7 +313,7 @@ public: * * @param s is the StructureNode that shall be removed. * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return true if this StructureNode was a child here and false if * if was not found. */ @@ -866,7 +866,7 @@ public: /** * A Document is mainly a wrapper for the Root structure node of the Document - * Graph. It also references the domains that have been used within this + * Graph. It also references the ontologies that have been used within this * document and the AnnotationEntities that span over Anchors in this Document. */ class Document : public RootNode { @@ -874,7 +874,7 @@ private: // TODO: Might there be several roots? E.g. metadata? Owned<StructuredEntity> root; NodeVector<AnnotationEntity> annotations; - NodeVector<Domain> domains; + NodeVector<Ontology> ontologies; NodeVector<Typesystem> typesystems; protected: @@ -893,7 +893,7 @@ public: Document(Manager &mgr, std::string name) : RootNode(mgr, std::move(name), nullptr), annotations(this), - domains(this), + ontologies(this), typesystems(this) { } @@ -987,30 +987,30 @@ public: std::string name = ""); /** - * Returns a const reference to the NodeVector of Domains that are used + * Returns a const reference to the NodeVector of ontologies that are used * within this Document. * - * @return a const reference to the NodeVector of Domains that are used + * @return a const reference to the NodeVector of ontologies that are used * within this Document. */ - const NodeVector<Domain> &getDomains() const { return domains; } + const NodeVector<Ontology> &getOntologys() const { return ontologies; } /** - * Adds a Domain reference to this Document. + * Adds a Ontology reference to this Document. */ - void referenceDomain(Handle<Domain> d) + void referenceOntology(Handle<Ontology> d) { invalidate(); - domains.push_back(d); + ontologies.push_back(d); } /** - * Adds multiple Domain references to this Document. + * Adds multiple Ontology references to this Document. */ - void referenceDomains(const std::vector<Handle<Domain>> &d) + void referenceOntologys(const std::vector<Handle<Ontology>> &d) { invalidate(); - domains.insert(domains.end(), d.begin(), d.end()); + ontologies.insert(ontologies.end(), d.begin(), d.end()); } /** diff --git a/src/core/model/Node.hpp b/src/core/model/Node.hpp index fe8db16..0567e67 100644 --- a/src/core/model/Node.hpp +++ b/src/core/model/Node.hpp @@ -88,7 +88,7 @@ struct ResolutionResult { /** * Root node of the subtree in which the node was found. This e.g. points to - * the Domain in which a Structure was defined or the Typesystem in which a + * the Ontology in which a Structure was defined or the Typesystem in which a * Type was defined. May be nullptr. */ Rooted<Node> resolutionRoot; @@ -119,7 +119,7 @@ class ResolutionState; /** * The Node class builds the base class for any Node within the DOM graph. A - * node may either be a descriptive node (such as a domain description etc.) + * node may either be a descriptive node (such as a ontology description etc.) * or a document element. Each node is identified by acharacteristic name and * a parent element. Note that the node name is not required to be unique. Nodes * without parent are considered root nodes. diff --git a/src/core/model/Domain.cpp b/src/core/model/Ontology.cpp index 8255401..8829139 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Ontology.cpp @@ -23,7 +23,7 @@ #include <core/common/RttiBuilder.hpp> #include <core/common/Exceptions.hpp> -#include "Domain.hpp" +#include "Ontology.hpp" namespace ousia { @@ -416,9 +416,9 @@ bool Descriptor::doValidate(Logger &logger) const std::string("Descriptor \"") + getName() + "\" has no parent!", *this); valid = false; - } else if (!getParent()->isa(&RttiTypes::Domain)) { + } else if (!getParent()->isa(&RttiTypes::Ontology)) { logger.error(std::string("The parent of Descriptor \"") + getName() + - "\" is not a Domain!", + "\" is not a Ontology!", *this); valid = false; } @@ -672,10 +672,10 @@ std::pair<Rooted<FieldDescriptor>, bool> Descriptor::createFieldDescriptor( /* Class StructuredClass */ StructuredClass::StructuredClass(Manager &mgr, std::string name, - Handle<Domain> domain, Variant cardinality, + Handle<Ontology> ontology, Variant cardinality, Handle<StructuredClass> superclass, bool transparent, bool root) - : Descriptor(mgr, std::move(name), domain), + : Descriptor(mgr, std::move(name), ontology), cardinality(cardinality), superclass(acquire(superclass)), subclasses(this), @@ -686,8 +686,8 @@ StructuredClass::StructuredClass(Manager &mgr, std::string name, if (superclass != nullptr) { superclass->addSubclass(this, logger); } - if (domain != nullptr) { - domain->addStructuredClass(this); + if (ontology != nullptr) { + ontology->addStructuredClass(this); } } @@ -843,27 +843,27 @@ NodeVector<FieldDescriptor> StructuredClass::getFieldDescriptors() const /* Class AnnotationClass */ AnnotationClass::AnnotationClass(Manager &mgr, std::string name, - Handle<Domain> domain) - : Descriptor(mgr, std::move(name), domain) + Handle<Ontology> ontology) + : Descriptor(mgr, std::move(name), ontology) { - if (domain != nullptr) { - domain->addAnnotationClass(this); + if (ontology != nullptr) { + ontology->addAnnotationClass(this); } } -/* Class Domain */ +/* Class Ontology */ -void Domain::doResolve(ResolutionState &state) +void Ontology::doResolve(ResolutionState &state) { continueResolveComposita(structuredClasses, structuredClasses.getIndex(), state); continueResolveComposita(annotationClasses, annotationClasses.getIndex(), state); continueResolveReferences(typesystems, state); - continueResolveReferences(domains, state); + continueResolveReferences(ontologies, state); } -bool Domain::doValidate(Logger &logger) const +bool Ontology::doValidate(Logger &logger) const { // check validity of name, of StructuredClasses, of AnnotationClasses and // TypeSystems. @@ -873,22 +873,22 @@ bool Domain::doValidate(Logger &logger) const continueValidationCheckDuplicates(typesystems, logger); } -void Domain::doReference(Handle<Node> node) +void Ontology::doReference(Handle<Node> node) { if (node->isa(&RttiTypes::Typesystem)) { referenceTypesystem(node.cast<Typesystem>()); } - if (node->isa(&RttiTypes::Domain)) { - referenceDomain(node.cast<Domain>()); + if (node->isa(&RttiTypes::Ontology)) { + referenceOntology(node.cast<Ontology>()); } } -RttiSet Domain::doGetReferenceTypes() const +RttiSet Ontology::doGetReferenceTypes() const { - return RttiSet{&RttiTypes::Domain, &RttiTypes::Typesystem}; + return RttiSet{&RttiTypes::Ontology, &RttiTypes::Typesystem}; } -void Domain::addStructuredClass(Handle<StructuredClass> s) +void Ontology::addStructuredClass(Handle<StructuredClass> s) { // only add it if we need to. if (structuredClasses.find(s) == structuredClasses.end()) { @@ -899,13 +899,13 @@ void Domain::addStructuredClass(Handle<StructuredClass> s) if (par != this) { if (par != nullptr) { // remove the StructuredClass from the old parent. - par.cast<Domain>()->removeStructuredClass(s); + par.cast<Ontology>()->removeStructuredClass(s); } s->setParent(this); } } -bool Domain::removeStructuredClass(Handle<StructuredClass> s) +bool Ontology::removeStructuredClass(Handle<StructuredClass> s) { auto it = structuredClasses.find(s); if (it != structuredClasses.end()) { @@ -917,7 +917,7 @@ bool Domain::removeStructuredClass(Handle<StructuredClass> s) return false; } -Rooted<StructuredClass> Domain::createStructuredClass( +Rooted<StructuredClass> Ontology::createStructuredClass( std::string name, Variant cardinality, Handle<StructuredClass> superclass, bool transparent, bool root) { @@ -926,7 +926,7 @@ Rooted<StructuredClass> Domain::createStructuredClass( std::move(transparent), std::move(root))}; } -void Domain::addAnnotationClass(Handle<AnnotationClass> a) +void Ontology::addAnnotationClass(Handle<AnnotationClass> a) { // only add it if we need to. if (annotationClasses.find(a) == annotationClasses.end()) { @@ -937,13 +937,13 @@ void Domain::addAnnotationClass(Handle<AnnotationClass> a) if (par != this) { if (par != nullptr) { // remove the StructuredClass from the old parent. - par.cast<Domain>()->removeAnnotationClass(a); + par.cast<Ontology>()->removeAnnotationClass(a); } a->setParent(this); } } -bool Domain::removeAnnotationClass(Handle<AnnotationClass> a) +bool Ontology::removeAnnotationClass(Handle<AnnotationClass> a) { auto it = annotationClasses.find(a); if (it != annotationClasses.end()) { @@ -955,7 +955,7 @@ bool Domain::removeAnnotationClass(Handle<AnnotationClass> a) return false; } -Rooted<AnnotationClass> Domain::createAnnotationClass(std::string name) +Rooted<AnnotationClass> Ontology::createAnnotationClass(std::string name) { return Rooted<AnnotationClass>{ new AnnotationClass(getManager(), std::move(name), this)}; @@ -974,7 +974,7 @@ const Rtti StructuredClass = .composedOf(&FieldDescriptor); const Rtti AnnotationClass = RttiBuilder<ousia::AnnotationClass>("AnnotationClass").parent(&Descriptor); -const Rtti Domain = RttiBuilder<ousia::Domain>("Domain") +const Rtti Ontology = RttiBuilder<ousia::Ontology>("Ontology") .parent(&RootNode) .composedOf({&StructuredClass, &AnnotationClass}); } diff --git a/src/core/model/Domain.hpp b/src/core/model/Ontology.hpp index 7e10d91..948caa5 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Ontology.hpp @@ -17,11 +17,11 @@ */ /** - * @file Domain.hpp + * @file Ontology.hpp * - * This header contains the class hierarchy of descriptor classes for domains. - * Properly connected instances of these classes with a Domain node as root - * describe a semantic Domain in a formal way. It specifies the allowed (tree) + * This header contains the class hierarchy of descriptor classes for ontologies. + * Properly connected instances of these classes with a Ontology node as root + * describe a semantic Ontology in a formal way. It specifies the allowed (tree) * structure of a document by means of StructuredClasses as well as the allowed * Annotations by means of AnnotationClasses. * @@ -33,7 +33,7 @@ * book and one for the actual structure. Consider the following XML: * * \code{.xml} - * <domain name="book"> + * <ontology name="book"> * <struct name="book" cardinality="1" isRoot="true"> * <field> * <childRef ref="book.chapter"/> @@ -65,7 +65,7 @@ * <struct name="text" transparent="true"> * <primitive type="string"/> * </struct> - * </domain> + * </ontology> * \endcode * * Note that we define one field as the TREE (meaning the main or default @@ -95,12 +95,12 @@ * the proper StructuredClass. This can be regulated by the "cardinality" * property of a StructuredClass. * - * It is possible to add further fields, like we would in the "headings" domain + * It is possible to add further fields, like we would in the "headings" ontology * to add titles to our structure. * * \code{.xml} - * <domain name="headings"> - * <import rel="domain" src="./book_domain.osxml"/> + * <ontology name="headings"> + * <import rel="ontology" src="./book_ontology.osxml"/> * <struct name="heading" cardinality="1" transparent="true"> * <parentRef ref="book.book"> * <field name="heading" isSubtree="true" optional="true"/> @@ -108,7 +108,7 @@ * ... * <fieldRef name="book.paragraph."> * </struct> - * </domain> + * </ontology> * \endcode * * This would change the context free grammar as follows: @@ -119,14 +119,14 @@ * \endcode * * AnnotationClasses on the other hand do not specify a context free grammar. - * They merely specify what kinds of Annotations are allowed within this domain + * They merely specify what kinds of Annotations are allowed within this ontology * and which fields or attributes they have. Note that Annotations are allowed * to define structured children that manifest e.g. meta information of that - * Annotation. An example for that would be the "comment" domain: + * Annotation. An example for that would be the "comment" ontology: * * \code{.xml} - * <domain name="comments"> - * <import rel="domain" src="./book_domain.osxml"/> + * <ontology name="comments"> + * <import rel="ontology" src="./book_ontology.osxml"/> * * <annotation name="comment"> * <field name="content" isSubtree="true"> @@ -156,7 +156,7 @@ * <childRef ref="reply"/> * </field> * </struct> - * </domain> + * </ontology> * \endcode * * Here we have comment annotations, which have a reply tree as sub structure. @@ -180,7 +180,7 @@ namespace ousia { class Rtti; class Descriptor; class StructuredClass; -class Domain; +class Ontology; /** * Magic field name used to identify the default field. The default field is @@ -481,8 +481,8 @@ protected: bool doValidate(Logger &logger) const override; public: - Descriptor(Manager &mgr, std::string name, Handle<Domain> domain) - : Node(mgr, std::move(name), domain), + Descriptor(Manager &mgr, std::string name, Handle<Ontology> ontology) + : Node(mgr, std::move(name), ontology), attributesDescriptor(acquire(new StructType(mgr, "", nullptr))), fieldDescriptors(this) { @@ -490,10 +490,10 @@ public: /** * Returns a reference to the StructType that specifies the attribute keys - * as well as value domains for this Descriptor. + * as well as value ontologies for this Descriptor. * * @return a reference to the StructType that specifies the attribute keys - * as well as value domains for this Descriptor. + * as well as value ontologies for this Descriptor. */ Rooted<StructType> getAttributesDescriptor() const { @@ -645,7 +645,7 @@ public: /** * This tries to construct the shortest possible path of this Descriptor - * to the given child Descriptor. As an example consider the book domain + * to the given child Descriptor. As an example consider the book ontology * from above. * * First consider the call book->pathTo(chapter). This is an easy example: @@ -729,17 +729,17 @@ public: /** * A StructuredClass specifies nodes in the StructureTree of a document that - * implements this domain. For more information on the StructureTree please + * implements this ontology. For more information on the StructureTree please * consult the Header documentation above. * - * Note that a StructuredClass may "invade" an existing Domain description by + * Note that a StructuredClass may "invade" an existing Ontology description by * defining itself as a viable child in one existing field. Consider the - * example of the "heading" domain from the header documentation again: + * example of the "heading" ontology from the header documentation again: * * \code{.xml} - * <domain name="headings"> + * <ontology name="headings"> * <head> - * <import rel="domain" src="book.oxm"/> + * <import rel="ontology" src="book.oxm"/> * </head> * <structs> * <struct name="heading" cardinality="0-1" transparent="true"> @@ -753,14 +753,14 @@ public: * <fieldRef name="book.paragraph."> * </fields> * </structs> - * </domain> + * </ontology> * \endcode * - * The "parent" construct allows to "invade" another domain. + * The "parent" construct allows to "invade" another ontology. * - * This does indeed interfere with an existing domain and one must carefully + * This does indeed interfere with an existing ontology and one must carefully * craft such parent references to not create undesired side effects. However - * they provide the most convenient mechanism to extend existing domains + * they provide the most convenient mechanism to extend existing ontologies * without having to rewrite them. * * Another important factor is the 'transparent' flag. Transparent @@ -798,7 +798,7 @@ public: * Inheritance therefore also goes for fields. */ class StructuredClass : public Descriptor { - friend Domain; + friend Ontology; private: const Variant cardinality; @@ -824,7 +824,7 @@ public: * * @param mgr is the current Manager. * @param name is the name of the StructuredClass. - * @param domain is the Domain this StructuredClass belongs + * @param ontology is the Ontology this StructuredClass belongs * to. * @param cardinality specifies how often an element of this type * may occur at a specific point in the @@ -846,7 +846,7 @@ public: * allowed to be at the root of a Document. */ StructuredClass(Manager &mgr, std::string name, - Handle<Domain> domain = nullptr, + Handle<Ontology> ontology = nullptr, Variant cardinality = Cardinality::any(), Handle<StructuredClass> superclass = nullptr, bool transparent = false, bool root = false); @@ -972,7 +972,7 @@ public: * This class has no special properties and is in essence just a Descriptor. */ class AnnotationClass : public Descriptor { - friend Domain; + friend Ontology; public: /** @@ -983,18 +983,18 @@ public: * @param name is a name for this AnnotationClass that will * be used for later references to this * AnnotationClass. - * @param domain is the Domain this AnnotationClass belongs + * @param ontology is the Ontology this AnnotationClass belongs * to. */ - AnnotationClass(Manager &mgr, std::string name, Handle<Domain> domain); + AnnotationClass(Manager &mgr, std::string name, Handle<Ontology> ontology); }; /** - * A Domain node specifies which StructuredClasses and which AnnotationClasses - * are part of this domain. TODO: Do we want to be able to restrict Annotations + * A Ontology node specifies which StructuredClasses and which AnnotationClasses + * are part of this ontology. TODO: Do we want to be able to restrict Annotations * to certain Structures? */ -class Domain : public RootNode { +class Ontology : public RootNode { friend StructuredClass; friend AnnotationClass; @@ -1002,7 +1002,7 @@ private: NodeVector<StructuredClass> structuredClasses; NodeVector<AnnotationClass> annotationClasses; NodeVector<Typesystem> typesystems; - NodeVector<Domain> domains; + NodeVector<Ontology> ontologies; protected: void doResolve(ResolutionState &state) override; @@ -1012,81 +1012,81 @@ protected: public: /** - * The constructor for a new domain. Note that this is an empty Domain and + * The constructor for a new ontology. Note that this is an empty Ontology and * still has to be filled with StructuredClasses and AnnotationClasses. * * @param mgr is the Manager instance. - * @param name is a name for this domain which will be used for later - * references to this Domain. + * @param name is a name for this ontology which will be used for later + * references to this Ontology. */ - Domain(Manager &mgr, std::string name = "") + Ontology(Manager &mgr, std::string name = "") : RootNode(mgr, std::move(name), nullptr), structuredClasses(this), annotationClasses(this), typesystems(this), - domains(this) + ontologies(this) { } /** - * The constructor for a new domain. Note that this is an empty Domain and + * The constructor for a new ontology. Note that this is an empty Ontology and * still has to be filled with StructuredClasses and AnnotationClasses. * * @param mgr is the Manager instance. * @param sys is the SystemTypesystem instance. - * @param name is a name for this domain which will be used for later - * references to this Domain. + * @param name is a name for this ontology which will be used for later + * references to this Ontology. */ - Domain(Manager &mgr, Handle<SystemTypesystem> sys, std::string name = "") - : Domain(mgr, std::move(name)) + Ontology(Manager &mgr, Handle<SystemTypesystem> sys, std::string name = "") + : Ontology(mgr, std::move(name)) { referenceTypesystem(sys); } /** - * Creates a new Domain and returns it. + * Creates a new Ontology and returns it. * * @param mgr is the Manager instance. - * @param name is a name for this domain which will be used for later - * references to this Domain. + * @param name is a name for this ontology which will be used for later + * references to this Ontology. */ - static Rooted<Domain> createEmptyDomain(Manager &mgr, std::string name) + static Rooted<Ontology> createEmptyOntology(Manager &mgr, std::string name) { - return Rooted<Domain>{new Domain(mgr, std::move(name))}; + return Rooted<Ontology>{new Ontology(mgr, std::move(name))}; } /** * Returns a const reference to the NodeVector of StructuredClasses that are - * part of this Domain. + * part of this Ontology. * * @return a const reference to the NodeVector of StructuredClasses that are - * part of this Domain. + * part of this Ontology. */ const NodeVector<StructuredClass> &getStructureClasses() const { return structuredClasses; } /** - * Adds a StructuredClass to this domain. This also sets the parent of the - * given StructuredClass if it is not set to this Domain already and removes - * it from the old Domain. + * Adds a StructuredClass to this ontology. This also sets the parent of the + * given StructuredClass if it is not set to this Ontology already and removes + * it from the old Ontology. * * @param s is some StructuredClass. */ void addStructuredClass(Handle<StructuredClass> s); /** - * Removes a StructuredClass from this domain. This also sets the parent of + * Removes a StructuredClass from this ontology. This also sets the parent of * the given StructuredClass to null. * * @param s is some StructuredClass. * @return true if the given StructuredClass was removed and false if this - * Domain did not have the given StructuredClass as child. + * Ontology did not have the given StructuredClass as child. */ bool removeStructuredClass(Handle<StructuredClass> s); /** - * This creates a new StructuredClass and appends it to this Domain. + * This creates a new StructuredClass and appends it to this Ontology. * * @param name is the name of the StructuredClass. * @param cardinality specifies how often an element of this type @@ -1117,36 +1117,36 @@ public: /** * Returns a const reference to the NodeVector of AnnotationClasses that are - * part of this Domain. + * part of this Ontology. * * @return a const reference to the NodeVector of AnnotationClasses that are - * part of this Domain. + * part of this Ontology. */ const NodeVector<AnnotationClass> &getAnnotationClasses() const { return annotationClasses; } /** - * Adds an AnnotationClass to this domain. This also sets the parent of the - * given AnnotationClass if it is not set to this Domain already and removes - * it from the old Domain. + * Adds an AnnotationClass to this ontology. This also sets the parent of the + * given AnnotationClass if it is not set to this Ontology already and removes + * it from the old Ontology. * * @param a is some AnnotationClass. */ void addAnnotationClass(Handle<AnnotationClass> a); /** - * Removes a AnnotationClass from this domain. This also sets the parent of + * Removes a AnnotationClass from this ontology. This also sets the parent of * the given AnnotationClass to null. * * @param a is some AnnotationClass. * @return true if the given AnnotationClass was removed and false if this - * Domain did not have the given AnnotationClass as child. + * Ontology did not have the given AnnotationClass as child. */ bool removeAnnotationClass(Handle<AnnotationClass> a); /** - * This creates a new AnnotationClass and appends it to this Domain. + * This creates a new AnnotationClass and appends it to this Ontology. * * @param name is a name for this AnnotationClass that will * be used for later references to this @@ -1156,20 +1156,20 @@ public: /** * Returns a const reference to the NodeVector of TypeSystems that are - * references in this Domain. + * references in this Ontology. * * @return a const reference to the NodeVector of TypeSystems that are - * references in this Domain. + * references in this Ontology. */ const NodeVector<Typesystem> &getTypesystems() const { return typesystems; } /** - * Adds a Typesystem reference to this Domain. + * Adds a Typesystem reference to this Ontology. */ void referenceTypesystem(Handle<Typesystem> t) { typesystems.push_back(t); } /** - * Adds multiple Typesystem references to this Domain. + * Adds multiple Typesystem references to this Ontology. */ void referenceTypesystems(const std::vector<Handle<Typesystem>> &ts) { @@ -1177,16 +1177,16 @@ public: } /** - * Adds a Domain reference to this Domain. + * Adds a Ontology reference to this Ontology. */ - void referenceDomain(Handle<Domain> d) { domains.push_back(d); } + void referenceOntology(Handle<Ontology> d) { ontologies.push_back(d); } /** - * Adds multiple Domain references to this Domain. + * Adds multiple Ontology references to this Ontology. */ - void referenceDomains(const std::vector<Handle<Domain>> &ds) + void referenceOntologys(const std::vector<Handle<Ontology>> &ds) { - domains.insert(domains.end(), ds.begin(), ds.end()); + ontologies.insert(ontologies.end(), ds.begin(), ds.end()); } }; @@ -1196,7 +1196,7 @@ extern const Rtti FieldDescriptor; extern const Rtti Descriptor; extern const Rtti StructuredClass; extern const Rtti AnnotationClass; -extern const Rtti Domain; +extern const Rtti Ontology; } } diff --git a/src/core/model/Project.cpp b/src/core/model/Project.cpp index f7dab8a..ecc0589 100644 --- a/src/core/model/Project.cpp +++ b/src/core/model/Project.cpp @@ -18,7 +18,7 @@ #include <core/common/RttiBuilder.hpp> -#include "Domain.hpp" +#include "Ontology.hpp" #include "Document.hpp" #include "Project.hpp" #include "Typesystem.hpp" @@ -69,9 +69,9 @@ Rooted<Document> Project::createDocument(const std::string &name) return document; } -Rooted<Domain> Project::createDomain(const std::string &name) +Rooted<Ontology> Project::createOntology(const std::string &name) { - return Rooted<Domain>{new Domain(getManager(), systemTypesystem, name)}; + return Rooted<Ontology>{new Ontology(getManager(), systemTypesystem, name)}; } void Project::referenceDocument(Handle<Document> document) diff --git a/src/core/model/Project.hpp b/src/core/model/Project.hpp index 480609c..97c711c 100644 --- a/src/core/model/Project.hpp +++ b/src/core/model/Project.hpp @@ -20,7 +20,7 @@ * @file Project.hpp * * Contains the concept of the "Project" class which represents the entity into - * which domains, documents, typesystems and other resources are embedded. + * which ontologies, documents, typesystems and other resources are embedded. * * @author Andreas Stöckel (astoecke@techfak.uni-bielefeld.de) */ @@ -40,12 +40,12 @@ class Registry; class SystemTypesystem; class Typesystem; class Document; -class Domain; +class Ontology; /** * The Project class constitutes the top-level node in which a collection of * documents are stored. It also contains an instance of the SystemTypesystem - * and allows for simple creation of new Typesystem and Domain instances. + * and allows for simple creation of new Typesystem and Ontology instances. */ class Project : public RootNode { private: @@ -99,12 +99,12 @@ public: Rooted<Document> createDocument(const std::string &name); /** - * Returns a new domain with the given name and adds it to the list of - * domains. Provides a reference of the system typesystem to the domain. + * Returns a new ontology with the given name and adds it to the list of + * ontologies. Provides a reference of the system typesystem to the ontology. * - * @param name is the name of the domain that should be created. + * @param name is the name of the ontology that should be created. */ - Rooted<Domain> createDomain(const std::string &name); + Rooted<Ontology> createOntology(const std::string &name); /** * Adds the given document to the list of documents in the project. diff --git a/src/core/model/RootNode.hpp b/src/core/model/RootNode.hpp index 173a6e4..d26917f 100644 --- a/src/core/model/RootNode.hpp +++ b/src/core/model/RootNode.hpp @@ -37,7 +37,7 @@ namespace ousia { /** * The RootNode class represents a Node that may be a Root node (such as - * Documents, Typesystems and Domains). Root nodes have the property, that the + * Documents, Typesystems and Ontologys). Root nodes have the property, that the * allow importing/referencing other Nodes. */ class RootNode : public Node { diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp index dabb03c..c46dc51 100644 --- a/src/core/parser/ParserScope.cpp +++ b/src/core/parser/ParserScope.cpp @@ -19,7 +19,7 @@ #include <core/common/Exceptions.hpp> #include <core/common/Utils.hpp> #include <core/common/VariantWriter.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include <core/model/RootNode.hpp> diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp index bb04bd3..2144c34 100644 --- a/src/core/parser/stack/DocumentHandler.cpp +++ b/src/core/parser/stack/DocumentHandler.cpp @@ -22,7 +22,7 @@ #include <core/common/Utils.hpp> #include <core/common/VariantReader.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Project.hpp> #include <core/model/Typesystem.hpp> #include <core/parser/ParserScope.hpp> diff --git a/src/core/parser/stack/DocumentHandler.hpp b/src/core/parser/stack/DocumentHandler.hpp index 862081c..44feb2b 100644 --- a/src/core/parser/stack/DocumentHandler.hpp +++ b/src/core/parser/stack/DocumentHandler.hpp @@ -46,7 +46,7 @@ namespace parser_stack { /** * The DocumentHandler class parses the "document" tag that is used to introduce * a new document. Note that this tag is not mandatory in osml files -- if the - * first command is not a typesystem, domain or any other declarative command, + * first command is not a typesystem, ontology or any other declarative command, * the DocumentHandler will be implicitly called. */ class DocumentHandler : public StaticHandler { diff --git a/src/core/parser/stack/GenericParserStates.cpp b/src/core/parser/stack/GenericParserStates.cpp index 69a6e0e..7287524 100644 --- a/src/core/parser/stack/GenericParserStates.cpp +++ b/src/core/parser/stack/GenericParserStates.cpp @@ -17,7 +17,7 @@ */ #include "DocumentHandler.hpp" -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "GenericParserStates.hpp" #include "ImportIncludeHandler.hpp" #include "TypesystemHandler.hpp" @@ -28,18 +28,18 @@ namespace parser_stack { const std::multimap<std::string, const State *> GenericParserStates{ {"document", &States::Document}, {"*", &States::DocumentChild}, - {"domain", &States::Domain}, - {"struct", &States::DomainStruct}, - {"annotation", &States::DomainAnnotation}, - {"attributes", &States::DomainAttributes}, - {"attribute", &States::DomainAttribute}, - {"field", &States::DomainField}, - {"fieldRef", &States::DomainFieldRef}, - {"primitive", &States::DomainStructPrimitive}, - {"childRef", &States::DomainStructChild}, - {"parentRef", &States::DomainStructParent}, - {"field", &States::DomainStructParentField}, - {"fieldRef", &States::DomainStructParentFieldRef}, + {"ontology", &States::Ontology}, + {"struct", &States::OntologyStruct}, + {"annotation", &States::OntologyAnnotation}, + {"attributes", &States::OntologyAttributes}, + {"attribute", &States::OntologyAttribute}, + {"field", &States::OntologyField}, + {"fieldRef", &States::OntologyFieldRef}, + {"primitive", &States::OntologyStructPrimitive}, + {"childRef", &States::OntologyStructChild}, + {"parentRef", &States::OntologyStructParent}, + {"field", &States::OntologyStructParentField}, + {"fieldRef", &States::OntologyStructParentFieldRef}, {"typesystem", &States::Typesystem}, {"enum", &States::TypesystemEnum}, {"entry", &States::TypesystemEnumEntry}, diff --git a/src/core/parser/stack/ImportIncludeHandler.cpp b/src/core/parser/stack/ImportIncludeHandler.cpp index d1ea97d..a6cbaea 100644 --- a/src/core/parser/stack/ImportIncludeHandler.cpp +++ b/src/core/parser/stack/ImportIncludeHandler.cpp @@ -20,7 +20,7 @@ #include <core/parser/ParserScope.hpp> #include <core/parser/ParserContext.hpp> -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "DocumentHandler.hpp" #include "ImportIncludeHandler.hpp" #include "State.hpp" @@ -38,7 +38,7 @@ void ImportHandler::doHandle(const Variant &fieldData, Variant::mapType &args) Rooted<Node> leaf = scope().getLeaf(); if (leaf == nullptr || !leaf->isa(&RttiTypes::RootNode)) { logger().error( - "Import not supported here, must be inside a document, domain " + "Import not supported here, must be inside a document, ontology " "or typesystem command.", location()); return; @@ -66,7 +66,7 @@ void IncludeHandler::doHandle(const Variant &fieldData, Variant::mapType &args) namespace States { const State Import = StateBuilder() - .parents({&Document, &Typesystem, &Domain}) + .parents({&Document, &Typesystem, &Ontology}) .elementHandler(ImportHandler::create) .arguments({Argument::String("rel", ""), Argument::String("type", ""), Argument::String("src", "")}); diff --git a/src/core/parser/stack/DomainHandler.cpp b/src/core/parser/stack/OntologyHandler.cpp index e86f893..8c0e4d9 100644 --- a/src/core/parser/stack/DomainHandler.cpp +++ b/src/core/parser/stack/OntologyHandler.cpp @@ -18,52 +18,52 @@ #include <core/common/RttiBuilder.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Project.hpp> #include <core/parser/ParserScope.hpp> #include <core/parser/ParserContext.hpp> #include "DocumentHandler.hpp" -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "State.hpp" #include "TypesystemHandler.hpp" namespace ousia { namespace parser_stack { -/* DomainHandler */ +/* OntologyHandler */ -bool DomainHandler::start(Variant::mapType &args) +bool OntologyHandler::start(Variant::mapType &args) { - // Create the Domain node - Rooted<Domain> domain = - context().getProject()->createDomain(args["name"].asString()); - domain->setLocation(location()); + // Create the Ontology node + Rooted<Ontology> ontology = + context().getProject()->createOntology(args["name"].asString()); + ontology->setLocation(location()); - // If the domain is defined inside a document, add the reference to the + // If the ontology is defined inside a document, add the reference to the // document Rooted<Document> document = scope().select<Document>(); if (document != nullptr) { - document->reference(domain); + document->reference(ontology); } // Push the typesystem onto the scope, set the POST_HEAD flag to true - scope().push(domain); + scope().push(ontology); scope().setFlag(ParserFlag::POST_HEAD, false); return true; } -void DomainHandler::end() { scope().pop(logger()); } +void OntologyHandler::end() { scope().pop(logger()); } -/* DomainStructHandler */ +/* OntologyStructHandler */ -bool DomainStructHandler::start(Variant::mapType &args) +bool OntologyStructHandler::start(Variant::mapType &args) { scope().setFlag(ParserFlag::POST_HEAD, true); - Rooted<Domain> domain = scope().selectOrThrow<Domain>(); + Rooted<Ontology> ontology = scope().selectOrThrow<Ontology>(); - Rooted<StructuredClass> structuredClass = domain->createStructuredClass( + Rooted<StructuredClass> structuredClass = ontology->createStructuredClass( args["name"].asString(), args["cardinality"].asCardinality(), nullptr, args["transparent"].asBool(), args["isRoot"].asBool()); structuredClass->setLocation(location()); @@ -85,28 +85,28 @@ bool DomainStructHandler::start(Variant::mapType &args) return true; } -void DomainStructHandler::end() { scope().pop(logger()); } +void OntologyStructHandler::end() { scope().pop(logger()); } -/* DomainAnnotationHandler */ -bool DomainAnnotationHandler::start(Variant::mapType &args) +/* OntologyAnnotationHandler */ +bool OntologyAnnotationHandler::start(Variant::mapType &args) { scope().setFlag(ParserFlag::POST_HEAD, true); - Rooted<Domain> domain = scope().selectOrThrow<Domain>(); + Rooted<Ontology> ontology = scope().selectOrThrow<Ontology>(); Rooted<AnnotationClass> annotationClass = - domain->createAnnotationClass(args["name"].asString()); + ontology->createAnnotationClass(args["name"].asString()); annotationClass->setLocation(location()); scope().push(annotationClass); return true; } -void DomainAnnotationHandler::end() { scope().pop(logger()); } +void OntologyAnnotationHandler::end() { scope().pop(logger()); } -/* DomainAttributesHandler */ +/* OntologyAttributesHandler */ -bool DomainAttributesHandler::start(Variant::mapType &args) +bool OntologyAttributesHandler::start(Variant::mapType &args) { // Fetch the current typesystem and create the struct node Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>(); @@ -118,11 +118,11 @@ bool DomainAttributesHandler::start(Variant::mapType &args) return true; } -void DomainAttributesHandler::end() { scope().pop(logger()); } +void OntologyAttributesHandler::end() { scope().pop(logger()); } -/* DomainFieldHandler */ +/* OntologyFieldHandler */ -bool DomainFieldHandler::start(Variant::mapType &args) +bool OntologyFieldHandler::start(Variant::mapType &args) { FieldDescriptor::FieldType type; if (args["isSubtree"].asBool()) { @@ -148,11 +148,11 @@ bool DomainFieldHandler::start(Variant::mapType &args) return true; } -void DomainFieldHandler::end() { scope().pop(logger()); } +void OntologyFieldHandler::end() { scope().pop(logger()); } -/* DomainFieldRefHandler */ +/* OntologyFieldRefHandler */ -bool DomainFieldRefHandler::start(Variant::mapType &args) +bool OntologyFieldRefHandler::start(Variant::mapType &args) { Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>(); @@ -178,11 +178,11 @@ bool DomainFieldRefHandler::start(Variant::mapType &args) return true; } -void DomainFieldRefHandler::end() {} +void OntologyFieldRefHandler::end() {} -/* DomainPrimitiveHandler */ +/* OntologyPrimitiveHandler */ -bool DomainPrimitiveHandler::start(Variant::mapType &args) +bool OntologyPrimitiveHandler::start(Variant::mapType &args) { Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>(); @@ -218,11 +218,11 @@ bool DomainPrimitiveHandler::start(Variant::mapType &args) return true; } -void DomainPrimitiveHandler::end() { scope().pop(logger()); } +void OntologyPrimitiveHandler::end() { scope().pop(logger()); } -/* DomainChildHandler */ +/* OntologyChildHandler */ -bool DomainChildHandler::start(Variant::mapType &args) +bool OntologyChildHandler::start(Variant::mapType &args) { Rooted<FieldDescriptor> field = scope().selectOrThrow<FieldDescriptor>(); @@ -238,26 +238,26 @@ bool DomainChildHandler::start(Variant::mapType &args) return true; } -/* DomainParentHandler */ +/* OntologyParentHandler */ -bool DomainParentHandler::start(Variant::mapType &args) +bool OntologyParentHandler::start(Variant::mapType &args) { Rooted<StructuredClass> strct = scope().selectOrThrow<StructuredClass>(); - Rooted<DomainParent> parent{ - new DomainParent(strct->getManager(), args["ref"].asString(), strct)}; + Rooted<OntologyParent> parent{ + new OntologyParent(strct->getManager(), args["ref"].asString(), strct)}; parent->setLocation(location()); scope().push(parent); return true; } -void DomainParentHandler::end() { scope().pop(logger()); } +void OntologyParentHandler::end() { scope().pop(logger()); } -/* DomainParentFieldHandler */ +/* OntologyParentFieldHandler */ -bool DomainParentFieldHandler::start(Variant::mapType &args) +bool OntologyParentFieldHandler::start(Variant::mapType &args) { - Rooted<DomainParent> parentNameNode = scope().selectOrThrow<DomainParent>(); + Rooted<OntologyParent> parentNameNode = scope().selectOrThrow<OntologyParent>(); FieldDescriptor::FieldType type; if (args["isSubtree"].asBool()) { type = FieldDescriptor::FieldType::SUBTREE; @@ -286,11 +286,11 @@ bool DomainParentFieldHandler::start(Variant::mapType &args) return true; } -/* DomainParentFieldRefHandler */ +/* OntologyParentFieldRefHandler */ -bool DomainParentFieldRefHandler::start(Variant::mapType &args) +bool OntologyParentFieldRefHandler::start(Variant::mapType &args) { - Rooted<DomainParent> parentNameNode = scope().selectOrThrow<DomainParent>(); + Rooted<OntologyParent> parentNameNode = scope().selectOrThrow<OntologyParent>(); const std::string &name = args["ref"].asString(); Rooted<StructuredClass> strct = @@ -318,100 +318,100 @@ bool DomainParentFieldRefHandler::start(Variant::mapType &args) } namespace States { -const State Domain = StateBuilder() +const State Ontology = StateBuilder() .parents({&None, &Document}) - .createdNodeType(&RttiTypes::Domain) - .elementHandler(DomainHandler::create) + .createdNodeType(&RttiTypes::Ontology) + .elementHandler(OntologyHandler::create) .arguments({Argument::String("name")}); -const State DomainStruct = +const State OntologyStruct = StateBuilder() - .parent(&Domain) + .parent(&Ontology) .createdNodeType(&RttiTypes::StructuredClass) - .elementHandler(DomainStructHandler::create) + .elementHandler(OntologyStructHandler::create) .arguments({Argument::String("name"), Argument::Cardinality("cardinality", Cardinality::any()), Argument::Bool("isRoot", false), Argument::Bool("transparent", false), Argument::String("isa", "")}); -const State DomainAnnotation = +const State OntologyAnnotation = StateBuilder() - .parent(&Domain) + .parent(&Ontology) .createdNodeType(&RttiTypes::AnnotationClass) - .elementHandler(DomainAnnotationHandler::create) + .elementHandler(OntologyAnnotationHandler::create) .arguments({Argument::String("name")}); -const State DomainAttributes = +const State OntologyAttributes = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::StructType) - .elementHandler(DomainAttributesHandler::create) + .elementHandler(OntologyAttributesHandler::create) .arguments({}); -const State DomainAttribute = +const State OntologyAttribute = StateBuilder() - .parent(&DomainAttributes) + .parent(&OntologyAttributes) .elementHandler(TypesystemStructFieldHandler::create) .arguments({Argument::String("name"), Argument::String("type"), Argument::Any("default", Variant::fromObject(nullptr))}); -const State DomainField = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) +const State OntologyField = StateBuilder() + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainFieldHandler::create) + .elementHandler(OntologyFieldHandler::create) .arguments({Argument::String("name", ""), Argument::Bool("isSubtree", false), Argument::Bool("optional", false)}); -const State DomainFieldRef = +const State OntologyFieldRef = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainFieldRefHandler::create) + .elementHandler(OntologyFieldRefHandler::create) .arguments({Argument::String("ref", DEFAULT_FIELD_NAME)}); -const State DomainStructPrimitive = +const State OntologyStructPrimitive = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainPrimitiveHandler::create) + .elementHandler(OntologyPrimitiveHandler::create) .arguments( {Argument::String("name", ""), Argument::Bool("isSubtree", false), Argument::Bool("optional", false), Argument::String("type")}); -const State DomainStructChild = StateBuilder() - .parent(&DomainField) - .elementHandler(DomainChildHandler::create) +const State OntologyStructChild = StateBuilder() + .parent(&OntologyField) + .elementHandler(OntologyChildHandler::create) .arguments({Argument::String("ref")}); -const State DomainStructParent = +const State OntologyStructParent = StateBuilder() - .parent(&DomainStruct) - .createdNodeType(&RttiTypes::DomainParent) - .elementHandler(DomainParentHandler::create) + .parent(&OntologyStruct) + .createdNodeType(&RttiTypes::OntologyParent) + .elementHandler(OntologyParentHandler::create) .arguments({Argument::String("ref")}); -const State DomainStructParentField = +const State OntologyStructParentField = StateBuilder() - .parent(&DomainStructParent) + .parent(&OntologyStructParent) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainParentFieldHandler::create) + .elementHandler(OntologyParentFieldHandler::create) .arguments({Argument::String("name", ""), Argument::Bool("isSubtree", false), Argument::Bool("optional", false)}); -const State DomainStructParentFieldRef = +const State OntologyStructParentFieldRef = StateBuilder() - .parent(&DomainStructParent) + .parent(&OntologyStructParent) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainParentFieldRefHandler::create) + .elementHandler(OntologyParentFieldRefHandler::create) .arguments({Argument::String("ref", DEFAULT_FIELD_NAME)}); } } namespace RttiTypes { -const Rtti DomainParent = RttiBuilder<ousia::parser_stack::DomainParent>( - "DomainParent").parent(&Node); +const Rtti OntologyParent = RttiBuilder<ousia::parser_stack::OntologyParent>( + "OntologyParent").parent(&Node); } } diff --git a/src/core/parser/stack/DomainHandler.hpp b/src/core/parser/stack/OntologyHandler.hpp index 76172d6..caeacc7 100644 --- a/src/core/parser/stack/DomainHandler.hpp +++ b/src/core/parser/stack/OntologyHandler.hpp @@ -17,10 +17,10 @@ */ /** - * @file DomainHandler.hpp + * @file OntologyHandler.hpp * - * Contains the Handler classes used for parsing Domain descriptors. This - * includes the "domain" tag and all describing tags below the "domain" tag. + * Contains the Handler classes used for parsing Ontology descriptors. This + * includes the "ontology" tag and all describing tags below the "ontology" tag. * * @author Benjamin Paaßen (bpaassen@techfak.uni-bielefeld.de) */ @@ -42,7 +42,7 @@ namespace parser_stack { // TODO: Documentation -class DomainHandler : public StaticHandler { +class OntologyHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -51,11 +51,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainHandler{handlerData}; + return new OntologyHandler{handlerData}; } }; -class DomainStructHandler : public StaticHandler { +class OntologyStructHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -64,11 +64,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainStructHandler{handlerData}; + return new OntologyStructHandler{handlerData}; } }; -class DomainAnnotationHandler : public StaticHandler { +class OntologyAnnotationHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -77,11 +77,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainAnnotationHandler{handlerData}; + return new OntologyAnnotationHandler{handlerData}; } }; -class DomainAttributesHandler : public StaticHandler { +class OntologyAttributesHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -90,11 +90,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainAttributesHandler{handlerData}; + return new OntologyAttributesHandler{handlerData}; } }; -class DomainFieldHandler : public StaticHandler { +class OntologyFieldHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -103,11 +103,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainFieldHandler{handlerData}; + return new OntologyFieldHandler{handlerData}; } }; -class DomainFieldRefHandler : public StaticHandler { +class OntologyFieldRefHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -116,11 +116,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainFieldRefHandler{handlerData}; + return new OntologyFieldRefHandler{handlerData}; } }; -class DomainPrimitiveHandler : public StaticHandler { +class OntologyPrimitiveHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -129,11 +129,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainPrimitiveHandler{handlerData}; + return new OntologyPrimitiveHandler{handlerData}; } }; -class DomainChildHandler : public StaticHandler { +class OntologyChildHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -141,16 +141,16 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainChildHandler{handlerData}; + return new OntologyChildHandler{handlerData}; } }; -class DomainParent : public Node { +class OntologyParent : public Node { public: using Node::Node; }; -class DomainParentHandler : public StaticHandler { +class OntologyParentHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -159,11 +159,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainParentHandler{handlerData}; + return new OntologyParentHandler{handlerData}; } }; -class DomainParentFieldHandler : public StaticHandler { +class OntologyParentFieldHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -171,11 +171,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainParentFieldHandler{handlerData}; + return new OntologyParentFieldHandler{handlerData}; } }; -class DomainParentFieldRefHandler : public StaticHandler { +class OntologyParentFieldRefHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -183,75 +183,75 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainParentFieldRefHandler{handlerData}; + return new OntologyParentFieldRefHandler{handlerData}; } }; namespace States { /** - * State representing a "domain" struct. + * State representing a "ontology" struct. */ -extern const State Domain; +extern const State Ontology; /** - * State representing a "struct" tag within a domain description. + * State representing a "struct" tag within a ontology description. */ -extern const State DomainStruct; +extern const State OntologyStruct; /** - * State representing an "annotation" tag within a domain description. + * State representing an "annotation" tag within a ontology description. */ -extern const State DomainAnnotation; +extern const State OntologyAnnotation; /** * State representing an "attributes" tag within a structure or annotation. */ -extern const State DomainAttributes; +extern const State OntologyAttributes; /** * State representing an "attribute" tag within the "attributes". */ -extern const State DomainAttribute; +extern const State OntologyAttribute; /** * State representing a "field" tag within a structure or annotation. */ -extern const State DomainField; +extern const State OntologyField; /** * State representing a "fieldref" tag within a structure or annotation. */ -extern const State DomainFieldRef; +extern const State OntologyFieldRef; /** * State representing a "primitive" tag within a structure or annotation. */ -extern const State DomainStructPrimitive; +extern const State OntologyStructPrimitive; /** * State representing a "child" tag within a structure or annotation. */ -extern const State DomainStructChild; +extern const State OntologyStructChild; /** * State representing a "parent" tag within a structure or annotation. */ -extern const State DomainStructParent; +extern const State OntologyStructParent; /** * State representing a "field" tag within a "parent" tag. */ -extern const State DomainStructParentField; +extern const State OntologyStructParentField; /** * State representing a "fieldRef" tag within a "parent" tag. */ -extern const State DomainStructParentFieldRef; +extern const State OntologyStructParentFieldRef; } } namespace RttiTypes { -extern const Rtti DomainParent; +extern const Rtti OntologyParent; } } #endif diff --git a/src/core/parser/stack/TypesystemHandler.cpp b/src/core/parser/stack/TypesystemHandler.cpp index de8ee49..b62f684 100644 --- a/src/core/parser/stack/TypesystemHandler.cpp +++ b/src/core/parser/stack/TypesystemHandler.cpp @@ -17,13 +17,13 @@ */ #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include <core/parser/ParserScope.hpp> #include <core/parser/ParserContext.hpp> #include "DocumentHandler.hpp" -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "State.hpp" #include "TypesystemHandler.hpp" @@ -39,12 +39,12 @@ bool TypesystemHandler::start(Variant::mapType &args) context().getProject()->createTypesystem(args["name"].asString()); typesystem->setLocation(location()); - // If the typesystem is defined inside a domain, add a reference to the - // typesystem to the domain -- do the same with a document, if no domain + // If the typesystem is defined inside a ontology, add a reference to the + // typesystem to the ontology -- do the same with a document, if no ontology // is found - Rooted<Domain> domain = scope().select<Domain>(); - if (domain != nullptr) { - domain->reference(typesystem); + Rooted<Ontology> ontology = scope().select<Ontology>(); + if (ontology != nullptr) { + ontology->reference(typesystem); } else { Rooted<Document> document = scope().select<Document>(); if (document != nullptr) { @@ -190,7 +190,7 @@ bool TypesystemConstantHandler::start(Variant::mapType &args) namespace States { const State Typesystem = StateBuilder() - .parents({&None, &Domain, &Document}) + .parents({&None, &Ontology, &Document}) .createdNodeType(&RttiTypes::Typesystem) .elementHandler(TypesystemHandler::create) .arguments({Argument::String("name", "")}); diff --git a/src/core/resource/Resource.cpp b/src/core/resource/Resource.cpp index 4b9e496..7bcaf88 100644 --- a/src/core/resource/Resource.cpp +++ b/src/core/resource/Resource.cpp @@ -42,7 +42,7 @@ static std::unordered_map<ResourceType, std::string, Utils::EnumHash> reverseMap static const std::unordered_map<std::string, ResourceType> NAME_RESOURCE_TYPE_MAP{{"document", ResourceType::DOCUMENT}, - {"domain", ResourceType::DOMAIN_DESC}, + {"ontology", ResourceType::ONTOLOGY}, {"typesystem", ResourceType::TYPESYSTEM}, {"attributes", ResourceType::ATTRIBUTES}, {"stylesheet", ResourceType::STYLESHEET}, diff --git a/src/core/resource/Resource.hpp b/src/core/resource/Resource.hpp index 63ed591..548a255 100644 --- a/src/core/resource/Resource.hpp +++ b/src/core/resource/Resource.hpp @@ -48,9 +48,9 @@ enum class ResourceType { UNKNOWN, /** - * The resource contains a domain description. + * The resource contains a ontology description. */ - DOMAIN_DESC, + ONTOLOGY, /** * The resource contains a typesystem description. diff --git a/src/core/resource/ResourceRequest.cpp b/src/core/resource/ResourceRequest.cpp index f01a324..3c01e6a 100644 --- a/src/core/resource/ResourceRequest.cpp +++ b/src/core/resource/ResourceRequest.cpp @@ -33,7 +33,7 @@ namespace ousia { namespace RttiTypes { extern const Rtti Document; -extern const Rtti Domain; +extern const Rtti Ontology; extern const Rtti Node; extern const Rtti Typesystem; } @@ -43,7 +43,7 @@ extern const Rtti Typesystem; */ static const std::unordered_map<const Rtti *, ResourceType> RTTI_RESOURCE_TYPE_MAP{{&RttiTypes::Document, ResourceType::DOCUMENT}, - {&RttiTypes::Domain, ResourceType::DOMAIN_DESC}, + {&RttiTypes::Ontology, ResourceType::ONTOLOGY}, {&RttiTypes::Typesystem, ResourceType::TYPESYSTEM}}; /** diff --git a/src/formats/osml/OsmlParser.cpp b/src/formats/osml/OsmlParser.cpp index a24f091..16e7aa4 100644 --- a/src/formats/osml/OsmlParser.cpp +++ b/src/formats/osml/OsmlParser.cpp @@ -95,7 +95,7 @@ public: const std::string &cmd = parser.getCommandName().asString(); if (cmd != "typesystem" && cmd != "document" && - cmd != "domain") { + cmd != "ontology") { stack.command("document", Variant::mapType{}); } needsDocument = false; diff --git a/src/plugins/filesystem/FileLocator.cpp b/src/plugins/filesystem/FileLocator.cpp index 2fd5483..994bbb9 100644 --- a/src/plugins/filesystem/FileLocator.cpp +++ b/src/plugins/filesystem/FileLocator.cpp @@ -103,8 +103,8 @@ void FileLocator::addDefaultSearchPaths(const std::string &relativeTo) // Add the search paths fs::path base{relativeTo}; addSearchPath(base.generic_string(), ResourceType::UNKNOWN); - addSearchPath((base / "domain").generic_string(), - ResourceType::DOMAIN_DESC); + addSearchPath((base / "ontology").generic_string(), + ResourceType::ONTOLOGY); addSearchPath((base / "typesystem").generic_string(), ResourceType::TYPESYSTEM); } diff --git a/src/plugins/filesystem/FileLocator.hpp b/src/plugins/filesystem/FileLocator.hpp index ad64db8..d1de6d0 100644 --- a/src/plugins/filesystem/FileLocator.hpp +++ b/src/plugins/filesystem/FileLocator.hpp @@ -116,7 +116,7 @@ public: * <li>The global application data directory used for make install * (default is /usr/local/share on UNIX)</li> * </ul> - * Resource type specific subdirectories (domain, typesytem, etc.) + * Resource type specific subdirectories (ontology, typesytem, etc.) * are automatically added to the aforementioned paths. */ void addDefaultSearchPaths(); diff --git a/src/plugins/html/DemoOutput.hpp b/src/plugins/html/DemoOutput.hpp index 4367202..b038a96 100644 --- a/src/plugins/html/DemoOutput.hpp +++ b/src/plugins/html/DemoOutput.hpp @@ -19,7 +19,7 @@ /** * @file DemoOutput.hpp * - * This implements a Demo HTML output for the following domains: + * This implements a Demo HTML output for the following ontologies: * * book * * headings * * emphasis @@ -67,18 +67,18 @@ public: * This writes a HTML representation of the given document to the given * output stream. Note that this method lacks the generality of our Ousia * approach with respect to two important points: - * 1.) It hardcodes the dependency to a certain set of domains in the C++ + * 1.) It hardcodes the dependency to a certain set of ontologies in the C++ * code. * 2.) It does not use the proposed pipeline of first copying the document * graph, then attaching style attributes and then transforming it to a * specific output format but does all of these steps at once. - * 3.) It does not use different transformers for the different domains but + * 3.) It does not use different transformers for the different ontologies but * does all transformations at once. * Therefore this is not an adequate model of our algorithms but only a * Demo. * * @param doc is a Document using concepts of the book, headings, - * emphasis and lists domains but no other. + * emphasis and lists ontologies but no other. * @param out is the output stream the data shall be written to. * @param pretty is a flag that manipulates whether newlines and tabs are * used. diff --git a/src/plugins/xml/XmlOutput.cpp b/src/plugins/xml/XmlOutput.cpp index ace7635..ffdecab 100644 --- a/src/plugins/xml/XmlOutput.cpp +++ b/src/plugins/xml/XmlOutput.cpp @@ -51,10 +51,10 @@ void XmlTransformer::writeXml(Handle<Document> doc, std::ostream &out, Manager &mgr = doc->getManager(); // the outermost tag is the document itself. Rooted<Element> document{new Element{mgr, {nullptr}, "document"}}; - // write imports for all referenced domains. - for (auto d : doc->getDomains()) { + // write imports for all referenced ontologies. + for (auto d : doc->getOntologys()) { Rooted<Element> import = - createImportElement(document, d, resourceManager, "domain"); + createImportElement(document, d, resourceManager, "ontology"); if (import != nullptr) { document->addChild(import); // add the import as namespace information to the document node as @@ -63,7 +63,7 @@ void XmlTransformer::writeXml(Handle<Document> doc, std::ostream &out, std::string("xmlns:") + d->getName(), d->getName()); } else { logger.warning(std::string( - "The location of domain \"" + d->getName() + + "The location of ontology \"" + d->getName() + "\" could not be retrieved using the given ResourceManager.")); } } @@ -199,7 +199,7 @@ Rooted<Element> XmlTransformer::transformStructuredEntity( Rooted<Element> elem{ new Element{mgr, parent, s->getDescriptor()->getName(), transformAttributes(s->getName(), s.get(), logger, pretty), - s->getDescriptor()->getParent().cast<Domain>()->getName()}}; + s->getDescriptor()->getParent().cast<Ontology>()->getName()}}; // then transform the children. transformChildren(s.get(), elem, logger, pretty); return elem; diff --git a/src/plugins/xml/XmlOutput.hpp b/src/plugins/xml/XmlOutput.hpp index da406a7..55c1c67 100644 --- a/src/plugins/xml/XmlOutput.hpp +++ b/src/plugins/xml/XmlOutput.hpp @@ -62,7 +62,7 @@ public: /** * This writes an XML serialization of the given document to the given * output stream. The serialization is equivalent to the input XML format, - * safe for the domain references. TODO: Can we change this? If so: how? + * safe for the ontology references. TODO: Can we change this? If so: how? * Note, though, that the serialization will not exploit transparency. * TODO: Can we change that? * @@ -70,7 +70,7 @@ public: * @param out is the output stream the XML serialization of the document * shall be written to. * @param logger is the logger errors shall be written to. - * @param resMgr is the ResourceManager to locate the domains and + * @param resMgr is the ResourceManager to locate the ontologies and * typesystems that were imported in this document. * @param pretty is a flag that manipulates whether newlines and tabs are * used. diff --git a/test/core/RegistryTest.cpp b/test/core/RegistryTest.cpp index 4e8fc6a..b557169 100644 --- a/test/core/RegistryTest.cpp +++ b/test/core/RegistryTest.cpp @@ -100,9 +100,9 @@ TEST(Registry, locateResource) Resource res; ASSERT_TRUE( - registry.locateResource(res, "path", ResourceType::DOMAIN_DESC)); + registry.locateResource(res, "path", ResourceType::ONTOLOGY)); ASSERT_TRUE(res.isValid()); - ASSERT_EQ(ResourceType::DOMAIN_DESC, res.getType()); + ASSERT_EQ(ResourceType::ONTOLOGY, res.getType()); ASSERT_EQ("path", res.getLocation()); } } diff --git a/test/core/frontend/TerminalLoggerTest.cpp b/test/core/frontend/TerminalLoggerTest.cpp index 99e8f29..acc379d 100644 --- a/test/core/frontend/TerminalLoggerTest.cpp +++ b/test/core/frontend/TerminalLoggerTest.cpp @@ -35,8 +35,8 @@ struct Pos { }; static const std::string testStr = - "\\link[domain]{book}\n" // 1 - "\\link[domain]{meta}\n" // 2 + "\\link[ontology]{book}\n" // 1 + "\\link[ontology]{meta}\n" // 2 "\n" // 3 "\\meta{\n" // 4 "\t\\title{The Adventures Of Tom Sawyer}\n" // 5 diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index 1bb2356..8ed59f5 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -23,10 +23,10 @@ #include <core/common/Rtti.hpp> #include <core/frontend/TerminalLogger.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include "TestDocument.hpp" -#include "TestDomain.hpp" +#include "TestOntology.hpp" namespace ousia { @@ -36,10 +36,10 @@ TEST(Document, construct) TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); // Construct the document. - Rooted<Document> doc = constructBookDocument(mgr, logger, domain); + Rooted<Document> doc = constructBookDocument(mgr, logger, ontology); // Check the document content. ASSERT_FALSE(doc.isNull()); @@ -111,22 +111,22 @@ TEST(Document, construct) TEST(Document, validate) { - // Let's start with a trivial domain and a trivial document. + // Let's start with a trivial ontology and a trivial document. TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "trivial")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "trivial")}; Cardinality single; single.merge({1}); // Set up the "root" StructuredClass. Rooted<StructuredClass> rootClass{new StructuredClass( - mgr, "root", domain, single, {nullptr}, false, true)}; + mgr, "root", ontology, single, {nullptr}, false, true)}; // set up a document for it. { // first an invalid one, which is empty. Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); ASSERT_FALSE(doc->validate(logger)); // then add a root, which should make it valid. @@ -138,7 +138,7 @@ TEST(Document, validate) { // A root with an invalid name, however, should make it invalid Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity( doc, logger, {"root"}, {}, "my invalid root"); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); @@ -150,7 +150,7 @@ TEST(Document, validate) rootClass->createFieldDescriptor(logger).first; // and add a child class for it. Rooted<StructuredClass> childClass{ - new StructuredClass(mgr, "child", domain, single)}; + new StructuredClass(mgr, "child", ontology, single)}; rootField->addChild(childClass); { /* @@ -158,7 +158,7 @@ TEST(Document, validate) * document should be invalid again. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); @@ -173,16 +173,16 @@ TEST(Document, validate) ASSERT_FALSE(doc->validate(logger)); } /* - * Add a further extension to the domain: We add a subclass to child. + * Add a further extension to the ontology: We add a subclass to child. */ Rooted<StructuredClass> childSubClass{ - new StructuredClass(mgr, "childSub", domain, single, childClass)}; + new StructuredClass(mgr, "childSub", ontology, single, childClass)}; { /* * A document with one instance of the Child subclass should be valid. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); buildStructuredEntity(doc, logger, root, {"childSub"}); @@ -202,7 +202,7 @@ TEST(Document, validate) * invalid, because it has no children of itself. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); buildStructuredEntity(doc, logger, root, {"childSub"}); @@ -223,7 +223,7 @@ TEST(Document, validate) * valid, because of the override. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); buildStructuredEntity(doc, logger, root, {"childSub"}); @@ -241,7 +241,7 @@ TEST(Document, validate) * invalid again, because we are missing the primitive content. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); Rooted<StructuredEntity> child = @@ -259,14 +259,14 @@ TEST(Document, validate) ASSERT_TRUE(doc->validate(logger)); } - // Now add an Annotation class to the domain. - Rooted<AnnotationClass> annoClass{new AnnotationClass(mgr, "anno", domain)}; + // Now add an Annotation class to the ontology. + Rooted<AnnotationClass> annoClass{new AnnotationClass(mgr, "anno", ontology)}; { /* * Create a valid document in itself. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); Rooted<Anchor> start{new Anchor(mgr, root)}; diff --git a/test/core/model/DomainTest.cpp b/test/core/model/OntologyTest.cpp index 6bbf26d..764dcb4 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/OntologyTest.cpp @@ -22,9 +22,9 @@ #include <core/common/Rtti.hpp> #include <core/frontend/TerminalLogger.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> -#include "TestDomain.hpp" +#include "TestOntology.hpp" namespace ousia { @@ -38,45 +38,45 @@ void assert_path(const ResolutionResult &res, const Rtti *expected_type, ASSERT_EQ(expected_path, res.node->path()); } -TEST(Domain, testDomainResolving) +TEST(Ontology, testOntologyResolving) { // Construct Manager Logger logger; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); std::vector<ResolutionResult> res; - // There is one domain called "book" - res = domain->resolve(&RttiTypes::Domain, "book"); + // There is one ontology called "book" + res = ontology->resolve(&RttiTypes::Ontology, "book"); ASSERT_EQ(1U, res.size()); - assert_path(res[0], &RttiTypes::Domain, {"book"}); + assert_path(res[0], &RttiTypes::Ontology, {"book"}); - // There is one domain called "book" - res = domain->resolve(&RttiTypes::StructuredClass, "book"); + // There is one ontology called "book" + res = ontology->resolve(&RttiTypes::StructuredClass, "book"); ASSERT_EQ(1U, res.size()); assert_path(res[0], &RttiTypes::StructuredClass, {"book", "book"}); // If we explicitly ask for the "book, book" path, then only the // StructuredClass should be returned. - res = domain->resolve(&RttiTypes::Domain, + res = ontology->resolve(&RttiTypes::Ontology, std::vector<std::string>{"book", "book"}); ASSERT_EQ(0U, res.size()); - res = domain->resolve(&RttiTypes::StructuredClass, + res = ontology->resolve(&RttiTypes::StructuredClass, std::vector<std::string>{"book", "book"}); ASSERT_EQ(1U, res.size()); // If we ask for "section" the result should be unique as well. - res = domain->resolve(&RttiTypes::StructuredClass, "section"); + res = ontology->resolve(&RttiTypes::StructuredClass, "section"); ASSERT_EQ(1U, res.size()); assert_path(res[0], &RttiTypes::StructuredClass, {"book", "section"}); - // If we ask for "paragraph" it is referenced two times in the Domain graph, + // If we ask for "paragraph" it is referenced two times in the Ontology graph, // but should be returned only once. - res = domain->resolve(&RttiTypes::StructuredClass, "paragraph"); + res = ontology->resolve(&RttiTypes::StructuredClass, "paragraph"); ASSERT_EQ(1U, res.size()); assert_path(res[0], &RttiTypes::StructuredClass, {"book", "paragraph"}); } @@ -115,10 +115,10 @@ TEST(StructuredClass, getFieldDescriptors) TerminalLogger logger{std::cout}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "myDomain")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "myOntology")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "A", ontology, Cardinality::any(), nullptr, false, true)}; Rooted<FieldDescriptor> A_a = createUnsortedPrimitiveField( A, sys->getStringType(), logger, false, "a"); Rooted<FieldDescriptor> A_b = createUnsortedPrimitiveField( @@ -127,7 +127,7 @@ TEST(StructuredClass, getFieldDescriptors) A, sys->getStringType(), logger, true, "somename"); Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), A, false, true)}; + mgr, "B", ontology, Cardinality::any(), A, false, true)}; Rooted<FieldDescriptor> B_b = createUnsortedPrimitiveField( B, sys->getStringType(), logger, false, "b"); Rooted<FieldDescriptor> B_c = createUnsortedPrimitiveField( @@ -136,11 +136,11 @@ TEST(StructuredClass, getFieldDescriptors) B, sys->getStringType(), logger, true, "othername"); Rooted<StructuredClass> C{new StructuredClass( - mgr, "C", domain, Cardinality::any(), B, false, true)}; + mgr, "C", ontology, Cardinality::any(), B, false, true)}; Rooted<FieldDescriptor> C_a = createUnsortedPrimitiveField( C, sys->getStringType(), logger, false, "a"); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_TRUE(ontology->validate(logger)); // check all FieldDescriptors { @@ -176,21 +176,21 @@ TEST(StructuredClass, getFieldDescriptorsCycles) Logger logger; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "myDomain")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "myOntology")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "A", ontology, Cardinality::any(), nullptr, false, true)}; A->addSubclass(A, logger); Rooted<FieldDescriptor> A_a = createUnsortedPrimitiveField( A, sys->getStringType(), logger, false, "a"); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); // if we call getFieldDescriptors that should still return a valid result. NodeVector<FieldDescriptor> fds = A->getFieldDescriptors(); ASSERT_EQ(1, fds.size()); ASSERT_EQ(A_a, fds[0]); } -Rooted<StructuredClass> getClass(const std::string name, Handle<Domain> dom) +Rooted<StructuredClass> getClass(const std::string name, Handle<Ontology> dom) { std::vector<ResolutionResult> res = dom->resolve(&RttiTypes::StructuredClass, name); @@ -199,23 +199,23 @@ Rooted<StructuredClass> getClass(const std::string name, Handle<Domain> dom) TEST(Descriptor, pathTo) { - // Start with some easy examples from the book domain. + // Start with some easy examples from the book ontology. TerminalLogger logger{std::cout}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); // get the book node and the section node. - Rooted<StructuredClass> book = getClass("book", domain); - Rooted<StructuredClass> section = getClass("section", domain); + Rooted<StructuredClass> book = getClass("book", ontology); + Rooted<StructuredClass> section = getClass("section", ontology); // get the path in between. NodeVector<Node> path = book->pathTo(section, logger); ASSERT_EQ(1U, path.size()); ASSERT_TRUE(path[0]->isa(&RttiTypes::FieldDescriptor)); // get the text node. - Rooted<StructuredClass> text = getClass("text", domain); + Rooted<StructuredClass> text = getClass("text", ontology); // get the path between book and text via paragraph. path = book->pathTo(text, logger); ASSERT_EQ(3U, path.size()); @@ -225,7 +225,7 @@ TEST(Descriptor, pathTo) ASSERT_TRUE(path[2]->isa(&RttiTypes::FieldDescriptor)); // get the subsection node. - Rooted<StructuredClass> subsection = getClass("subsection", domain); + Rooted<StructuredClass> subsection = getClass("subsection", ontology); // try to get the path between book and subsection. path = book->pathTo(subsection, logger); // this should be impossible. @@ -247,7 +247,7 @@ TEST(Descriptor, pathTo) TEST(Descriptor, pathToAdvanced) { /* - * Now we build a really nasty domain with lots of transparency + * Now we build a really nasty ontology with lots of transparency * and inheritance. The basic idea is to have three paths from start to * finish, where one is blocked by overriding fields and the longer valid * one is found first such that it has to be replaced by the shorter one @@ -269,30 +269,30 @@ TEST(Descriptor, pathToAdvanced) Manager mgr{1}; TerminalLogger logger{std::cout}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "nasty")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "nasty")}; // Let's create the classes that we need first Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, false, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, false, true)}; Rooted<StructuredClass> start{new StructuredClass( - mgr, "start", domain, Cardinality::any(), A, false, false)}; + mgr, "start", ontology, Cardinality::any(), A, false, false)}; Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), {nullptr}, true, false)}; + mgr, "B", ontology, Cardinality::any(), {nullptr}, true, false)}; Rooted<StructuredClass> C{new StructuredClass( - mgr, "C", domain, Cardinality::any(), B, true, false)}; + mgr, "C", ontology, Cardinality::any(), B, true, false)}; Rooted<StructuredClass> D{new StructuredClass( - mgr, "D", domain, Cardinality::any(), {nullptr}, true, false)}; + mgr, "D", ontology, Cardinality::any(), {nullptr}, true, false)}; Rooted<StructuredClass> E{new StructuredClass( - mgr, "E", domain, Cardinality::any(), {nullptr}, true, false)}; + mgr, "E", ontology, Cardinality::any(), {nullptr}, true, false)}; Rooted<StructuredClass> target{ - new StructuredClass(mgr, "target", domain, Cardinality::any())}; + new StructuredClass(mgr, "target", ontology, Cardinality::any())}; // We create a field for A Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; @@ -312,11 +312,11 @@ TEST(Descriptor, pathToAdvanced) Rooted<FieldDescriptor> E_field = E->createFieldDescriptor(logger).first; E_field->addChild(target); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_TRUE(ontology->validate(logger)); #ifdef MANAGER_GRAPHVIZ_EXPORT // dump the manager state - mgr.exportGraphviz("nastyDomain.dot"); + mgr.exportGraphviz("nastyOntology.dot"); #endif // and now we should be able to find the shortest path as suggested @@ -332,18 +332,18 @@ TEST(Descriptor, pathToAdvanced) TEST(Descriptor, pathToCycles) { - // build a domain with a cycle. + // build a ontology with a cycle. Manager mgr{1}; Logger logger; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "cycles")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "cycles")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, true, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, true, true)}; A->addSubclass(A, logger); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), {nullptr}, false, true)}; + mgr, "B", ontology, Cardinality::any(), {nullptr}, false, true)}; Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; A_field->addChild(B); /* @@ -360,16 +360,16 @@ TEST(Descriptor, pathToCycles) TEST(Descriptor, getDefaultFields) { - // construct a domain with lots of default fields to test. + // construct a ontology with lots of default fields to test. // start with a single structure class. Manager mgr{1}; TerminalLogger logger{std::cout}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "nasty")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "nasty")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "A", ontology, Cardinality::any(), nullptr, false, true)}; // in this trivial case no field should be found. ASSERT_TRUE(A->getDefaultFields().empty()); @@ -385,7 +385,7 @@ TEST(Descriptor, getDefaultFields) // remove that field from A and add it to another class. Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "B", ontology, Cardinality::any(), nullptr, false, true)}; B->moveFieldDescriptor(A_prim_field, logger); @@ -405,7 +405,7 @@ TEST(Descriptor, getDefaultFields) // add a transparent child class. Rooted<StructuredClass> C{new StructuredClass( - mgr, "C", domain, Cardinality::any(), nullptr, true, false)}; + mgr, "C", ontology, Cardinality::any(), nullptr, true, false)}; A_field->addChild(C); // add a primitive field for it. @@ -420,14 +420,14 @@ TEST(Descriptor, getDefaultFields) // add another transparent child class to A with a daughter class that has // in turn a subclass with a primitive field. Rooted<StructuredClass> D{new StructuredClass( - mgr, "D", domain, Cardinality::any(), nullptr, true, false)}; + mgr, "D", ontology, Cardinality::any(), nullptr, true, false)}; A_field->addChild(D); Rooted<FieldDescriptor> D_field = D->createFieldDescriptor(logger).first; Rooted<StructuredClass> E{new StructuredClass( - mgr, "E", domain, Cardinality::any(), nullptr, true, false)}; + mgr, "E", ontology, Cardinality::any(), nullptr, true, false)}; D_field->addChild(E); Rooted<StructuredClass> F{new StructuredClass( - mgr, "E", domain, Cardinality::any(), E, true, false)}; + mgr, "E", ontology, Cardinality::any(), E, true, false)}; Rooted<FieldDescriptor> F_field = F->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; @@ -440,16 +440,16 @@ TEST(Descriptor, getDefaultFields) TEST(Descriptor, getDefaultFieldsCycles) { - // build a domain with a cycle. + // build a ontology with a cycle. Manager mgr{1}; Logger logger; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "cycles")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "cycles")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, true, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, true, true)}; A->addSubclass(A, logger); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); Rooted<FieldDescriptor> A_field = A->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; /* @@ -463,17 +463,17 @@ TEST(Descriptor, getDefaultFieldsCycles) TEST(Descriptor, getPermittedChildren) { - // analyze the book domain. + // analyze the book ontology. TerminalLogger logger{std::cout}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); // get the relevant classes. - Rooted<StructuredClass> book = getClass("book", domain); - Rooted<StructuredClass> section = getClass("section", domain); - Rooted<StructuredClass> paragraph = getClass("paragraph", domain); - Rooted<StructuredClass> text = getClass("text", domain); + Rooted<StructuredClass> book = getClass("book", ontology); + Rooted<StructuredClass> section = getClass("section", ontology); + Rooted<StructuredClass> paragraph = getClass("paragraph", ontology); + Rooted<StructuredClass> text = getClass("text", ontology); /* * as permitted children we expect section, paragraph and text in exactly * that order. section should be before paragraph because of declaration @@ -488,7 +488,7 @@ TEST(Descriptor, getPermittedChildren) // Now we add a subclass to text. Rooted<StructuredClass> sub{new StructuredClass( - mgr, "Subclass", domain, Cardinality::any(), text, true, false)}; + mgr, "Subclass", ontology, Cardinality::any(), text, true, false)}; // And that should be in the result list as well now. children = book->getPermittedChildren(); ASSERT_EQ(4U, children.size()); @@ -500,16 +500,16 @@ TEST(Descriptor, getPermittedChildren) TEST(Descriptor, getPermittedChildrenCycles) { - // build a domain with a cycle. + // build a ontology with a cycle. Manager mgr{1}; Logger logger; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "cycles")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "cycles")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, true, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, true, true)}; A->addSubclass(A, logger); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; // we make the cycle worse by adding A as child of itself. A_field->addChild(A); @@ -528,21 +528,21 @@ TEST(StructuredClass, isSubclassOf) // create an inheritance hierarchy. Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "inheritance")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "inheritance")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, false, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, false, true)}; // first branch Rooted<StructuredClass> B{ - new StructuredClass(mgr, "B", domain, Cardinality::any(), A)}; + new StructuredClass(mgr, "B", ontology, Cardinality::any(), A)}; Rooted<StructuredClass> C{ - new StructuredClass(mgr, "C", domain, Cardinality::any(), B)}; + new StructuredClass(mgr, "C", ontology, Cardinality::any(), B)}; // second branch Rooted<StructuredClass> D{ - new StructuredClass(mgr, "D", domain, Cardinality::any(), A)}; + new StructuredClass(mgr, "D", ontology, Cardinality::any(), A)}; Rooted<StructuredClass> E{ - new StructuredClass(mgr, "E", domain, Cardinality::any(), D)}; + new StructuredClass(mgr, "E", ontology, Cardinality::any(), D)}; Rooted<StructuredClass> F{ - new StructuredClass(mgr, "F", domain, Cardinality::any(), D)}; + new StructuredClass(mgr, "F", ontology, Cardinality::any(), D)}; // check function results ASSERT_FALSE(A->isSubclassOf(A)); @@ -588,102 +588,102 @@ TEST(StructuredClass, isSubclassOf) ASSERT_FALSE(F->isSubclassOf(F)); } -TEST(Domain, validate) +TEST(Ontology, validate) { TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // start with an easy example: Our book domain should be valid. + // start with an easy example: Our book ontology should be valid. { - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); } { - // Even easier: An empty domain should be valid. - Rooted<Domain> domain{new Domain(mgr, sys, "domain")}; - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + // Even easier: An empty ontology should be valid. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "ontology")}; + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // if we add a StructureClass it should be valid still. Rooted<StructuredClass> base{ - new StructuredClass(mgr, "myClass", domain)}; - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + new StructuredClass(mgr, "myClass", ontology)}; + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // if we tamper with the name, however, it shouldn't be valid anymore. base->setName(""); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); base->setName("my class"); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); base->setName("myClass"); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // Let's add a primitive field (without a primitive type at first) Rooted<FieldDescriptor> base_field = base->createPrimitiveFieldDescriptor(nullptr, logger).first; // this should not be valid. - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // but it should be if we set the type. base_field->setPrimitiveType(sys->getStringType()); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // add a subclass for our base class. - Rooted<StructuredClass> sub{new StructuredClass(mgr, "sub", domain)}; + Rooted<StructuredClass> sub{new StructuredClass(mgr, "sub", ontology)}; // this should be valid in itself. - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // and still if we add a superclass. sub->setSuperclass(base, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // and still if we remove the subclass from the base class. base->removeSubclass(sub, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); ASSERT_EQ(nullptr, sub->getSuperclass()); // and still if we re-add it. base->addSubclass(sub, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); ASSERT_EQ(base, sub->getSuperclass()); // add a non-primitive field to the child class. Rooted<FieldDescriptor> sub_field = sub->createFieldDescriptor(logger).first; // this should not be valid because we allow no children. - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // we should also be able to add a child and make it valid. sub_field->addChild(base); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // it should be invalid if we add it twice. sub_field->addChild(base); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // and valid again if we remove it once. sub_field->removeChild(base); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // if we set a primitive type it should be invalid sub_field->setPrimitiveType(sys->getStringType()); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // and valid again if we unset it. sub_field->setPrimitiveType(nullptr); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // It should be invalid if we set another TREE field. Rooted<FieldDescriptor> sub_field2 = sub->createFieldDescriptor(logger, FieldDescriptor::FieldType::TREE, "test", false).first; - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // but valid again if we remove it sub->removeFieldDescriptor(sub_field2); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); } } }
\ No newline at end of file diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 71379d2..c92effa 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -20,19 +20,19 @@ #define _MODEL_TEST_ADVANCED_HPP_ #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include "TestDocumentBuilder.hpp" namespace ousia { -static Rooted<StructuredClass> resolveDescriptor(Handle<Domain> domain, +static Rooted<StructuredClass> resolveDescriptor(Handle<Ontology> ontology, const std::string &className) { // use the actual resolve method. std::vector<ResolutionResult> resolved = - domain->resolve(&RttiTypes::StructuredClass, className); + ontology->resolve(&RttiTypes::StructuredClass, className); // take the first valid result. for (auto &r : resolved) { return r.node.cast<StructuredClass>(); @@ -42,53 +42,53 @@ static Rooted<StructuredClass> resolveDescriptor(Handle<Domain> domain, } /** - * This constructs the "heading" domain given the book domain. + * This constructs the "heading" ontology given the book ontology. */ -static Rooted<Domain> constructHeadingDomain(Manager &mgr, +static Rooted<Ontology> constructHeadingOntology(Manager &mgr, Handle<SystemTypesystem> sys, - Handle<Domain> bookDomain, + Handle<Ontology> bookOntology, Logger &logger) { - // set up domain node. - Rooted<Domain> domain{new Domain(mgr, sys, "headings")}; + // set up ontology node. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "headings")}; // set up cardinality (every section may have at most one heading). Cardinality card; card.merge({0, 1}); // set up heading StructuredClass. Rooted<StructuredClass> heading{ - new StructuredClass(mgr, "heading", domain, card, {nullptr}, true)}; + new StructuredClass(mgr, "heading", ontology, card, {nullptr}, true)}; // as field want to reference the field of paragraph. - Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph"); + Rooted<StructuredClass> p = resolveDescriptor(bookOntology, "paragraph"); heading->addFieldDescriptor(p->getFieldDescriptor(), logger); // create a new field for headings in each section type. std::vector<std::string> secclasses{"book", "section", "subsection", "paragraph"}; for (auto &s : secclasses) { - Rooted<StructuredClass> desc = resolveDescriptor(bookDomain, s); + Rooted<StructuredClass> desc = resolveDescriptor(bookOntology, s); Rooted<FieldDescriptor> heading_field = desc->createFieldDescriptor(logger, FieldDescriptor::FieldType::SUBTREE, "heading", true).first; heading_field->addChild(heading); } - return domain; + return ontology; } /** - * This constructs the "list" domain given the book domain. + * This constructs the "list" ontology given the book ontology. */ -static Rooted<Domain> constructListDomain(Manager &mgr, +static Rooted<Ontology> constructListOntology(Manager &mgr, Handle<SystemTypesystem> sys, - Handle<Domain> bookDomain, + Handle<Ontology> bookOntology, Logger &logger) { - // set up domain node. - Rooted<Domain> domain{new Domain(mgr, sys, "list")}; + // set up ontology node. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "list")}; // get book.paragraph - Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph"); + Rooted<StructuredClass> p = resolveDescriptor(bookOntology, "paragraph"); // set up item StructuredClass; Rooted<StructuredClass> item{new StructuredClass( - mgr, "item", domain, Cardinality::any(), {nullptr}, false)}; + mgr, "item", ontology, Cardinality::any(), {nullptr}, false)}; // as field we want to reference the field of paragraph. item->addFieldDescriptor(p->getFieldDescriptor(), logger); @@ -96,28 +96,28 @@ static Rooted<Domain> constructListDomain(Manager &mgr, std::vector<std::string> listTypes{"ol", "ul"}; for (auto &listType : listTypes) { Rooted<StructuredClass> list{new StructuredClass( - mgr, listType, domain, Cardinality::any(), p, false)}; + mgr, listType, ontology, Cardinality::any(), p, false)}; Rooted<FieldDescriptor> list_field{new FieldDescriptor(mgr, list)}; list_field->addChild(item); } - return domain; + return ontology; } /** - * This constructs the "emphasis" domain. + * This constructs the "emphasis" ontology. */ -static Rooted<Domain> constructEmphasisDomain(Manager &mgr, +static Rooted<Ontology> constructEmphasisOntology(Manager &mgr, Handle<SystemTypesystem> sys, Logger &logger) { - // set up domain node. - Rooted<Domain> domain{new Domain(mgr, sys, "emphasis")}; + // set up ontology node. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "emphasis")}; // create AnnotationClasses - Rooted<AnnotationClass> em{new AnnotationClass(mgr, "emphasized", domain)}; + Rooted<AnnotationClass> em{new AnnotationClass(mgr, "emphasized", ontology)}; - Rooted<AnnotationClass> strong{new AnnotationClass(mgr, "strong", domain)}; + Rooted<AnnotationClass> strong{new AnnotationClass(mgr, "strong", ontology)}; - return domain; + return ontology; } static bool addText(Logger &logger, Handle<Document> doc, @@ -173,17 +173,17 @@ static bool addAnnotation(Logger &logger, Handle<Document> doc, /** * This constructs a more advanced book document using not only the book - * domain but also headings, emphasis and lists. + * ontology but also headings, emphasis and lists. */ static Rooted<Document> constructAdvancedDocument(Manager &mgr, Logger &logger, - Handle<Domain> bookDom, - Handle<Domain> headingDom, - Handle<Domain> listDom, - Handle<Domain> emphasisDom) + Handle<Ontology> bookDom, + Handle<Ontology> headingDom, + Handle<Ontology> listDom, + Handle<Ontology> emphasisDom) { // Start with the (empty) document. Rooted<Document> doc{new Document(mgr, "kant_was_ist_aufklaerung.oxd")}; - doc->referenceDomains({bookDom, headingDom, listDom, emphasisDom}); + doc->referenceOntologys({bookDom, headingDom, listDom, emphasisDom}); // Add the root. Rooted<StructuredEntity> book = diff --git a/test/core/model/TestDocument.hpp b/test/core/model/TestDocument.hpp index 7675dab..a4a8f7c 100644 --- a/test/core/model/TestDocument.hpp +++ b/test/core/model/TestDocument.hpp @@ -20,7 +20,7 @@ #define _MODEL_TEST_DOCUMENT_HPP_ #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include "TestDocumentBuilder.hpp" @@ -28,15 +28,15 @@ namespace ousia { /** - * This constructs a fairly simple test document for the "book" domain. The + * This constructs a fairly simple test document for the "book" ontology. The * structure of the document can be seen in the Code below. */ static Rooted<Document> constructBookDocument(Manager &mgr, Logger &logger, - Rooted<Domain> bookDomain) + Rooted<Ontology> bookOntology) { // Start with the (empty) document. Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(bookDomain); + doc->referenceOntology(bookOntology); // Add the root. Rooted<StructuredEntity> root = diff --git a/test/core/model/TestDocumentBuilder.hpp b/test/core/model/TestDocumentBuilder.hpp index fc76b07..745f1ab 100644 --- a/test/core/model/TestDocumentBuilder.hpp +++ b/test/core/model/TestDocumentBuilder.hpp @@ -23,7 +23,7 @@ #include <core/common/Logger.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> namespace ousia { @@ -81,7 +81,7 @@ static Rooted<Descriptor> resolveDescriptor(Handle<Document> doc, * @param name is the name of this StructuredEntity (empty per * default). * @return the newly created StructuredEntity or a nullptr if some - * input handle was empty or the given domains did not + * input handle was empty or the given ontologies did not * contain a StructuredClass with the given name. */ Rooted<StructuredEntity> buildRootStructuredEntity( @@ -112,7 +112,7 @@ Rooted<StructuredEntity> buildRootStructuredEntity( * This builds a StructuredEntity as child of the given DocumentEntity. It * automatically appends the newly build entity to its parent. * - * @param document is the document this entity shall be build for. The domains + * @param document is the document this entity shall be build for. The ontologies * referenced here are the basis to resolve the given path. * @param logger is the current logger. * @param parent is the parent DocumentEntity. The newly constructed @@ -126,7 +126,7 @@ Rooted<StructuredEntity> buildRootStructuredEntity( * @param name is the name of this StructuredEntity (empty per * default). * @return the newly created StructuredEntity or a nullptr if some - * input handle was empty or the given domains did not + * input handle was empty or the given ontologies did not * contain a StructuredClass with the given name. */ Rooted<StructuredEntity> buildStructuredEntity( @@ -167,7 +167,7 @@ Rooted<StructuredEntity> buildStructuredEntity( * This builds an AnnotationEntity as child of the given Document. It * automatically appends the newly build entity to its parent. * - * @param document is the document this entity shall be build for. The domains + * @param document is the document this entity shall be build for. The ontologies * referenced here are the basis to resolve the given path. * @param logger is the current logger. * @param path is the name of the AnnotationClass or a path specifying it @@ -179,7 +179,7 @@ Rooted<StructuredEntity> buildStructuredEntity( * @param name is the name of this AnnotationEntity (empty per * default). * @return the newly created AnnotationEntity or a nullptr if some - * input handle was empty or the given domains did not + * input handle was empty or the given ontologies did not * contain a AnnotationClass with the given name. */ Rooted<AnnotationEntity> buildAnnotationEntity( diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestOntology.hpp index 779ef03..c65d6f4 100644 --- a/test/core/model/TestDomain.hpp +++ b/test/core/model/TestOntology.hpp @@ -19,27 +19,27 @@ #ifndef _MODEL_TEST_DOMAIN_HPP_ #define _MODEL_TEST_DOMAIN_HPP_ -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> namespace ousia { /** - * This constructs the "book" domain for test purposes. The structure of the - * domain is fairly simple and can be seen from the construction itself. + * This constructs the "book" ontology for test purposes. The structure of the + * ontology is fairly simple and can be seen from the construction itself. */ -static Rooted<Domain> constructBookDomain(Manager &mgr, +static Rooted<Ontology> constructBookOntology(Manager &mgr, Handle<SystemTypesystem> sys, Logger &logger) { - // Start with the Domain itself. - Rooted<Domain> domain{new Domain(mgr, sys, "book")}; + // Start with the Ontology itself. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "book")}; // Set up the cardinalities we'll need. Cardinality single; single.merge({1}); // Set up the "book" node. Rooted<StructuredClass> book{new StructuredClass( - mgr, "book", domain, single, {nullptr}, false, true)}; + mgr, "book", ontology, single, {nullptr}, false, true)}; // The structure field of it. Rooted<FieldDescriptor> book_field = @@ -47,7 +47,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // From there on the "section". Rooted<StructuredClass> section{ - new StructuredClass(mgr, "section", domain, Cardinality::any())}; + new StructuredClass(mgr, "section", ontology, Cardinality::any())}; book_field->addChild(section); // And the field of it. @@ -56,7 +56,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // We also add the "paragraph", which is transparent. Rooted<StructuredClass> paragraph{new StructuredClass( - mgr, "paragraph", domain, Cardinality::any(), {nullptr}, true)}; + mgr, "paragraph", ontology, Cardinality::any(), {nullptr}, true)}; section_field->addChild(paragraph); book_field->addChild(paragraph); @@ -66,7 +66,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // We append "subsection" to section. Rooted<StructuredClass> subsection{ - new StructuredClass(mgr, "subsection", domain, Cardinality::any())}; + new StructuredClass(mgr, "subsection", ontology, Cardinality::any())}; section_field->addChild(subsection); // And the field of it. @@ -78,7 +78,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // Finally we add the "text" node, which is transparent as well. Rooted<StructuredClass> text{new StructuredClass( - mgr, "text", domain, Cardinality::any(), {nullptr}, true)}; + mgr, "text", ontology, Cardinality::any(), {nullptr}, true)}; paragraph_field->addChild(text); // ... and has a primitive field. @@ -86,7 +86,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, text->createPrimitiveFieldDescriptor(sys->getStringType(), logger) .first; - return domain; + return ontology; } } diff --git a/test/core/resource/ResourceRequestTest.cpp b/test/core/resource/ResourceRequestTest.cpp index dac7a28..3112cc4 100644 --- a/test/core/resource/ResourceRequestTest.cpp +++ b/test/core/resource/ResourceRequestTest.cpp @@ -31,7 +31,7 @@ namespace ousia { namespace RttiTypes { extern const Rtti Document; -extern const Rtti Domain; +extern const Rtti Ontology; extern const Rtti Typesystem; } @@ -62,12 +62,12 @@ struct TestSetup { TestSetup() { - registry.registerExtension("domain", "application/domain"); + registry.registerExtension("ontology", "application/ontology"); registry.registerExtension("typesystem", "application/typesystem"); registry.registerExtension("document", "application/document"); registry.registerParser( - {"application/domain", "application/typesystem"}, - {&RttiTypes::Domain, &RttiTypes::Typesystem}, &pModule); + {"application/ontology", "application/typesystem"}, + {&RttiTypes::Ontology, &RttiTypes::Typesystem}, &pModule); registry.registerParser({"application/document"}, {&RttiTypes::Document}, &pDocument); } @@ -78,16 +78,16 @@ TEST(ResourceRequest, deduction) { TestSetup t; - ResourceRequest req("test.domain", "", "", {&RttiTypes::Domain}); + ResourceRequest req("test.ontology", "", "", {&RttiTypes::Ontology}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); - ASSERT_EQ("application/domain", req.getMimetype()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain}), req.getSupportedTypes()); - ASSERT_EQ(ResourceType::DOMAIN_DESC, req.getResourceType()); + ASSERT_EQ("test.ontology", req.getPath()); + ASSERT_EQ("application/ontology", req.getMimetype()); + ASSERT_EQ(RttiSet({&RttiTypes::Ontology}), req.getSupportedTypes()); + ASSERT_EQ(ResourceType::ONTOLOGY, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } @@ -95,17 +95,17 @@ TEST(ResourceRequest, deductionWithMimetype) { TestSetup t; - ResourceRequest req("test.domain", "application/typesystem", "", + ResourceRequest req("test.ontology", "application/typesystem", "", {&RttiTypes::Typesystem}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); + ASSERT_EQ("test.ontology", req.getPath()); ASSERT_EQ("application/typesystem", req.getMimetype()); ASSERT_EQ(RttiSet({&RttiTypes::Typesystem}), req.getSupportedTypes()); ASSERT_EQ(ResourceType::TYPESYSTEM, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } @@ -113,18 +113,18 @@ TEST(ResourceRequest, deductionWithUnknownResourceType) { TestSetup t; - ResourceRequest req("test.domain", "", "", - {&RttiTypes::Domain, &RttiTypes::Typesystem}); + ResourceRequest req("test.ontology", "", "", + {&RttiTypes::Ontology, &RttiTypes::Typesystem}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); - ASSERT_EQ("application/domain", req.getMimetype()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ("test.ontology", req.getPath()); + ASSERT_EQ("application/ontology", req.getMimetype()); + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getSupportedTypes()); ASSERT_EQ(ResourceType::UNKNOWN, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } @@ -132,17 +132,17 @@ TEST(ResourceRequest, deductionWithRel) { TestSetup t; - ResourceRequest req("test.domain", "", "domain", - {&RttiTypes::Domain, &RttiTypes::Typesystem}); + ResourceRequest req("test.ontology", "", "ontology", + {&RttiTypes::Ontology, &RttiTypes::Typesystem}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); - ASSERT_EQ("application/domain", req.getMimetype()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain}), req.getSupportedTypes()); - ASSERT_EQ(ResourceType::DOMAIN_DESC, req.getResourceType()); + ASSERT_EQ("test.ontology", req.getPath()); + ASSERT_EQ("application/ontology", req.getMimetype()); + ASSERT_EQ(RttiSet({&RttiTypes::Ontology}), req.getSupportedTypes()); + ASSERT_EQ(ResourceType::ONTOLOGY, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } } diff --git a/test/formats/osml/OsmlParserTest.cpp b/test/formats/osml/OsmlParserTest.cpp index 5127b32..c88232b 100644 --- a/test/formats/osml/OsmlParserTest.cpp +++ b/test/formats/osml/OsmlParserTest.cpp @@ -23,7 +23,7 @@ #include <core/common/CharReader.hpp> #include <core/common/SourceContextReader.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include <core/model/Node.hpp> #include <core/model/Project.hpp> @@ -37,7 +37,7 @@ namespace ousia { namespace RttiTypes { extern const Rtti Document; -extern const Rtti Domain; +extern const Rtti Ontology; extern const Rtti Typesystem; } @@ -70,15 +70,15 @@ TEST(OsmlParser, emptyDocument) ASSERT_TRUE(node->isa(&RttiTypes::Document)); } -TEST(OsmlParser, emptyDomain) +TEST(OsmlParser, emptyOntology) { OsmlStandaloneEnvironment env(logger); Rooted<Node> node = - env.parse("empty_domain.osml", "", "", RttiSet{&RttiTypes::Node}); + env.parse("empty_ontology.osml", "", "", RttiSet{&RttiTypes::Node}); ASSERT_TRUE(node != nullptr); - ASSERT_TRUE(node->isa(&RttiTypes::Domain)); - ASSERT_EQ("testDomain", node->getName()); + ASSERT_TRUE(node->isa(&RttiTypes::Ontology)); + ASSERT_EQ("testOntology", node->getName()); } TEST(OsmlParser, emptyTypesystem) @@ -106,13 +106,13 @@ TEST(OsmlParser, rollbackOnInvalidElement) ASSERT_TRUE(node->isa(&RttiTypes::Document)); } -TEST(OsmlParser, inlineDomain) +TEST(OsmlParser, inlineOntology) { OsmlStandaloneEnvironment env(logger); logger.reset(); Rooted<Node> node = - env.parse("inline_domain.osml", "", "", RttiSet{&RttiTypes::Node}); + env.parse("inline_ontology.osml", "", "", RttiSet{&RttiTypes::Node}); ASSERT_FALSE(logger.hasError()); ASSERT_TRUE(node != nullptr); @@ -156,7 +156,7 @@ TEST(OsmlParser, structureInheritance) ASSERT_FALSE(logger.hasError()); ASSERT_TRUE(node != nullptr); - ASSERT_TRUE(node->isa(&RttiTypes::Domain)); + ASSERT_TRUE(node->isa(&RttiTypes::Ontology)); } TEST(OsmlParser, structWithNoField) diff --git a/test/formats/osxml/OsxmlParserTest.cpp b/test/formats/osxml/OsxmlParserTest.cpp index 3bf4a47..79dd58b 100644 --- a/test/formats/osxml/OsxmlParserTest.cpp +++ b/test/formats/osxml/OsxmlParserTest.cpp @@ -23,7 +23,7 @@ #include <core/common/CharReader.hpp> #include <core/common/SourceContextReader.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Node.hpp> #include <core/model/Project.hpp> #include <core/frontend/TerminalLogger.hpp> @@ -36,7 +36,7 @@ namespace ousia { namespace RttiTypes { extern const Rtti Document; -extern const Rtti Domain; +extern const Rtti Ontology; extern const Rtti Typesystem; } @@ -88,7 +88,7 @@ static void checkAttributes(Handle<StructType> expected, } static void checkStructuredClass( - Handle<Node> n, const std::string &name, Handle<Domain> domain, + Handle<Node> n, const std::string &name, Handle<Ontology> ontology, Variant cardinality = Cardinality::any(), Handle<StructType> attributesDescriptor = nullptr, Handle<StructuredClass> superclass = nullptr, bool transparent = false, @@ -98,7 +98,7 @@ static void checkStructuredClass( Handle<StructuredClass> sc = n.cast<StructuredClass>(); ASSERT_FALSE(sc == nullptr); ASSERT_EQ(name, sc->getName()); - ASSERT_EQ(domain, sc->getParent()); + ASSERT_EQ(ontology, sc->getParent()); ASSERT_EQ(cardinality, sc->getCardinality()); ASSERT_EQ(transparent, sc->isTransparent()); ASSERT_EQ(root, sc->hasRootPermission()); @@ -106,44 +106,44 @@ static void checkStructuredClass( } static Rooted<StructuredClass> checkStructuredClass( - const std::string &resolve, const std::string &name, Handle<Domain> domain, + const std::string &resolve, const std::string &name, Handle<Ontology> ontology, Variant cardinality = Cardinality::any(), Handle<StructType> attributesDescriptor = nullptr, Handle<StructuredClass> superclass = nullptr, bool transparent = false, bool root = false) { - auto res = domain->resolve(&RttiTypes::StructuredClass, resolve); + auto res = ontology->resolve(&RttiTypes::StructuredClass, resolve); if (res.size() != 1) { throw OusiaException("resolution error!"); } Handle<StructuredClass> sc = res[0].node.cast<StructuredClass>(); - checkStructuredClass(sc, name, domain, cardinality, attributesDescriptor, + checkStructuredClass(sc, name, ontology, cardinality, attributesDescriptor, superclass, transparent, root); return sc; } static void checkAnnotationClass( - Handle<Node> n, const std::string &name, Handle<Domain> domain, + Handle<Node> n, const std::string &name, Handle<Ontology> ontology, Handle<StructType> attributesDescriptor = nullptr) { ASSERT_FALSE(n == nullptr); Handle<AnnotationClass> ac = n.cast<AnnotationClass>(); ASSERT_FALSE(ac == nullptr); ASSERT_EQ(name, ac->getName()); - ASSERT_EQ(domain, ac->getParent()); + ASSERT_EQ(ontology, ac->getParent()); checkAttributes(attributesDescriptor, ac); } static Rooted<AnnotationClass> checkAnnotationClass( - const std::string &resolve, const std::string &name, Handle<Domain> domain, + const std::string &resolve, const std::string &name, Handle<Ontology> ontology, Handle<StructType> attributesDescriptor = nullptr) { - auto res = domain->resolve(&RttiTypes::AnnotationClass, resolve); + auto res = ontology->resolve(&RttiTypes::AnnotationClass, resolve); if (res.size() != 1) { throw OusiaException("resolution error!"); } Handle<AnnotationClass> ac = res[0].node.cast<AnnotationClass>(); - checkAnnotationClass(ac, name, domain, attributesDescriptor); + checkAnnotationClass(ac, name, ontology, attributesDescriptor); return ac; } @@ -192,33 +192,33 @@ static void checkFieldDescriptor( optional); } -TEST(OsxmlParser, domainParsing) +TEST(OsxmlParser, ontologyParsing) { XmlStandaloneEnvironment env(logger); - Rooted<Node> book_domain_node = - env.parse("book_domain.osxml", "", "", RttiSet{&RttiTypes::Domain}); - ASSERT_FALSE(book_domain_node == nullptr); + Rooted<Node> book_ontology_node = + env.parse("book_ontology.osxml", "", "", RttiSet{&RttiTypes::Ontology}); + ASSERT_FALSE(book_ontology_node == nullptr); ASSERT_FALSE(logger.hasError()); - // check the domain node. - Rooted<Domain> book_domain = book_domain_node.cast<Domain>(); - ASSERT_EQ("book", book_domain->getName()); + // check the ontology node. + Rooted<Ontology> book_ontology = book_ontology_node.cast<Ontology>(); + ASSERT_EQ("book", book_ontology->getName()); // get the book struct node. Cardinality single; single.merge({1}); Rooted<StructuredClass> book = checkStructuredClass( - "book", "book", book_domain, single, nullptr, nullptr, false, true); + "book", "book", book_ontology, single, nullptr, nullptr, false, true); // get the chapter struct node. Rooted<StructuredClass> chapter = - checkStructuredClass("chapter", "chapter", book_domain); + checkStructuredClass("chapter", "chapter", book_ontology); Rooted<StructuredClass> section = - checkStructuredClass("section", "section", book_domain); + checkStructuredClass("section", "section", book_ontology); Rooted<StructuredClass> subsection = - checkStructuredClass("subsection", "subsection", book_domain); + checkStructuredClass("subsection", "subsection", book_ontology); Rooted<StructuredClass> paragraph = - checkStructuredClass("paragraph", "paragraph", book_domain, + checkStructuredClass("paragraph", "paragraph", book_ontology, Cardinality::any(), nullptr, nullptr, true, false); Rooted<StructuredClass> text = - checkStructuredClass("text", "text", book_domain, Cardinality::any(), + checkStructuredClass("text", "text", book_ontology, Cardinality::any(), nullptr, nullptr, true, false); // check the FieldDescriptors. @@ -231,19 +231,19 @@ TEST(OsxmlParser, domainParsing) text, {}, "", FieldDescriptor::FieldType::TREE, env.project->getSystemTypesystem()->getStringType(), false); - // check parent handling using the headings domain. - Rooted<Node> headings_domain_node = - env.parse("headings_domain.osxml", "", "", RttiSet{&RttiTypes::Domain}); - ASSERT_FALSE(headings_domain_node == nullptr); + // check parent handling using the headings ontology. + Rooted<Node> headings_ontology_node = + env.parse("headings_ontology.osxml", "", "", RttiSet{&RttiTypes::Ontology}); + ASSERT_FALSE(headings_ontology_node == nullptr); ASSERT_FALSE(logger.hasError()); - Rooted<Domain> headings_domain = headings_domain_node.cast<Domain>(); + Rooted<Ontology> headings_ontology = headings_ontology_node.cast<Ontology>(); // now there should be a heading struct. Rooted<StructuredClass> heading = - checkStructuredClass("heading", "heading", headings_domain, single, + checkStructuredClass("heading", "heading", headings_ontology, single, nullptr, nullptr, true, false); // which should be a reference to the paragraph descriptor. checkFieldDescriptor(heading, paragraph, {text}); - // and each struct in the book domain (except for text) should have a + // and each struct in the book ontology (except for text) should have a // heading field now. checkFieldDescriptor(book, {heading}, "heading", FieldDescriptor::FieldType::SUBTREE, nullptr, true); @@ -256,21 +256,21 @@ TEST(OsxmlParser, domainParsing) checkFieldDescriptor(paragraph, {heading}, "heading", FieldDescriptor::FieldType::SUBTREE, nullptr, true); - // check annotation handling using the comments domain. - Rooted<Node> comments_domain_node = - env.parse("comments_domain.osxml", "", "", RttiSet{&RttiTypes::Domain}); - ASSERT_FALSE(comments_domain_node == nullptr); + // check annotation handling using the comments ontology. + Rooted<Node> comments_ontology_node = + env.parse("comments_ontology.osxml", "", "", RttiSet{&RttiTypes::Ontology}); + ASSERT_FALSE(comments_ontology_node == nullptr); ASSERT_FALSE(logger.hasError()); - Rooted<Domain> comments_domain = comments_domain_node.cast<Domain>(); + Rooted<Ontology> comments_ontology = comments_ontology_node.cast<Ontology>(); // now we should be able to find a comment annotation. Rooted<AnnotationClass> comment_anno = - checkAnnotationClass("comment", "comment", comments_domain); + checkAnnotationClass("comment", "comment", comments_ontology); // as well as a comment struct Rooted<StructuredClass> comment = - checkStructuredClass("comment", "comment", comments_domain); + checkStructuredClass("comment", "comment", comments_ontology); // and a reply struct Rooted<StructuredClass> reply = - checkStructuredClass("reply", "reply", comments_domain); + checkStructuredClass("reply", "reply", comments_ontology); // check the fields for each of them. { std::vector<Rooted<Descriptor>> descs{comment_anno, comment, reply}; diff --git a/test/plugins/filesystem/FileLocatorTest.cpp b/test/plugins/filesystem/FileLocatorTest.cpp index 22db926..e2aacb1 100644 --- a/test/plugins/filesystem/FileLocatorTest.cpp +++ b/test/plugins/filesystem/FileLocatorTest.cpp @@ -38,12 +38,12 @@ TEST(FileLocator, addSearchPath) // Add one path for three types. instance.addSearchPath(".", - {ResourceType::DOMAIN_DESC, ResourceType::SCRIPT, + {ResourceType::ONTOLOGY, ResourceType::SCRIPT, ResourceType::TYPESYSTEM}); ASSERT_EQ(3U, instance.getSearchPaths().size()); - auto it = instance.getSearchPaths().find(ResourceType::DOMAIN_DESC); + auto it = instance.getSearchPaths().find(ResourceType::ONTOLOGY); ASSERT_EQ(1U, it->second.size()); ASSERT_EQ(canonicalPath, it->second[0]); @@ -64,12 +64,12 @@ TEST(FileLocator, addSearchPath) // Adding the path another time should not increase the number of found // paths, except for new resource types instance.addSearchPath( - canonicalPath, {ResourceType::DOMAIN_DESC, ResourceType::SCRIPT, + canonicalPath, {ResourceType::ONTOLOGY, ResourceType::SCRIPT, ResourceType::TYPESYSTEM, ResourceType::ATTRIBUTES}); ASSERT_EQ(4U, instance.getSearchPaths().size()); - it = instance.getSearchPaths().find(ResourceType::DOMAIN_DESC); + it = instance.getSearchPaths().find(ResourceType::ONTOLOGY); ASSERT_EQ(1U, it->second.size()); ASSERT_EQ(canonicalPath, it->second[0]); @@ -93,11 +93,11 @@ TEST(FileLocator, addSearchPath) std::string canonicalPath2 = fs::canonical("..").generic_string(); - instance.addSearchPath("..", {ResourceType::DOMAIN_DESC}); + instance.addSearchPath("..", {ResourceType::ONTOLOGY}); ASSERT_EQ(4U, instance.getSearchPaths().size()); - it = instance.getSearchPaths().find(ResourceType::DOMAIN_DESC); + it = instance.getSearchPaths().find(ResourceType::ONTOLOGY); ASSERT_EQ(2U, it->second.size()); ASSERT_EQ(canonicalPath, it->second[0]); @@ -106,7 +106,7 @@ TEST(FileLocator, addSearchPath) void assert_located(const FileLocator &instance, const std::string &path, const std::string &relativeTo, - ResourceType type = ResourceType::DOMAIN_DESC) + ResourceType type = ResourceType::ONTOLOGY) { Resource res; ASSERT_TRUE(instance.locate(res, path, type, relativeTo)); @@ -117,7 +117,7 @@ void assert_located(const FileLocator &instance, const std::string &path, void assert_not_located(const FileLocator &instance, const std::string &path, const std::string &relativeTo, - ResourceType type = ResourceType::DOMAIN_DESC) + ResourceType type = ResourceType::ONTOLOGY) { Resource res; ASSERT_FALSE(instance.locate(res, path, type, relativeTo)); @@ -134,7 +134,7 @@ TEST(FileLocator, locate) assert_not_located(locator, "c.txt", ""); // Add the respective search path - locator.addUnittestSearchPath("filesystem/b", ResourceType::DOMAIN_DESC); + locator.addUnittestSearchPath("filesystem/b", ResourceType::ONTOLOGY); // Now we should be able to find both. assert_located(locator, "a.txt", ""); @@ -217,8 +217,8 @@ TEST(FileLocator, testDefaultSearchPaths) locator.addDefaultSearchPaths(); assert_not_located(locator, "book.osxml", "", ResourceType::UNKNOWN); - assert_located(locator, "domain/book.osxml", "", ResourceType::UNKNOWN); - assert_located(locator, "book.osxml", "", ResourceType::DOMAIN_DESC); + assert_located(locator, "ontology/book.osxml", "", ResourceType::UNKNOWN); + assert_located(locator, "book.osxml", "", ResourceType::ONTOLOGY); assert_not_located(locator, "color.osxml", "", ResourceType::UNKNOWN); assert_located(locator, "typesystem/color.osxml", "", ResourceType::UNKNOWN); diff --git a/test/plugins/html/DemoOutputTest.cpp b/test/plugins/html/DemoOutputTest.cpp index 2f56e40..debb667 100644 --- a/test/plugins/html/DemoOutputTest.cpp +++ b/test/plugins/html/DemoOutputTest.cpp @@ -26,10 +26,10 @@ #include <core/common/Rtti.hpp> #include <core/frontend/TerminalLogger.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/TestAdvanced.hpp> -#include <core/model/TestDomain.hpp> +#include <core/model/TestOntology.hpp> namespace ousia { namespace html { @@ -40,12 +40,12 @@ TEST(DemoHTMLTransformer, writeHTML) TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domains. - Rooted<Domain> bookDom = constructBookDomain(mgr, sys, logger); - Rooted<Domain> headingDom = - constructHeadingDomain(mgr, sys, bookDom, logger); - Rooted<Domain> listDom = constructListDomain(mgr, sys, bookDom, logger); - Rooted<Domain> emDom = constructEmphasisDomain(mgr, sys, logger); + // Get the ontologies. + Rooted<Ontology> bookDom = constructBookOntology(mgr, sys, logger); + Rooted<Ontology> headingDom = + constructHeadingOntology(mgr, sys, bookDom, logger); + Rooted<Ontology> listDom = constructListOntology(mgr, sys, bookDom, logger); + Rooted<Ontology> emDom = constructEmphasisOntology(mgr, sys, logger); // Construct the document. Rooted<Document> doc = constructAdvancedDocument( mgr, logger, bookDom, headingDom, listDom, emDom); @@ -75,13 +75,13 @@ TEST(DemoHTMLTransformer, AnnotationProcessing) TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domains. - Rooted<Domain> bookDom = constructBookDomain(mgr, sys, logger); - Rooted<Domain> emDom = constructEmphasisDomain(mgr, sys, logger); + // Get the ontologies. + Rooted<Ontology> bookDom = constructBookOntology(mgr, sys, logger); + Rooted<Ontology> emDom = constructEmphasisOntology(mgr, sys, logger); // Construct a document only containing overlapping annotations. // it has the form: <em>bla<strong>blub</em>bla</strong> Rooted<Document> doc{new Document(mgr, "annotations.oxd")}; - doc->referenceDomains({bookDom, emDom}); + doc->referenceOntologys({bookDom, emDom}); Rooted<StructuredEntity> book = buildRootStructuredEntity(doc, logger, {"book"}); ASSERT_TRUE(book != nullptr); diff --git a/test/plugins/xml/XmlOutputTest.cpp b/test/plugins/xml/XmlOutputTest.cpp index fcf72d2..ac80a57 100644 --- a/test/plugins/xml/XmlOutputTest.cpp +++ b/test/plugins/xml/XmlOutputTest.cpp @@ -26,10 +26,10 @@ #include <core/common/Rtti.hpp> #include <core/frontend/TerminalLogger.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/TestAdvanced.hpp> -#include <core/model/TestDomain.hpp> +#include <core/model/TestOntology.hpp> namespace ousia { namespace xml { @@ -40,12 +40,12 @@ TEST(DemoHTMLTransformer, writeHTML) TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domains. - Rooted<Domain> bookDom = constructBookDomain(mgr, sys, logger); - Rooted<Domain> headingDom = - constructHeadingDomain(mgr, sys, bookDom, logger); - Rooted<Domain> listDom = constructListDomain(mgr, sys, bookDom, logger); - Rooted<Domain> emDom = constructEmphasisDomain(mgr, sys, logger); + // Get the ontologies. + Rooted<Ontology> bookDom = constructBookOntology(mgr, sys, logger); + Rooted<Ontology> headingDom = + constructHeadingOntology(mgr, sys, bookDom, logger); + Rooted<Ontology> listDom = constructListOntology(mgr, sys, bookDom, logger); + Rooted<Ontology> emDom = constructEmphasisOntology(mgr, sys, logger); // Construct the document. Rooted<Document> doc = constructAdvancedDocument( mgr, logger, bookDom, headingDom, listDom, emDom); @@ -71,13 +71,13 @@ TEST(DemoHTMLTransformer, AnnotationProcessing) TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domains. - Rooted<Domain> bookDom = constructBookDomain(mgr, sys, logger); - Rooted<Domain> emDom = constructEmphasisDomain(mgr, sys, logger); + // Get the ontologies. + Rooted<Ontology> bookDom = constructBookOntology(mgr, sys, logger); + Rooted<Ontology> emDom = constructEmphasisOntology(mgr, sys, logger); // Construct a document only containing overlapping annotations. // it has the form: <em>bla<strong>blub</em>bla</strong> Rooted<Document> doc{new Document(mgr, "annotations.oxd")}; - doc->referenceDomains({bookDom, emDom}); + doc->referenceOntologys({bookDom, emDom}); Rooted<StructuredEntity> book = buildRootStructuredEntity(doc, logger, {"book"}); ASSERT_TRUE(book != nullptr); @@ -114,11 +114,11 @@ TEST(DemoHTMLTransformer, PrimitiveSubtreeFields) TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct a simple domain. - Rooted<Domain> domain{new Domain(mgr, sys, "myDomain")}; + // Construct a simple ontology. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "myOntology")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "A", ontology, Cardinality::any(), nullptr, false, true)}; Rooted<FieldDescriptor> A_a = A->createPrimitiveFieldDescriptor(sys->getStringType(), logger, FieldDescriptor::FieldType::SUBTREE, @@ -129,7 +129,7 @@ TEST(DemoHTMLTransformer, PrimitiveSubtreeFields) "b").first; Rooted<FieldDescriptor> A_main = A->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; - ASSERT_TRUE(domain->validate(logger)); + ASSERT_TRUE(ontology->validate(logger)); // Construct a document for it. Rooted<Document> doc{new Document(mgr, "myDoc")}; Rooted<StructuredEntity> A_impl = doc->createRootStructuredEntity(A); @@ -144,7 +144,7 @@ TEST(DemoHTMLTransformer, PrimitiveSubtreeFields) transformer.writeXml(doc, out, logger, dummy, false); const std::string res = out.str(); ASSERT_TRUE( - res.find("<myDomain:A><a>test_a</a><b>test_b</b>test</myDomain:A>") != + res.find("<myOntology:A><a>test_a</a><b>test_b</b>test</myOntology:A>") != std::string::npos); } } diff --git a/testdata/osmlparser/empty_domain.osml b/testdata/osmlparser/empty_domain.osml deleted file mode 100644 index e8d6452..0000000 --- a/testdata/osmlparser/empty_domain.osml +++ /dev/null @@ -1,2 +0,0 @@ -\begin{domain#testDomain} -\end{domain} diff --git a/testdata/osmlparser/empty_ontology.osml b/testdata/osmlparser/empty_ontology.osml new file mode 100644 index 0000000..ffc9d80 --- /dev/null +++ b/testdata/osmlparser/empty_ontology.osml @@ -0,0 +1,2 @@ +\begin{ontology#testOntology} +\end{ontology} diff --git a/testdata/osmlparser/explicit_fields.osml b/testdata/osmlparser/explicit_fields.osml index a9ba1a3..ea13c02 100644 --- a/testdata/osmlparser/explicit_fields.osml +++ b/testdata/osmlparser/explicit_fields.osml @@ -1,6 +1,6 @@ \document -\domain#test +\ontology#test \struct#a[isRoot=true] \primitive#b[type=string,isSubtree=true] \primitive#c[type=string,isSubtree=true] diff --git a/testdata/osmlparser/include_recursive_root.osml b/testdata/osmlparser/include_recursive_root.osml index b3e433f..b29f1f4 100644 --- a/testdata/osmlparser/include_recursive_root.osml +++ b/testdata/osmlparser/include_recursive_root.osml @@ -1,6 +1,6 @@ \begin{document} -\domain#testDomain +\ontology#testOntology \struct#test[isRoot=true] \begin{test} diff --git a/testdata/osmlparser/include_root.osml b/testdata/osmlparser/include_root.osml index 1d1d660..3c65ca1 100644 --- a/testdata/osmlparser/include_root.osml +++ b/testdata/osmlparser/include_root.osml @@ -1,6 +1,6 @@ \begin{document} -\domain#testDomain +\ontology#testOntology \struct#test[isRoot=true] \field \childRef[ref=a] diff --git a/testdata/osmlparser/inline_domain.osml b/testdata/osmlparser/inline_ontology.osml index 1d71df4..1bba1f6 100644 --- a/testdata/osmlparser/inline_domain.osml +++ b/testdata/osmlparser/inline_ontology.osml @@ -1,6 +1,6 @@ \begin{document} -\domain#testDomain +\ontology#testOntology \struct#test[isRoot=true] \field \childRef[ref=a] diff --git a/testdata/osmlparser/invalid_explicit_fields.osml b/testdata/osmlparser/invalid_explicit_fields.osml index 9986204..eeecc0a 100644 --- a/testdata/osmlparser/invalid_explicit_fields.osml +++ b/testdata/osmlparser/invalid_explicit_fields.osml @@ -1,6 +1,6 @@ \document -\domain#test +\ontology#test \struct#a[isRoot=true] \primitive#b[type=string,isSubtree=true] \primitive#c[type=string,isSubtree=true] diff --git a/testdata/osmlparser/rollback_on_invalid_element.osml b/testdata/osmlparser/rollback_on_invalid_element.osml index 671c76d..282e741 100644 --- a/testdata/osmlparser/rollback_on_invalid_element.osml +++ b/testdata/osmlparser/rollback_on_invalid_element.osml @@ -1,6 +1,6 @@ \begin{document} -\domain#testDomain +\ontology#testOntology \struct#test[isRoot=true] \field \childRef[ref=a] diff --git a/testdata/osmlparser/struct_with_no_field.osml b/testdata/osmlparser/struct_with_no_field.osml index 8cf2d02..4f27998 100644 --- a/testdata/osmlparser/struct_with_no_field.osml +++ b/testdata/osmlparser/struct_with_no_field.osml @@ -1,6 +1,6 @@ \document -\domain#test +\ontology#test \struct#a[isRoot=true] \field \childRef[ref=b] diff --git a/testdata/osmlparser/structure_inheritance.osml b/testdata/osmlparser/structure_inheritance.osml index 6b88f2f..008778a 100644 --- a/testdata/osmlparser/structure_inheritance.osml +++ b/testdata/osmlparser/structure_inheritance.osml @@ -1,4 +1,4 @@ -\domain#test +\ontology#test \struct#a \primitive[type=string] \struct#b[isa=a] diff --git a/testdata/osxmlparser/book_domain.osxml b/testdata/osxmlparser/book_ontology.osxml index 5a8cc67..0b393e6 100644 --- a/testdata/osxmlparser/book_domain.osxml +++ b/testdata/osxmlparser/book_ontology.osxml @@ -1,10 +1,10 @@ <?xml version="1.0" standalone="yes"?> -<!-- The domain node is the root node of a single domain definition --> -<domain name="book"> +<!-- The ontology node is the root node of a single ontology definition --> +<ontology name="book"> <!-- We start by declaring the structured classes. This implicitly defines a context free grammar, which specifies the language of documents that - may be constructed using this domain. Note that this grammar may be - influenced by other domains depending on this one. --> + may be constructed using this ontology. Note that this grammar may be + influenced by other ontologies depending on this one. --> <!-- Note that we specify neither attributes, nor parent, nor transparency, meaning that we refer to the default values. Also note that we need to specify explicitly, which classes @@ -95,4 +95,4 @@ <!-- we might want to specify std.string here --> <primitive type="string"/> </struct> -</domain> +</ontology> diff --git a/testdata/osxmlparser/comments_domain.osxml b/testdata/osxmlparser/comments_ontology.osxml index dc7742e..f2423be 100644 --- a/testdata/osxmlparser/comments_domain.osxml +++ b/testdata/osxmlparser/comments_ontology.osxml @@ -1,6 +1,6 @@ <?xml version="1.0" standalone="yes"?> -<domain name="comments"> - <import rel="domain" src="./book_domain.osxml"/> +<ontology name="comments"> + <import rel="ontology" src="./book_ontology.osxml"/> <!-- an annotation comment --> <annotation name="comment"> @@ -37,4 +37,4 @@ <childRef ref="book.paragraph"/> </field> </struct> -</domain> +</ontology> diff --git a/testdata/osxmlparser/complex_book.osxml b/testdata/osxmlparser/complex_book.osxml index 8fff93d..222b146 100644 --- a/testdata/osxmlparser/complex_book.osxml +++ b/testdata/osxmlparser/complex_book.osxml @@ -1,12 +1,12 @@ <?xml version="1.0"?> <document> - <import rel="domain" src="book"/> - <import rel="domain" src="headings"/> - <import rel="domain" src="meta"/> - <import rel="domain" src="bibliography"/> - <!--<import rel="domain" src="emphasis.oxm"/> - <import rel="domain" src="comments.oxm"/> + <import rel="ontology" src="book"/> + <import rel="ontology" src="headings"/> + <import rel="ontology" src="meta"/> + <import rel="ontology" src="bibliography"/> + <!--<import rel="ontology" src="emphasis.oxm"/> + <import rel="ontology" src="comments.oxm"/> <alias tag="paragraph" aka="p"/> <alias tag="emphasized" aka="em"/>--> diff --git a/testdata/osxmlparser/headings_domain.osxml b/testdata/osxmlparser/headings_ontology.osxml index 07d3db2..413eaa9 100644 --- a/testdata/osxmlparser/headings_domain.osxml +++ b/testdata/osxmlparser/headings_ontology.osxml @@ -1,7 +1,7 @@ <?xml version="1.0" standalone="yes"?> -<domain name="headings"> +<ontology name="headings"> - <import rel="domain" src="./book_domain.osxml"/> + <import rel="ontology" src="./book_ontology.osxml"/> <struct name="heading" cardinality="1" transparent="true"> <!-- The parent mechanism is a curious thing. Remind yourself @@ -26,8 +26,8 @@ <!-- regarding its fields we have a problem here. We do not want to declare a new field, because in fact we want to allow every bit of content that a paragraph would allow - also considering - possible extensions of paragraph by other domains. + possible extensions of paragraph by other ontologies. So we need to reference the default field of paragraph. --> <fieldRef ref="book.paragraph.$default"/> </struct> -</domain> +</ontology> diff --git a/testdata/osxmlparser/simple_book.osxml b/testdata/osxmlparser/simple_book.osxml index 310a413..ec1e45a 100644 --- a/testdata/osxmlparser/simple_book.osxml +++ b/testdata/osxmlparser/simple_book.osxml @@ -1,9 +1,9 @@ <?xml version="1.0"?> <document> - <import rel="domain" src="book_domain.osxml"/> + <import rel="ontology" src="book_ontology.osxml"/> <book> This might be some introductory text or a dedication. - <!-- Note that a better version of the book domain might specify + <!-- Note that a better version of the book ontology might specify headings here. --> <chapter name="myFirstChapter"> Here we might have an introduction to the chapter. |