Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer_RDFXML.php |
— | — | @@ -180,8 +180,7 @@ |
181 | 181 | if ( $expLiteral->getDatatype() != '' ) { |
182 | 182 | $this->post_ns_buffer .= ' rdf:datatype="' . $expLiteral->getDatatype() . '"'; |
183 | 183 | } |
184 | | - $this->post_ns_buffer .= '>' . |
185 | | - str_replace( array( '&', '>', '<' ), array( '&', '>', '<' ), $expLiteral->getLexicalForm() ) . |
| 184 | + $this->post_ns_buffer .= '>' . $this->makeAttributeValueString( $expLiteral->getLexicalForm() ) . |
186 | 185 | '</' . $expResourceProperty->getQName() . ">\n"; |
187 | 186 | } |
188 | 187 | |
— | — | @@ -197,10 +196,12 @@ |
198 | 197 | protected function serializeExpResource( SMWExpNsResource $expResourceProperty, SMWExpResource $expResource, $indent, $isClassTypeProp ) { |
199 | 198 | $this->post_ns_buffer .= $indent . '<' . $expResourceProperty->getQName(); |
200 | 199 | if ( !$expResource->isBlankNode() ) { |
201 | | - if ( ( $expResource instanceof SMWExpNsResource ) && ( $expResource->getNamespaceID() == 'wiki' ) ) { // very common case, reduce bandwidth |
| 200 | + if ( ( $expResource instanceof SMWExpNsResource ) && ( $expResource->getNamespaceID() == 'wiki' ) ) { |
| 201 | + // very common case, reduce bandwidth |
202 | 202 | $this->post_ns_buffer .= ' rdf:resource="&wiki;' . $expResource->getLocalName() . '"'; |
203 | 203 | } else { |
204 | | - $this->post_ns_buffer .= ' rdf:resource="' . $expResource->getUri() . '"'; |
| 204 | + $uriValue = $this->makeAttributeValueString( $expResource->getUri() ); |
| 205 | + $this->post_ns_buffer .= ' rdf:resource="' . $uriValue . '"'; |
205 | 206 | } |
206 | 207 | } |
207 | 208 | $this->post_ns_buffer .= "/>\n"; |
— | — | @@ -237,10 +238,22 @@ |
238 | 239 | * Escape a string in the special form that is required for values in |
239 | 240 | * DTD entity declarations in XML. Namely, this require the percent sign |
240 | 241 | * to be replaced. |
241 | | - * @param string $string to be escaped |
| 242 | + * |
| 243 | + * @param $string string to be escaped |
| 244 | + * @return string |
242 | 245 | */ |
243 | 246 | protected function makeValueEntityString( $string ) { |
244 | 247 | return "'" . str_replace( '%','%',$string ) . "'"; |
245 | 248 | } |
246 | 249 | |
| 250 | + /** |
| 251 | + * Escape a string as required for using it in XML attribute values. |
| 252 | + * |
| 253 | + * @param $string string to be escaped |
| 254 | + * @return string |
| 255 | + */ |
| 256 | + protected function makeAttributeValueString( $string ) { |
| 257 | + return str_replace( array( '&', '>', '<' ), array( '&', '>', '<' ), $string ); |
| 258 | + } |
| 259 | + |
247 | 260 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php |
— | — | @@ -313,7 +313,7 @@ |
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
317 | | - } |
| 317 | + } // else: not in wiki namespace -- TODO: this could be an imported URI |
318 | 318 | } else { |
319 | 319 | // TODO (currently not needed, but will be useful for displaying external SPARQL results) |
320 | 320 | } |
— | — | @@ -358,7 +358,7 @@ |
359 | 359 | return self::getSpecialNsResource( 'rdf', 'type' ); |
360 | 360 | case '_SUBC': |
361 | 361 | return self::getSpecialNsResource( 'rdfs', 'subClassOf' ); |
362 | | - case '_CONC': // we actually simplify this below, but need a non-null value now |
| 362 | + case '_CONC': |
363 | 363 | return self::getSpecialNsResource( 'owl', 'equivalentClass' ); |
364 | 364 | case '_URI': |
365 | 365 | if ( $forNamespace == NS_CATEGORY || $forNamespace == SMW_NS_CONCEPT ) { |
— | — | @@ -380,9 +380,10 @@ |
381 | 381 | return self::getSpecialNsResource( 'swivt', 'wikiPageModificationDate' ); |
382 | 382 | case '_SKEY': |
383 | 383 | return self::getSpecialNsResource( 'swivt', 'wikiPageSortKey' ); |
384 | | - case '_TYPE': /// TODO: property type currently not exported |
385 | | - return null; |
386 | | - default: return null; |
| 384 | + case '_TYPE': |
| 385 | + return self::getSpecialNsResource( 'swivt', 'type' ); |
| 386 | + default: |
| 387 | + return self::getSpecialNsResource( 'swivt', 'specialProperty' . $propertyKey ); |
387 | 388 | } |
388 | 389 | } |
389 | 390 | |
— | — | @@ -514,8 +515,7 @@ |
515 | 516 | $lit = new SMWExpLiteral( $xsdvalue, 'http://www.w3.org/2001/XMLSchema#boolean', $dataItem ); |
516 | 517 | return $lit; |
517 | 518 | case SMWDataItem::TYPE_URI: |
518 | | - /// TODO This escaping seems very odd. The serialisation should handle such things. |
519 | | - $res = new SMWExpResource( str_replace( '&', '&', $dataItem->getURI() ), $dataItem ); |
| 519 | + $res = new SMWExpResource( $dataItem->getURI(), $dataItem ); |
520 | 520 | return $res; |
521 | 521 | case SMWDataItem::TYPE_TIME: |
522 | 522 | $gregorianTime = $dataItem->getForCalendarModel( SMWDITime::CM_GREGORIAN ); |