1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*!
Standard library module for namespace `rdf`.

*/

use crate::model::annotations::AnnotationBuilder;
use crate::model::modules::Module;
use crate::model::HasBody;
use crate::stdlib::rdfs;
// ------------------------------------------------------------------------------------------------
// Public Macros
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// Public Types
// ------------------------------------------------------------------------------------------------

pub const MODULE_NAME: &str = "rdf";
pub const MODULE_URL: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";

pub const HTML: &str = "HTML";
pub const JSON: &str = "JSON";
pub const LANG_STRING: &str = "langString";
pub const PLAIN_LITERAL: &str = "PlainLiteral";
pub const XML_LITERAL: &str = "XMLLiteral";

pub const ALT: &str = "Alt";
pub const BAG: &str = "Bag";
pub const LIST: &str = "List";
pub const PROPERTY: &str = "Property";
pub const SEQ: &str = "Seq";
pub const STATEMENT: &str = "Statement";

pub const FIRST: &str = "first";
pub const NIL: &str = "nil";
pub const OBJECT: &str = "object";
pub const PREDICATE: &str = "predicate";
pub const REST: &str = "rest";
pub const SUBJECT: &str = "subject";
pub const TYPE: &str = "type";
pub const VALUE: &str = "value";

pub const COMPOUND: &str = "CompoundLiteral";
pub const LANGUAGE: &str = "language";
pub const DIRECTION: &str = "direction";

// ------------------------------------------------------------------------------------------------
// Public Functions
// ------------------------------------------------------------------------------------------------

pub fn module() -> Module {
    #[allow(non_snake_case)]
    let MODULE_IRI: url::Url = url::Url::parse(MODULE_URL).unwrap();
    let mut module = Module::empty(id!(MODULE_NAME)).with_base_uri(MODULE_IRI.clone());

    module
        .body_mut()
        .add_to_imports(import!(id!(rdfs::MODULE_NAME)));

    module.body_mut().extend_definitions(vec![
        // Datatypes
        rdf!(datatype HTML, MODULE_IRI; rdfs::LITERAL)
            .with_comment("The datatype of RDF literals storing fragments of HTML content")
            .with_see_also_str("http://www.w3.org/TR/rdf11-concepts/#section-html")
            .into(),
        rdf!(datatype JSON, MODULE_IRI; rdfs::LITERAL)
            .with_comment("The datatype of RDF literals storing JSON content")
            .with_see_also_str("https://www.w3.org/TR/json-ld11/#the-rdf-json-datatype")
            .into(),
        rdf!(datatype LANG_STRING, MODULE_IRI; rdfs::LITERAL)
            .with_comment("The datatype of language-tagged string values")
            .with_see_also_str("http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal")
            .into(),
        rdf!(datatype PLAIN_LITERAL, MODULE_IRI; rdfs::LITERAL)
            .with_comment("The class of plain (i.e. untyped) literal values, as used in RIF and OWL 2")
            .with_see_also_str("http://www.w3.org/TR/rdf-plain-literal/")
            .into(),
        rdf!(datatype XML_LITERAL, MODULE_IRI; rdfs::LITERAL)
            .with_comment("The datatype of XML literal values")
            .into(),

        // Classes
        rdf!(class PROPERTY, MODULE_IRI; (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("The class of RDF properties.")
            .into(),

        // Properties
        rdf!(property TYPE, MODULE_IRI;
             (rdfs::MODULE_NAME, rdfs::RESOURCE) =>
             (rdfs::MODULE_NAME, rdfs::CLASS))
            .into(),

        // Container Classes and Properties
        rdf!(class ALT, MODULE_IRI;
             (rdfs::MODULE_NAME, rdfs::CONTAINER))
            .with_comment("The class of containers of alternatives.")
            .into(),
        rdf!(class BAG, MODULE_IRI;
             (rdfs::MODULE_NAME, rdfs::CONTAINER))
            .with_comment("The class of unordered containers.")
            .into(),
        rdf!(class SEQ, MODULE_IRI;
             (rdfs::MODULE_NAME, rdfs::CONTAINER))
            .with_comment("The class of ordered containers.")
            .into(),

        // RDF Collections
        rdf!(class LIST, MODULE_IRI;
             (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("The class of RDF Lists.")
           .into(),
        rdf!(property FIRST, MODULE_IRI;
             LIST => (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("The first item in the subject RDF list.")
            .into(),
        rdf!(property REST, MODULE_IRI; LIST => LIST)
            .with_comment("The rest of the subject RDF list after the first item.")
            .into(),
        rdf!(thing NIL, MODULE_IRI, LIST)
            .with_comment("The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it.")
            .into(),

        // Reification Vocabulary
        rdf!(class STATEMENT, MODULE_IRI; (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("The class of RDF statements.")
            .into(),
        rdf!(property SUBJECT, MODULE_IRI;
             STATEMENT => (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("The subject of the subject RDF statement.")
            .into(),
        rdf!(property PREDICATE, MODULE_IRI;
             STATEMENT => (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("The predicate of the subject RDF statement.")
            .into(),
        rdf!(property OBJECT, MODULE_IRI;
             STATEMENT => (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("The object of the subject RDF statement.")
            .into(),

        rdf!(property VALUE, MODULE_IRI;
             (rdfs::MODULE_NAME, rdfs::RESOURCE) =>
             (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("Idiomatic property used for structured values.")
            .into(),

        // Compound Literals
        rdf!(class COMPOUND, MODULE_IRI; (rdfs::MODULE_NAME, rdfs::RESOURCE))
            .with_comment("A class representing a compound literal.")
            .with_see_also_str("https://www.w3.org/TR/json-ld11/#the-rdf-compoundliteral-class-and-the-rdf-language-and-rdf-direction-properties")
            .into(),
        rdf!(property DIRECTION, MODULE_IRI; COMPOUND)
            .with_comment("The language component of a CompoundLiteral.")
            .with_see_also_str("https://www.w3.org/TR/json-ld11/#the-rdf-compoundliteral-class-and-the-rdf-language-and-rdf-direction-properties")
            .into(),
        rdf!(property LANGUAGE, MODULE_IRI; COMPOUND)
            .with_comment("The base direction component of a CompoundLiteral.")
            .with_see_also_str("https://www.w3.org/TR/json-ld11/#the-rdf-compoundliteral-class-and-the-rdf-language-and-rdf-direction-properties")
            .into(),
     ]);

    module
}