1 | <?php |
||
18 | class SMWRDFXMLSerializer extends SMWSerializer{ |
||
|
|||
19 | /** |
||
20 | * True if the $pre_ns_buffer contains the beginning of a namespace |
||
21 | * declaration block to which further declarations for the current |
||
22 | * context can be appended. |
||
23 | */ |
||
24 | protected $namespace_block_started; |
||
25 | /** |
||
26 | * True if the namespaces that are added at the current serialization stage |
||
27 | * become global, i.e. remain available for all later contexts. This is the |
||
28 | * case in RDF/XML only as long as the header has not been streamed to the |
||
29 | * client (reflected herein by calling flushContent()). Later, namespaces |
||
30 | * can only be added locally to individual elements, thus requiring them to |
||
31 | * be re-added multiple times if used in many elements. |
||
32 | */ |
||
33 | protected $namespaces_are_global; |
||
34 | |||
35 | 14 | public function clear() { |
|
40 | |||
41 | 14 | protected function serializeHeader() { |
|
69 | |||
70 | 14 | protected function serializeFooter() { |
|
74 | |||
75 | 14 | public function serializeDeclaration( $uri, $typename ) { |
|
78 | |||
79 | 14 | public function serializeExpData( SMWExpData $expData ) { |
|
88 | |||
89 | 14 | public function flushContent() { |
|
95 | |||
96 | 2 | protected function serializeNamespace( $shortname, $uri ) { |
|
97 | 2 | if ( $this->namespaces_are_global ) { |
|
98 | 2 | $this->global_namespaces[$shortname] = true; |
|
99 | 2 | $this->pre_ns_buffer .= "\n\t"; |
|
100 | } else { |
||
101 | $this->pre_ns_buffer .= ' '; |
||
102 | } |
||
103 | 2 | $this->pre_ns_buffer .= "xmlns:$shortname=\"$uri\""; |
|
104 | 2 | } |
|
105 | |||
106 | /** |
||
107 | * Serialize the given SMWExpData object, possibly recursively with |
||
108 | * increased indentation. |
||
109 | * |
||
110 | * @param $expData SMWExpData containing the data to be serialised. |
||
111 | * @param $indent string specifying a prefix for indentation (usually a sequence of tabs) |
||
112 | */ |
||
113 | 14 | protected function serializeNestedExpData( SMWExpData $expData, $indent ) { |
|
171 | |||
172 | /** |
||
173 | * Add to the output a serialization of a property assignment where an |
||
174 | * SMWExpLiteral is the object. It is assumed that a suitable subject |
||
175 | * block has already been openend. |
||
176 | * |
||
177 | * @param $expResourceProperty SMWExpNsResource the property to use |
||
178 | * @param $expLiteral SMWExpLiteral the data value to use |
||
179 | * @param $indent string specifying a prefix for indentation (usually a sequence of tabs) |
||
180 | */ |
||
181 | 14 | protected function serializeExpLiteral( SMWExpNsResource $expResourceProperty, SMWExpLiteral $expLiteral, $indent ) { |
|
198 | |||
199 | /** |
||
200 | * Add to the output a serialization of a property assignment where an |
||
201 | * SMWExpResource is the object. It is assumed that a suitable subject |
||
202 | * block has already been openend. |
||
203 | * |
||
204 | * @param $expResourceProperty SMWExpNsResource the property to use |
||
205 | * @param $expResource SMWExpResource the data value to use |
||
206 | * @param $indent string specifying a prefix for indentation (usually a sequence of tabs) |
||
207 | * @param $isClassTypeProp boolean whether the resource must be declared as a class |
||
208 | */ |
||
209 | 14 | protected function serializeExpResource( SMWExpNsResource $expResourceProperty, SMWExpResource $expResource, $indent, $isClassTypeProp ) { |
|
210 | 14 | $this->post_ns_buffer .= $indent . '<' . $expResourceProperty->getQName(); |
|
211 | 14 | if ( !$expResource->isBlankNode() ) { |
|
212 | 14 | if ( ( $expResource instanceof SMWExpNsResource ) && ( $expResource->getNamespaceID() == 'wiki' ) ) { |
|
213 | // very common case, reduce bandwidth |
||
214 | 9 | $this->post_ns_buffer .= ' rdf:resource="&wiki;' . $expResource->getLocalName() . '"'; |
|
215 | } else { |
||
216 | 14 | $uriValue = $this->makeAttributeValueString( $expResource->getUri() ); |
|
217 | 14 | $this->post_ns_buffer .= ' rdf:resource="' . $uriValue . '"'; |
|
218 | } |
||
219 | } |
||
220 | 14 | $this->post_ns_buffer .= "/>\n"; |
|
221 | 14 | if ( $isClassTypeProp ) { |
|
222 | 5 | $this->requireDeclaration( $expResource, SMW_SERIALIZER_DECL_CLASS ); |
|
223 | } |
||
224 | 14 | } |
|
225 | |||
226 | /** |
||
227 | * Add a serialization of the given SMWExpResource to the output, |
||
228 | * assuming that an opening property tag is alerady there. |
||
229 | * |
||
230 | * @param $expResourceProperty SMWExpNsResource the property to use |
||
231 | * @param $expResource array of (SMWExpResource or SMWExpData) |
||
232 | * @param $indent string specifying a prefix for indentation (usually a sequence of tabs) |
||
233 | * @param $isClassTypeProp boolean whether the resource must be declared as a class |
||
234 | * |
||
235 | * @bug The $isClassTypeProp parameter is not properly taken into account. |
||
236 | * @bug Individual resources are not serialised properly. |
||
237 | */ |
||
238 | protected function serializeExpCollection( SMWExpNsResource $expResourceProperty, array $collection, $indent, $isClassTypeProp ) { |
||
254 | |||
255 | /** |
||
256 | * Escape a string in the special form that is required for values in |
||
257 | * DTD entity declarations in XML. Namely, this require the percent sign |
||
258 | * to be replaced. |
||
259 | * |
||
260 | * @param $string string to be escaped |
||
261 | * @return string |
||
262 | */ |
||
263 | 14 | protected function makeValueEntityString( $string ) { |
|
266 | |||
267 | /** |
||
268 | * Escape a string as required for using it in XML attribute values. |
||
269 | * |
||
270 | * @param $string string to be escaped |
||
271 | * @return string |
||
272 | */ |
||
273 | 14 | protected function makeAttributeValueString( $string ) { |
|
276 | |||
277 | } |
||
278 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.