1 | <?php |
||
51 | class RdfaLiteContext extends AbstractContext |
||
52 | { |
||
53 | /** |
||
54 | * Default vocabularies and their prefixes |
||
55 | * |
||
56 | * @var array |
||
57 | * @see https://www.w3.org/2011/rdfa-context/rdfa-1.1 |
||
58 | * @link https://www.w3.org/2013/json-ld-context/rdfa11 |
||
59 | */ |
||
60 | protected static $defaultVocabularies = [ |
||
61 | 'cat' => 'http://www.w3.org/ns/dcat#', |
||
62 | 'qb' => 'http://purl.org/linked-data/cube#', |
||
63 | 'grddl' => 'http://www.w3.org/2003/g/data-view#', |
||
64 | 'ma' => 'http://www.w3.org/ns/ma-ont#', |
||
65 | 'owl' => 'http://www.w3.org/2002/07/owl#', |
||
66 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', |
||
67 | 'rdfa' => 'http://www.w3.org/ns/rdfa#', |
||
68 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', |
||
69 | 'rif' => 'http://www.w3.org/2007/rif#', |
||
70 | 'rr' => 'http://www.w3.org/ns/r2rml#', |
||
71 | 'skos' => 'http://www.w3.org/2004/02/skos/core#', |
||
72 | 'skosxl' => 'http://www.w3.org/2008/05/skos-xl#', |
||
73 | 'wdr' => 'http://www.w3.org/2007/05/powder#', |
||
74 | 'void' => 'http://rdfs.org/ns/void#', |
||
75 | 'wdrs' => 'http://www.w3.org/2007/05/powder-s#', |
||
76 | 'xhv' => 'http://www.w3.org/1999/xhtml/vocab#', |
||
77 | 'xml' => 'http://www.w3.org/XML/1998/namespace', |
||
78 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
||
79 | 'prov' => 'http://www.w3.org/ns/prov#', |
||
80 | 'sd' => 'http://www.w3.org/ns/sparql-service-description#', |
||
81 | 'org' => 'http://www.w3.org/ns/org#', |
||
82 | 'gldp' => 'http://www.w3.org/ns/people#', |
||
83 | 'cnt' => 'http://www.w3.org/2008/content#', |
||
84 | 'dcat' => 'http://www.w3.org/ns/dcat#', |
||
85 | 'earl' => 'http://www.w3.org/ns/earl#', |
||
86 | 'ht' => 'http://www.w3.org/2006/http#', |
||
87 | 'ptr' => 'http://www.w3.org/2009/pointers#', |
||
88 | 'cc' => 'http://creativecommons.org/ns#', |
||
89 | 'ctag' => 'http://commontag.org/ns#', |
||
90 | 'dc' => 'http://purl.org/dc/terms/', |
||
91 | 'dc11' => 'http://purl.org/dc/elements/1.1/', |
||
92 | 'dcterms' => 'http://purl.org/dc/terms/', |
||
93 | 'foaf' => 'http://xmlns.com/foaf/0.1/', |
||
94 | 'gr' => 'http://purl.org/goodrelations/v1#', |
||
95 | 'ical' => 'http://www.w3.org/2002/12/cal/icaltzd#', |
||
96 | 'og' => 'http://ogp.me/ns#', |
||
97 | 'rev' => 'http://purl.org/stuff/rev#', |
||
98 | 'sioc' => 'http://rdfs.org/sioc/ns#', |
||
99 | 'v' => 'http://rdf.data-vocabulary.org/#', |
||
100 | 'vcard' => 'http://www.w3.org/2006/vcard/ns#', |
||
101 | 'schema' => 'http://schema.org/', |
||
102 | 'describedby' => 'http://www.w3.org/2007/05/powder-s#describedby', |
||
103 | 'license' => 'http://www.w3.org/1999/xhtml/vocab#license', |
||
104 | 'role' => 'http://www.w3.org/1999/xhtml/vocab#role' |
||
105 | ]; |
||
106 | |||
107 | /** |
||
108 | * Registered vocabularies |
||
109 | * |
||
110 | * @var array |
||
111 | */ |
||
112 | protected $vocabularies; |
||
113 | |||
114 | /** |
||
115 | * Context constructor |
||
116 | */ |
||
117 | 23 | public function __construct() |
|
122 | |||
123 | /** |
||
124 | * Register a vocabulary and its prefix |
||
125 | * |
||
126 | * @param string $prefix Vocabulary prefix |
||
127 | * @param string $uri Vocabulary URI |
||
128 | * @return RdfaLiteContext New context |
||
129 | * |
||
130 | */ |
||
131 | 11 | public function registerVocabulary($prefix, $uri) |
|
145 | |||
146 | /** |
||
147 | * Validata a vocabulary prefix |
||
148 | * |
||
149 | * @param string $prefix Vocabulary prefix |
||
150 | * @return string Valid vocabulary prefix |
||
151 | * @throws RuntimeException If the vocabulary prefix is invalid |
||
152 | */ |
||
153 | 13 | protected static function validateVocabPrefix($prefix) |
|
167 | |||
168 | /** |
||
169 | * Return a particular vocabulary |
||
170 | * |
||
171 | * @param string $prefix Vocabulary Prefix |
||
172 | * @return VocabularyInterface Vocabulary |
||
173 | * @throws OutOfBoundsException If the prefix has not been registered |
||
174 | */ |
||
175 | 8 | public function getVocabulary($prefix) |
|
189 | |||
190 | /** |
||
191 | * Return whether a particular vocabulary prefix has been registered |
||
192 | * |
||
193 | * @param string $prefix Vocabulary prefix |
||
194 | * @return bool Whether the prefix has been registered |
||
195 | */ |
||
196 | 2 | public function hasVocabulary($prefix) |
|
200 | |||
201 | /** |
||
202 | * Set the default vocabulary by URI |
||
203 | * |
||
204 | * @param VocabularyInterface $vocabulary Current default vocabulary |
||
205 | * @return RdfaLiteContext Self reference |
||
206 | */ |
||
207 | 11 | public function setDefaultVocabulary(VocabularyInterface $vocabulary) |
|
218 | } |
||
219 |