r86263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86262‎ | r86263 | r86264 >
Date:15:00, 17 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Restructuring of ExpElement class hierarchy and methods
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Concept.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Data.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_ExportController.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer_RDFXML.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer_Turtle.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Data.php
@@ -12,36 +12,55 @@
1313 * SMWExpData is a data container for export-ready semantic content. It is
1414 * organised as a tree-shaped data structure with one root subject and zero
1515 * or more children connected with labelled edges to the root. Children are
16 - * again SMWExpData objects, and edges are annotated with SMWExpElements
 16+ * again SMWExpData objects, and edges are annotated with SMWExpNsElements
1717 * specifying properties.
 18+ * @note We do not allow property element without namespace abbreviation
 19+ * here. Property aabbreviations are mandatory for some serialisations.
1820 *
1921 * @ingroup SMW
2022 */
21 -class SMWExpData {
 23+class SMWExpData extends SMWExpElement {
 24+ /**
 25+ * The subject of the data that we store.
 26+ * @var SMWExpResource
 27+ */
2228 protected $m_subject;
23 - protected $m_children = array(); // property text keys => array of children SMWExpData objects
24 - protected $m_edges = array(); // property text keys => property SMWExpElements
 29+ /**
 30+ * Array mapping property URIs to arrays their values, given as
 31+ * SMWExpElement objects.
 32+ * @var array of array of SMWElement
 33+ */
 34+ protected $m_children = array();
 35+ /**
 36+ * Array mapping property URIs to arrays their SMWExpResource
 37+ * @var array of SMWExpResource
 38+ */
 39+ protected $m_edges = array();
2540
2641 /**
27 - * Constructor. $subject is the SMWExpElement for the
 42+ * Constructor. $subject is the SMWExpResource for the
2843 * subject about which this SMWExpData is.
2944 */
30 - public function __construct( SMWExpElement $subject ) {
 45+ public function __construct( SMWExpResource $subject ) {
 46+ parent::__construct( $subject->getDataItem() );
3147 $this->m_subject = $subject;
3248 }
3349
3450 /**
35 - * Turn an array of SMWElements into an RDF collection.
 51+ * Turn an array of SMWExpElements into an RDF collection.
 52+ *
 53+ * @param $elements array of SMWExpElement
 54+ * @return SMWExpData
3655 */
37 - public static function makeCollection( $elements ) {
 56+ public static function makeCollection( array $elements ) {
3857 if ( count( $elements ) == 0 ) {
39 - return new SMWExpData( SMWExporter::getSpecialElement( 'rdf', 'nil' ) );
 58+ return new SMWExpData( SMWExporter::getSpecialNsResource( 'rdf', 'nil' ) );
4059 } else {
41 - $rdftype = SMWExporter::getSpecialElement( 'rdf', 'type' );
42 - $rdffirst = SMWExporter::getSpecialElement( 'rdf', 'first' );
43 - $rdfrest = SMWExporter::getSpecialElement( 'rdf', 'rest' );
 60+ $rdftype = SMWExporter::getSpecialNsResource( 'rdf', 'type' );
 61+ $rdffirst = SMWExporter::getSpecialNsResource( 'rdf', 'first' );
 62+ $rdfrest = SMWExporter::getSpecialNsResource( 'rdf', 'rest' );
4463 $result = new SMWExpData( new SMWExpResource( '' ) ); // bnode
45 - $result->addPropertyObjectValue( $rdftype, new SMWExpData( SMWExporter::getSpecialElement( 'rdf', 'List' ) ) );
 64+ $result->addPropertyObjectValue( $rdftype, new SMWExpData( SMWExporter::getSpecialNsResource( 'rdf', 'List' ) ) );
4665 $result->addPropertyObjectValue( $rdffirst, array_shift( $elements ) );
4766 $result->addPropertyObjectValue( $rdfrest, SMWExpData::makeCollection( $elements ) );
4867 return $result;
@@ -51,53 +70,47 @@
5271 /**
5372 * Return subject to which the stored semantic annotation refer to.
5473 *
55 - * @return SMWExpElement
 74+ * @return SMWExpResource
5675 */
5776 public function getSubject() {
5877 return $this->m_subject;
5978 }
6079
6180 /**
62 - * Set the subject element.
63 - *
64 - * @param SMWExpResource $subject
65 - */
66 - public function setSubject( SMWExpResource $subject ) {
67 - $this->m_subject = $subject;
68 - }
69 -
70 - /**
71 - * Store a value for a property identified by its title object. No duplicate elimination as this
72 - * is usually done in SMWSemanticData already (which is typically used to generate this object).
73 - *
74 - * @param SMWExpResource $property
 81+ * Store a value for a property identified by its title object. No
 82+ * duplicate elimination as this is usually done in SMWSemanticData
 83+ * already (which is typically used to generate this object).
 84+ *
 85+ * @param SMWExpNsResource $property
7586 * @param SMWExpData $child
7687 */
77 - public function addPropertyObjectValue( SMWExpResource $property, SMWExpData $child ) {
78 - if ( !array_key_exists( $property->getName(), $this->m_edges ) ) {
79 - $this->m_children[$property->getName()] = array();
80 - $this->m_edges[$property->getName()] = $property;
 88+ public function addPropertyObjectValue( SMWExpNsResource $property, SMWExpElement $child ) {
 89+ if ( !array_key_exists( $property->getUri(), $this->m_edges ) ) {
 90+ $this->m_children[$property->getUri()] = array();
 91+ $this->m_edges[$property->getUri()] = $property;
8192 }
82 - $this->m_children[$property->getName()][] = $child;
 93+ $this->m_children[$property->getUri()][] = $child;
8394 }
8495
8596 /**
86 - * Return the list of SMWExpElements for all properties for which some values exist.
 97+ * Return the list of SMWExpResource objects for all properties for
 98+ * which some values have been given.
8799 *
88 - * @return array of SMWExpElements
 100+ * @return array of SMWExpResource
89101 */
90102 public function getProperties() {
91103 return $this->m_edges;
92104 }
93105
94106 /**
95 - * Return the list of SMWExpData values associated to some property (element).
 107+ * Return the list of SMWExpElement values associated to some property
 108+ * (element).
96109 *
97 - * @return array of SMWExpData
 110+ * @return array of SMWExpElement
98111 */
99112 public function getValues( SMWExpResource $property ) {
100 - if ( array_key_exists( $property->getName(), $this->m_children ) ) {
101 - return $this->m_children[$property->getName()];
 113+ if ( array_key_exists( $property->getUri(), $this->m_children ) ) {
 114+ return $this->m_children[$property->getUri()];
102115 } else {
103116 return array();
104117 }
@@ -106,76 +119,91 @@
107120 /**
108121 * Return the list of SMWExpData values associated to some property that is
109122 * specifed by a standard namespace id and local name.
110 - *
 123+ *
 124+ * @param $namespaceId string idetifying a known special namespace (e.g. "rdf")
 125+ * @param $localName string of local name (e.g. "type")
111126 * @return array of SMWExpData
112127 */
113 - public function getSpecialValues( $namespace, $localname ) {
114 - $pe = SMWExporter::getSpecialElement( $namespace, $localname );
115 - if ( $pe !== null ) {
116 - return $this->getValues( $pe );
117 - } else {
118 - return array();
119 - }
 128+ public function getSpecialValues( $namespaceId, $localName ) {
 129+ $pe = SMWExporter::getSpecialNsResource( $namespaceId, $localName );
 130+ return $this->getValues( $pe );
120131 }
121132
122133 /**
123 - * This function finds the main type (class) element of the subject based on the
124 - * current property assignments. It returns this type element (SMWExpElement) and
125 - * removes the according type assignement from the data.
 134+ * This function finds the main type (class) element of the subject
 135+ * based on the current property assignments. It returns this type
 136+ * element (SMWExpElement) and removes the according type assignement
 137+ * from the data. If no type is assigned, the element for rdf:Resource
 138+ * is returned.
 139+ *
 140+ * @note Under all normal conditions, the result will be an
 141+ * SMWExpResource.
 142+ *
 143+ * @return SMWExpElement
126144 */
127145 public function extractMainType() {
128 - $pe = SMWExporter::getSpecialElement( 'rdf', 'type' );
129 - if ( array_key_exists( $pe->getName(), $this->m_children ) ) {
130 - $result = array_shift( $this->m_children[$pe->getName()] );
131 - if ( count( $this->m_children[$pe->getName()] ) == 0 ) {
132 - unset( $this->m_edges[$pe->getName()] );
133 - unset( $this->m_children[$pe->getName()] );
 146+ $pe = SMWExporter::getSpecialNsResource( 'rdf', 'type' );
 147+ if ( array_key_exists( $pe->getUri(), $this->m_children ) ) {
 148+ $result = array_shift( $this->m_children[$pe->getUri()] );
 149+ if ( count( $this->m_children[$pe->getUri()] ) == 0 ) {
 150+ unset( $this->m_edges[$pe->getUri()] );
 151+ unset( $this->m_children[$pe->getUri()] );
134152 }
135 - return $result->getSubject();
 153+ return ( $result instanceof SMWExpData ) ? $result->getSubject() : $result;
136154 } else {
137 - return SMWExporter::getSpecialElement( 'rdf', 'Resource' );
 155+ return SMWExporter::getSpecialNsResource( 'rdf', 'Resource' );
138156 }
139157 }
140158
141159 /**
142 - * Check if this element can be serialised using parseType="Collection" and
143 - * if yes return an array of SMWExpElements corresponding to the collection
144 - * elements in the specified order. Otherwise return false.
 160+ * Check if this element encodes an RDF list, and if yes return an
 161+ * array of SMWExpElements corresponding to the collection elements in
 162+ * the specified order. Otherwise return false.
 163+ * The method only returns lists that can be encoded using
 164+ * parseType="Collection" in RDF/XML, i.e. only lists of non-literal
 165+ * resources.
 166+ *
 167+ * @return mixed array of SMWExpElement (but not SMWExpLiteral) or false
145168 */
146169 public function getCollection() {
147 - $rdftype = SMWExporter::getSpecialElement( 'rdf', 'type' );
148 - $rdffirst = SMWExporter::getSpecialElement( 'rdf', 'first' );
149 - $rdfrest = SMWExporter::getSpecialElement( 'rdf', 'rest' );
150 - $rdfnil = SMWExporter::getSpecialElement( 'rdf', 'nil' );
151 - $name = $this->getSubject()->getName();
 170+ $rdftypeUri = SMWExporter::getSpecialNsResource( 'rdf', 'type' )->getUri();
 171+ $rdffirstUri = SMWExporter::getSpecialNsResource( 'rdf', 'first' )->getUri();
 172+ $rdfrestUri = SMWExporter::getSpecialNsResource( 'rdf', 'rest' )->getUri();
 173+ $rdfnilUri = SMWExporter::getSpecialNsResource( 'rdf', 'nil' )->getUri();
152174 // first check if we are basically an RDF List:
153 - if ( ( ( $name == '' ) || ( $name { 0 } == '_' ) ) && // bnode
154 - ( array_key_exists( $rdftype->getName(), $this->m_children ) ) &&
155 - ( count( $this->m_children[$rdftype->getName()] ) == 1 ) &&
156 - ( array_key_exists( $rdffirst->getName(), $this->m_children ) ) &&
157 - ( count( $this->m_children[$rdffirst->getName()] ) == 1 ) &&
158 - ( array_key_exists( $rdfrest->getName(), $this->m_children ) ) &&
159 - !( end( $this->m_children[$rdffirst->getName()] ) instanceof SMWExpLiteral ) &&
 175+ if ( ( $this->m_subject->isBlankNode() ) &&
 176+ ( count( $this->m_children ) == 3 ) &&
 177+ ( array_key_exists( $rdftypeUri, $this->m_children ) ) &&
 178+ ( count( $this->m_children[$rdftypeUri] ) == 1 ) &&
 179+ ( array_key_exists( $rdffirstUri, $this->m_children ) ) &&
 180+ ( count( $this->m_children[$rdffirstUri] ) == 1 ) &&
 181+ !( end( $this->m_children[$rdffirstUri] ) instanceof SMWExpLiteral ) &&
160182 // (parseType collection in RDF not possible with literals :-/)
161 - ( count( $this->m_children[$rdfrest->getName()] ) == 1 ) &&
162 - ( count( $this->m_children ) == 3 ) ) {
163 - $typedata = end( $this->m_children[$rdftype->getName()] );
164 - $rdflist = SMWExporter::getSpecialElement( 'rdf', 'List' );
165 - if ( $typedata->getSubject()->getName() == $rdflist->getName() ) {
166 - $first = end( $this->m_children[$rdffirst->getName()] );
167 - $rest = end( $this->m_children[$rdfrest->getName()] );
168 - $restlist = $rest->getCollection();
169 - if ( $restlist === false ) {
 183+ ( array_key_exists( $rdfrestUri, $this->m_children ) ) &&
 184+ ( count( $this->m_children[$rdfrestUri] ) == 1 ) ) {
 185+ $typedata = end( $this->m_children[$rdftypeUri] );
 186+ $rdflistUri = SMWExporter::getSpecialNsResource( 'rdf', 'List' )->getUri();
 187+ if ( $typedata->getSubject()->getUri() == $rdflistUri ) {
 188+ $first = end( $this->m_children[$rdffirstUri] );
 189+ $rest = end( $this->m_children[$rdfrestUri] );
 190+ if ( $rest instanceof SMWExpData ) {
 191+ $restlist = $rest->getCollection();
 192+ if ( $restlist === false ) {
 193+ return false;
 194+ } else {
 195+ array_unshift( $restlist, $first );
 196+ return $restlist;
 197+ }
 198+ } elseif ( ( $rest instanceof SMWExpResource ) &&
 199+ ( $rest->getUri() == $rdfnilUri ) ) {
 200+ return array( $first );
 201+ } else {
170202 return false;
171 - } else {
172 - array_unshift( $restlist, $first );
173 - return $restlist;
174203 }
175204 } else {
176205 return false;
177206 }
178 - } elseif ( ( !array_key_exists( $rdftype->getName(), $this->m_children ) ) &&
179 - ( $name == $rdfnil->getName() ) ) {
 207+ } elseif ( ( count( $this->m_children ) == 0 ) && ( $this->m_subject->getUri() == $rdfnilUri ) ) {
180208 return array();
181209 } else {
182210 return false;
@@ -183,34 +211,44 @@
184212 }
185213
186214 /**
187 - * Return an array of ternary arrays (subject predicate object) of SMWExpElements
188 - * that represents the flattened version of the given data.
 215+ * Return an array of ternary arrays (subject predicate object) of
 216+ * SMWExpElements that represents the flattened version of this data.
 217+ *
 218+ * @return array of array of SMWExpElement
189219 */
190 - public function getTripleList() {
 220+ public function getTripleList( SMWExpElement $subject = null ) {
191221 global $smwgBnodeCount;
192 -
193222 if ( !isset( $smwgBnodeCount ) ) {
194223 $smwgBnodeCount = 0;
195224 }
196 -
 225+
 226+ if ( $subject == null ) {
 227+ $subject = $this->m_subject;
 228+ }
 229+
197230 $result = array();
198 -
 231+
199232 foreach ( $this->m_edges as $key => $edge ) {
200 - foreach ( $this->m_children[$key] as $child ) {
201 - $name = $child->getSubject()->getName();
202 -
203 - if ( $name === '' || $name[0] === '_' ) { // bnode, rename ID to avoid unifying bnodes of different contexts
 233+ foreach ( $this->m_children[$key] as $childElement ) {
 234+ if ( $childElement instanceof SMWExpData ) {
 235+ $childSubject = $childElement->getSubject();
 236+ } else {
 237+ $childSubject = $childElement;
 238+ }
 239+
 240+ if ( ( $childSubject instanceof SMWExpResource ) &&
 241+ ( $childSubject->isBlankNode() ) ) { // bnode, rename ID to avoid unifying bnodes of different contexts
204242 // TODO: should we really rename bnodes of the form "_id" here?
205 - $child = clone $child;
206 - $subject = new SMWExpResource( '_' . $smwgBnodeCount++, $child->getSubject()->getDataValue() );
207 - $child->setSubject( $subject );
 243+ $childSubject = new SMWExpResource( '_' . $smwgBnodeCount++, $childSubject()->getDataItem() );
208244 }
209 -
210 - $result[] = array( $this->m_subject, $edge, $child->getSubject() );
211 - $result = array_merge( $result, $child->getTripleList() ); // recursively generate all children's triples
 245+
 246+ $result[] = array( $subject, $edge, $childSubject );
 247+ if ( $childElement instanceof SMWExpData ) { // recursively add child's triples
 248+ $result = array_merge( $result, $child->getTripleList( $childSubject ) );
 249+ }
212250 }
213251 }
214 -
 252+
215253 return $result;
216254 }
217255
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php
@@ -16,140 +16,215 @@
1717 *
1818 * @ingroup SMW
1919 */
20 -class SMWExpElement {
21 - protected $m_dv;
22 - protected $m_name;
 20+abstract class SMWExpElement {
2321
2422 /**
25 - * Constructor. $dv is the SMWDataValue from which this object was created,
26 - * if any.
 23+ * The SMWDataItem that this export element is associated with, if
 24+ * any. Might be unset if not given yet.
 25+ * @var SMWDataItem
2726 */
28 - public function __construct( $name, $dv = null ) {
29 - $this->m_name = $name;
30 - $this->m_dv = $dv;
31 - }
 27+ protected $m_dataItem;
3228
3329 /**
34 - * Return a string for denoting contents of the element, e.g. the URI or the literal
35 - * values.
 30+ * Constructor.
 31+ *
 32+ * @param $dataItem SMWDataItem or null
3633 */
37 - public function getName() {
38 - return $this->m_name;
 34+ public function __construct( $dataItem = null ) {
 35+ if ( $dataItem !== null ) {
 36+ $this->m_dataItem = $dataItem;
 37+ }
3938 }
4039
4140 /**
42 - * If available, return the SMWDataValue object from which this SMWExpElement was built.
43 - * NULL if unset.
 41+ * Get a SMWDataItem object that represents the contents of this export
 42+ * element in SMW, or null if no such data item could be found.
 43+ *
 44+ * @return SMWDataItem or null
4445 */
45 - public function getDataValue() {
46 - return $this->m_dv;
 46+ public function getDataItem() {
 47+ return isset( $this->m_dataItem ) ? $this->m_dataItem : null;
4748 }
4849 }
4950
5051 /**
51 - * A single resource (individual) for export. Defined by a URI, and possibly
52 - * also providing abbreviated forms (QNames).
 52+ * A single resource (individual) for export, as defined by a URI.
5353 * This class can also be used to represent blank nodes: It is assumed that all
54 - * objects of class SMWExpElement or any of its subclasses do represent blank
 54+ * objects of class SMWExpElement or any of its subclasses represent a blank
5555 * node if their name is empty or of the form "_id" where "id" is any
5656 * identifier string. IDs are local to the current context, such as a list of
5757 * triples or an SMWExpData container.
58 - *
59 - * @todo This class should be split into two: one general resource class, and
60 - * one that only supports resources with namespace/qname form, because the
61 - * latter is strictly necessary in some places where resources are used.
 58+ *
6259 * @ingroup SMW
6360 */
6461 class SMWExpResource extends SMWExpElement {
6562
66 - protected $m_namespace = false;
67 - protected $m_namespaceid = false;
68 - protected $m_localname = false;
69 -
7063 /**
71 - * Constructor. $dv is the SMWDataValue from which this object was created,
72 - * if any. If $namespace and $namespaceid are given, then $name is assumed to
73 - * be the local name and they are used to build a QName. Otherwise $name is
74 - * assumed to be the full URI.
 64+ * Constructor. The given URI must not contain serialization-specific
 65+ * abbreviations or escapings, such as XML entities.
 66+ *
 67+ * @param $uri string of the full URI
 68+ * @param $dataItem SMWDataItem or null
7569 */
76 - public function __construct( $name, $dv = null, $namespace = false, $namespaceid = false ) {
77 - if ( $namespace !== false ) {
78 - $this->m_namespace = $namespace;
79 - $this->m_namespaceid = $namespaceid;
80 - $this->m_localname = $name;
81 - parent::__construct( $namespace . $name, $dv );
82 - } else {
83 - parent::__construct( $name, $dv );
84 - }
 70+ public function __construct( $uri, $dataItem = null ) {
 71+ parent::__construct( $dataItem );
 72+ $this->m_uri = $uri;
8573 }
8674
8775 /**
88 - * Return true of this resource represents a blank node.
 76+ * Return true if this resource represents a blank node.
 77+ *
 78+ * @return boolean
8979 */
9080 public function isBlankNode() {
91 - return ( $this->m_name == '' ) || ( $this->m_name{0} == '_' );
 81+ return ( $this->m_uri == '' ) || ( $this->m_uri{0} == '_' );
9282 }
9383
9484 /**
95 - * Return a qualitifed name for the element, or false if no such name could be found.
 85+ * Get the URI of this resource. The result is a UTF-8 encoded URI (or
 86+ * IRI) without any escaping.
 87+ *
 88+ * @return string
9689 */
 90+ public function getUri() {
 91+ return $this->m_uri;
 92+ }
 93+
 94+}
 95+
 96+
 97+/**
 98+ * A single resource (individual) for export, defined by a URI for which there
 99+ * also is a namespace abbreviation.
 100+ *
 101+ * @ingroup SMW
 102+ */
 103+class SMWExpNsResource extends SMWExpResource {
 104+
 105+ /**
 106+ * Namespace URI prefix of the abbreviated URI
 107+ * @var string
 108+ */
 109+ protected $m_namespace;
 110+ /**
 111+ * Namespace abbreviation of the abbreviated URI
 112+ * @var string
 113+ */
 114+ protected $m_namespaceid;
 115+ /**
 116+ * Local part of the abbreviated URI
 117+ * @var string
 118+ */
 119+ protected $m_localname;
 120+
 121+ /**
 122+ * Constructor. The given URI must not contain serialization-specific
 123+ * abbreviations or escapings, such as XML entities.
 124+ *
 125+ * @param $localname string local part of the abbreviated URI
 126+ * @param $namespace string namespace URI prefix of the abbreviated URI
 127+ * @param $namespaceid string namespace abbreviation of the abbreviated URI
 128+ * @param $dataItem SMWDataItem or null
 129+ */
 130+ public function __construct( $localname, $namespace, $namespaceid, $dataItem = null ) {
 131+ parent::__construct( $namespace . $localname, $dataItem );
 132+ $this->m_namespace = $namespace;
 133+ $this->m_namespaceid = $namespaceid;
 134+ $this->m_localname = $localname;
 135+ }
 136+
 137+ /**
 138+ * Return a qualitifed name for the element.
 139+ *
 140+ * @return string
 141+ */
97142 public function getQName() {
98 - if ( $this->m_namespace != false ) {
99 - return $this->m_namespaceid . ':' . $this->m_localname;
100 - } else {
101 - return false;
102 - }
 143+ return $this->m_namespaceid . ':' . $this->m_localname;
103144 }
104145
105146 /**
106 - * If a QName was given, this method returns the namespace identifier used (the part before :).
 147+ * Get the namespace identifier used (the part before :).
 148+ *
 149+ * @return string
107150 */
108 - public function getNamespaceID() {
 151+ public function getNamespaceId() {
109152 return $this->m_namespaceid;
110153 }
111154
112155 /**
113 - * If a QName was given, this method returns the complete namespace URI that the
114 - * namespace identifier abbreviates.
 156+ * Get the namespace URI that is used in the abbreviation.
 157+ *
 158+ * @return string
115159 */
116160 public function getNamespace() {
117161 return $this->m_namespace;
118162 }
119163
120164 /**
121 - * If a QName was given, this method returns its local name (the part after :).
 165+ * Get the local name (the part after :).
 166+ *
 167+ * @return string
122168 */
123169 public function getLocalName() {
124170 return $this->m_localname;
125171 }
 172+
126173 }
127174
128175 /**
129 - * A single datatype literal for export. Defined by a literal value and a datatype URI.
130 - * Currently no support for language tags.
 176+ * A single datatype literal for export. Defined by a literal value and a
 177+ * datatype URI.
 178+ *
 179+ * @todo Currently no support for language tags.
 180+ *
131181 * @ingroup SMW
132182 */
133183 class SMWExpLiteral extends SMWExpElement {
134184
135 - protected $m_datatype = false;
 185+ /**
 186+ * Datatype URI for the literal.
 187+ * @var string
 188+ */
 189+ protected $m_datatype;
 190+ /**
 191+ * Lexical form of the literal.
 192+ * @var string
 193+ */
 194+ protected $m_lexicalForm;
136195
137196 /**
138 - * Constructor. $dv is the SMWDataValue from which this object was created,
139 - * if any. $name here should be the plain string for representing the literal
140 - * without datatype or language information. The string $name is a plain UTF8-string
141 - * witout any escape sequences whatsoever. Note that it may be required to escape
142 - * some symbols in some contexts, especially <, >, & in XML and HTML.
 197+ * Constructor. The given lexical form should be the plain string for
 198+ * representing the literal without datatype or language information.
 199+ * It must not use any escaping or abbrevition mechanisms.
 200+ *
 201+ * @param $lexicalForm string lexical form
 202+ * @param $datatype string datatype URI or empty for untyped literals
 203+ * @param $dataItem SMWDataItem or null
143204 */
144 - public function __construct( $name, $dv = null, $datatype = false ) {
 205+ public function __construct( $lexicalForm, $datatype = '', $dataItem = null ) {
 206+ parent::__construct( $dataItem );
 207+ $this->m_lexicalForm = $lexicalForm;
145208 $this->m_datatype = $datatype;
146 - parent::__construct( $name, $dv );
147209 }
148210
149211 /**
150 - * Return the URI of the datatype used, or false if untyped.
 212+ * Return the URI of the datatype used, or the empty string if untyped.
 213+ *
 214+ * @return string
151215 */
152216 public function getDatatype() {
153217 return $this->m_datatype;
154218 }
155219
 220+ /**
 221+ * Return the lexical form of the literal. The result does not use
 222+ * any escapings and might still need to be escaped in some contexts.
 223+ * The lexical form is not validated or canonicalized.
 224+ *
 225+ * @return string
 226+ */
 227+ public function getLexicalForm() {
 228+ return $this->m_lexicalForm;
 229+ }
 230+
156231 }
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_ExportController.php
@@ -158,21 +158,22 @@
159159 }
160160
161161 if ( $recursiondepth != 0 ) {
162 - $subrecdepth = ($recursiondepth>0) ? ($recursiondepth-1) : ($recursiondepth==0 ? 0 : -1);
 162+ $subrecdepth = $recursiondepth > 0 ? ( $recursiondepth - 1 ) :
 163+ ( $recursiondepth == 0 ? 0 : -1 );
163164
164165 foreach ( $data->getProperties() as $property ) {
165 - if ( $property->getDataValue() instanceof SMWWikiPageValue ) {
166 - $this->queuePage( $property->getDataValue(), 0 ); // no real recursion along properties
 166+ if ( $property->getDataItem() instanceof SMWWikiPageValue ) {
 167+ $this->queuePage( $property->getDataItem(), 0 ); // no real recursion along properties
167168 }
168169 $wikipagevalues = false;
169 - foreach ( $data->getValues( $property ) as $expdata ) {
170 - $subject = $expdata->getSubject();
171 - if ( !$wikipagevalues && ( $subject->getDataValue() instanceof SMWWikiPageValue ) ) {
 170+ foreach ( $data->getValues( $property ) as $valueExpElement ) {
 171+ $valueResource = $valueExpElement instanceof SMWExpData ? $valueExpElement->getSubject() : $valueExpElement;
 172+ if ( !$wikipagevalues && ( $valueResource->getDataItem() instanceof SMWWikiPageValue ) ) {
172173 $wikipagevalues = true;
173174 } elseif ( !$wikipagevalues ) {
174175 break;
175176 }
176 - $this->queuePage( $subject->getDatavalue(), $subrecdepth );
 177+ $this->queuePage( $valueResource->getDataItem(), $subrecdepth );
177178 }
178179 }
179180
@@ -527,10 +528,10 @@
528529 }
529530
530531 $data = new SMWExpData( new SMWExpResource( $nexturl ) );
531 - $ed = new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Thing' ) );
532 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ), $ed );
 532+ $ed = new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Thing' ) );
 533+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $ed );
533534 $ed = new SMWExpData( new SMWExpResource( $nexturl ) );
534 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdfs', 'isDefinedBy' ), $ed );
 535+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'isDefinedBy' ), $ed );
535536 $this->serializer->serializeExpData( $data );
536537 }
537538
@@ -556,39 +557,39 @@
557558
558559 // assemble export data:
559560 $data = new SMWExpData( new SMWExpResource( '&wiki;#wiki' ) );
560 - $ed = new SMWExpData( SMWExporter::getSpecialElement( 'swivt', 'Wikisite' ) );
561 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ), $ed );
 561+ $ed = new SMWExpData( SMWExporter::getSpecialNsResource( 'swivt', 'Wikisite' ) );
 562+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $ed );
562563 // basic wiki information
563564 $ed = new SMWExpData( new SMWExpLiteral( $wgSitename ) );
564 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdfs', 'label' ), $ed );
 565+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'label' ), $ed );
565566 $ed = new SMWExpData( new SMWExpLiteral( $wgSitename, null, 'http://www.w3.org/2001/XMLSchema#string' ) );
566 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'siteName' ), $ed );
 567+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'siteName' ), $ed );
567568 $ed = new SMWExpData( new SMWExpLiteral( SMWExporter::expandURI( '&wikiurl;' ), null, 'http://www.w3.org/2001/XMLSchema#string' ) );
568 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'pagePrefix' ), $ed );
 569+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'pagePrefix' ), $ed );
569570 $ed = new SMWExpData( new SMWExpLiteral( SMW_VERSION, null, 'http://www.w3.org/2001/XMLSchema#string' ) );
570 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'smwVersion' ), $ed );
 571+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'smwVersion' ), $ed );
571572 $ed = new SMWExpData( new SMWExpLiteral( $wgLanguageCode, null, 'http://www.w3.org/2001/XMLSchema#string' ) );
572 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'langCode' ), $ed );
 573+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'langCode' ), $ed );
573574 $mainpage = Title::newMainPage();
574575 if ( $mainpage !== null ) {
575576 $ed = new SMWExpData( new SMWExpResource( $mainpage->getFullURL() ) );
576 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'mainPage' ), $ed );
 577+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'mainPage' ), $ed );
577578 }
578579 // statistical information
579580 $ed = new SMWExpData( new SMWExpLiteral( SiteStats::pages(), null, 'http://www.w3.org/2001/XMLSchema#int' ) );
580 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'pageCount' ), $ed );
 581+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'pageCount' ), $ed );
581582 $ed = new SMWExpData( new SMWExpLiteral( SiteStats::articles(), null, 'http://www.w3.org/2001/XMLSchema#int' ) );
582 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'contentPageCount' ), $ed );
 583+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'contentPageCount' ), $ed );
583584 $ed = new SMWExpData( new SMWExpLiteral( SiteStats::images(), null, 'http://www.w3.org/2001/XMLSchema#int' ) );
584 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'mediaCount' ), $ed );
 585+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'mediaCount' ), $ed );
585586 $ed = new SMWExpData( new SMWExpLiteral( SiteStats::edits(), null, 'http://www.w3.org/2001/XMLSchema#int' ) );
586 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'editCount' ), $ed );
 587+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'editCount' ), $ed );
587588 $ed = new SMWExpData( new SMWExpLiteral( SiteStats::views(), null, 'http://www.w3.org/2001/XMLSchema#int' ) );
588 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'viewCount' ), $ed );
 589+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'viewCount' ), $ed );
589590 $ed = new SMWExpData( new SMWExpLiteral( SiteStats::users(), null, 'http://www.w3.org/2001/XMLSchema#int' ) );
590 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'userCount' ), $ed );
 591+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'userCount' ), $ed );
591592 $ed = new SMWExpData( new SMWExpLiteral( SiteStats::numberingroup( 'sysop' ), null, 'http://www.w3.org/2001/XMLSchema#int' ) );
592 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'adminCount' ), $ed );
 593+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'adminCount' ), $ed );
593594
594595 $this->serializer->startSerialization();
595596 $this->serializer->serializeExpData( SMWExporter::getOntologyExpData( '' ) );
@@ -601,10 +602,10 @@
602603 $nexturl = SMWExporter::expandURI( '&export;&amp;offset=0' );
603604 }
604605 $data = new SMWExpData( new SMWExpResource( $nexturl ) );
605 - $ed = new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Thing' ) );
606 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ), $ed );
 606+ $ed = new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Thing' ) );
 607+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $ed );
607608 $ed = new SMWExpData( new SMWExpResource( $nexturl ) );
608 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdfs', 'isDefinedBy' ), $ed );
 609+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'isDefinedBy' ), $ed );
609610 $this->serializer->serializeExpData( $data );
610611
611612 $this->serializer->finishSerialization();
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer_RDFXML.php
@@ -75,8 +75,8 @@
7676 $this->post_ns_buffer .= "\t<$typename rdf:about=\"$uri\" />\n";
7777 }
7878
79 - public function serializeExpData( SMWExpData $data ) {
80 - $this->serializeNestedExpData( $data, '' );
 79+ public function serializeExpData( SMWExpData $expData ) {
 80+ $this->serializeNestedExpData( $expData, '' );
8181 $this->serializeNamespaces();
8282 if ( !$this->namespaces_are_global ) {
8383 $this->pre_ns_buffer .= $this->post_ns_buffer;
@@ -106,13 +106,13 @@
107107 * Serialize the given SMWExpData object, possibly recursively with
108108 * increased indentation.
109109 *
110 - * @param $data SMWExpData containing the data to be serialised.
 110+ * @param $expData SMWExpData containing the data to be serialised.
111111 * @param $indent string specifying a prefix for indentation (usually a sequence of tabs)
112112 */
113 - protected function serializeNestedExpData( SMWExpData $data, $indent ) {
114 - $this->recordDeclarationTypes( $data );
 113+ protected function serializeNestedExpData( SMWExpData $expData, $indent ) {
 114+ $this->recordDeclarationTypes( $expData );
115115
116 - $type = $data->extractMainType()->getQName();
 116+ $type = $expData->extractMainType()->getQName();
117117 if ( !$this->namespace_block_started ) { // start new ns block
118118 $this->pre_ns_buffer .= "\t$indent<$type";
119119 $this->namespace_block_started = true;
@@ -120,61 +120,42 @@
121121 $this->post_ns_buffer .= "\t$indent<$type";
122122 }
123123
124 - if ( ( $data->getSubject() instanceof SMWExpLiteral ) ||
125 - ( $data->getSubject() instanceof SMWExpResource ) ) {
126 - $this->post_ns_buffer .= ' rdf:about="' . $data->getSubject()->getName() . '"';
 124+ if ( $expData->getSubject() instanceof SMWExpResource ) {
 125+ $this->post_ns_buffer .= ' rdf:about="' . $expData->getSubject()->getUri() . '"';
127126 } // else: blank node, no "rdf:about"
128127
129 - if ( count( $data->getProperties() ) == 0 ) { // nothing else to export
 128+ if ( count( $expData->getProperties() ) == 0 ) { // nothing else to export
130129 $this->post_ns_buffer .= " />\n";
131130 } else { // process data
132131 $this->post_ns_buffer .= ">\n";
133132
134 - foreach ( $data->getProperties() as $property ) {
 133+ foreach ( $expData->getProperties() as $property ) {
135134 $prop_decl_queued = false;
136 - $class_type_prop = $this->isOWLClassTypeProperty( $property );
 135+ $isClassTypeProp = $this->isOWLClassTypeProperty( $property );
137136
138 - foreach ( $data->getValues( $property ) as $value ) {
139 - $this->post_ns_buffer .= "\t\t$indent<" . $property->getQName();
 137+ foreach ( $expData->getValues( $property ) as $valueElement ) {
140138 $this->requireNamespace( $property->getNamespaceID(), $property->getNamespace() );
141 - $object = $value->getSubject();
142139
143 - if ( $object instanceof SMWExpLiteral ) {
 140+ if ( $valueElement instanceof SMWExpLiteral ) {
144141 $prop_decl_type = SMW_SERIALIZER_DECL_APROP;
145 - if ( $object->getDatatype() != '' ) {
146 - $this->post_ns_buffer .= ' rdf:datatype="' . $object->getDatatype() . '"';
147 - }
148 - $this->post_ns_buffer .= '>' .
149 - str_replace( array( '&', '>', '<' ), array( '&amp;', '&gt;', '&lt;' ), $object->getName() ) .
150 - '</' . $property->getQName() . ">\n";
151 - } else { // resource (maybe blank node), could have subdescriptions
 142+ $this->serializeExpLiteral( $property, $valueElement, "\t\t$indent" );
 143+ } elseif ( $valueElement instanceof SMWExpResource ) {
152144 $prop_decl_type = SMW_SERIALIZER_DECL_OPROP;
153 - $collection = $value->getCollection();
 145+ $this->serializeExpResource( $property, $valueElement, "\t\t$indent", $isClassTypeProp );
 146+ } elseif ( $valueElement instanceof SMWExpData ) {
 147+ $prop_decl_type = SMW_SERIALIZER_DECL_OPROP;
 148+
 149+ $collection = $valueElement->getCollection();
154150 if ( $collection !== false ) { // RDF-style collection (list)
155 - $this->post_ns_buffer .= " rdf:parseType=\"Collection\">\n";
156 - foreach ( $collection as $subvalue ) {
157 - $this->serializeNestedExpData( $subvalue, $indent . "\t\t" );
158 - if ( $class_type_prop ) {
159 - $this->requireDeclaration( $subvalue, SMW_SERIALIZER_DECL_CLASS );
160 - }
161 - }
 151+ $this->serializeExpCollection( $property, $collection, "\t\t$indent", $isClassTypeProp );
 152+ } elseif ( count( $valueElement->getProperties() ) > 0 ) { // resource with data
 153+ $this->post_ns_buffer .= "\t\t$indent<" . $expResourceProperty->getQName() . ">\n";
 154+ $this->serializeNestedExpData( $valueElement, "\t\t$indent" );
162155 $this->post_ns_buffer .= "\t\t$indent</" . $property->getQName() . ">\n";
163 - } else {
164 - if ( $class_type_prop ) {
165 - $this->requireDeclaration( $object, SMW_SERIALIZER_DECL_CLASS );
166 - }
167 - if ( count( $value->getProperties() ) > 0 ) { // resource with data: serialise
168 - $this->post_ns_buffer .= ">\n";
169 - $this->serializeNestedExpData( $value, $indent . "\t\t" );
170 - $this->post_ns_buffer .= "\t\t$indent</" . $property->getQName() . ">\n";
171 - } else { // resource without data
172 - if ( !$object->isBlankNode() ) {
173 - $this->post_ns_buffer .= ' rdf:resource="' . $object->getName() . '"';
174 - }
175 - $this->post_ns_buffer .= "/>\n";
176 - }
 156+ } else { // resource without data
 157+ $this->serializeExpResource( $property, $valueElement->getSubject(), "\t\t$indent", $isClassTypeProp );
177158 }
178 - }
 159+ } // else: no other types of export elements
179160
180161 if ( !$prop_decl_queued ) {
181162 $this->requireDeclaration( $property, $prop_decl_type );
@@ -185,6 +166,68 @@
186167 $this->post_ns_buffer .= "\t$indent</" . $type . ">\n";
187168 }
188169 }
 170+
 171+ /**
 172+ * Add a serialization of the given SMWExpLiteral to the output,
 173+ * assuming that an opening property tag is alerady there.
 174+ *
 175+ * @param $expResourceProperty SMWExpNsResource the property to use
 176+ * @param $expLiteral SMWExpLiteral the data value to use
 177+ * @param $indent string specifying a prefix for indentation (usually a sequence of tabs)
 178+ */
 179+ protected function serializeExpLiteral( SMWExpNsResource $expResourceProperty, SMWExpLiteral $expLiteral, $indent ) {
 180+ $this->post_ns_buffer .= $indent . '<' . $expResourceProperty->getQName();
 181+ if ( $expLiteral->getDatatype() != '' ) {
 182+ $this->post_ns_buffer .= ' rdf:datatype="' . $expLiteral->getDatatype() . '"';
 183+ }
 184+ $this->post_ns_buffer .= '>' .
 185+ str_replace( array( '&', '>', '<' ), array( '&amp;', '&gt;', '&lt;' ), $expLiteral->getLexicalForm() ) .
 186+ '</' . $expResourceProperty->getQName() . ">\n";
 187+ }
 188+
 189+ /**
 190+ * Add a serialization of the given SMWExpResource to the output,
 191+ * assuming that an opening property tag is alerady there.
 192+ *
 193+ * @param $expResourceProperty SMWExpNsResource the property to use
 194+ * @param $expResource SMWExpResource the data value to use
 195+ * @param $indent string specifying a prefix for indentation (usually a sequence of tabs)
 196+ * @param $isClassTypeProp boolean whether the resource must be declared as a class
 197+ */
 198+ protected function serializeExpResource( SMWExpNsResource $expResourceProperty, SMWExpResource $expResource, $indent, $isClassTypeProp ) {
 199+ $this->post_ns_buffer .= $indent . '<' . $expResourceProperty->getQName();
 200+ if ( !$expResource->isBlankNode() ) {
 201+ $this->post_ns_buffer .= ' rdf:resource="' . $expResource->getUri() . '"';
 202+ }
 203+ $this->post_ns_buffer .= "/>\n";
 204+ if ( $isClassTypeProp ) {
 205+ $this->requireDeclaration( $expResource, SMW_SERIALIZER_DECL_CLASS );
 206+ }
 207+ }
 208+
 209+ /**
 210+ * Add a serialization of the given SMWExpResource to the output,
 211+ * assuming that an opening property tag is alerady there.
 212+ *
 213+ * @param $expResourceProperty SMWExpNsResource the property to use
 214+ * @param $expResource array of (SMWExpResource or SMWExpData)
 215+ * @param $indent string specifying a prefix for indentation (usually a sequence of tabs)
 216+ * @param $isClassTypeProp boolean whether the resource must be declared as a class
 217+ */
 218+ protected function serializeExpCollection( SMWExpNsResource $expResourceProperty, array $collection, $indent, $isClassTypeProp ) {
 219+ $this->post_ns_buffer .= $indent . '<' . $expResourceProperty->getQName() . " rdf:parseType=\"Collection\">\n";
 220+ foreach ( $collection as $expElement ) {
 221+ if ( $expElement instanceof SMWExpData ) {
 222+ $this->serializeNestedExpData( $expElement, $indent );
 223+ } else {
 224+ $this->serializeExpResource( $expResourceProperty, $expElement, $indent );
 225+ }
 226+ if ( $isClassTypeProp ) {
 227+ $this->requireDeclaration( $expResource, SMW_SERIALIZER_DECL_CLASS );
 228+ }
 229+ }
 230+ $this->post_ns_buffer .= "$indent</" . $expResourceProperty->getQName() . ">\n";
 231+ }
189232
190233 /**
191234 * Escape a string in the special form that is required for values in
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php
@@ -70,11 +70,11 @@
7171 * @param mixed $typesvalueforproperty either an SMWTypesValue or null
7272 */
7373 static public function makeExportDataForSubject( SMWDIWikiPage $subject, $typesvalueforproperty = null ) {
74 - $result = self::getDataItemExpData( $subject );
 74+ $result = new SMWExpData( self::getDataItemExpData( $subject ) );
7575 $subj_title = Title::makeTitle( $subject->getNamespace(), $subject->getDBkey() );
7676 switch ( $subject->getNamespace() ) {
7777 case NS_CATEGORY: case SMW_NS_CONCEPT:
78 - $maintype_pe = SMWExporter::getSpecialElement( 'owl', 'Class' );
 78+ $maintype_pe = SMWExporter::getSpecialNsResource( 'owl', 'Class' );
7979 $label = $subj_title->getText();
8080 break;
8181 case SMW_NS_PROPERTY:
@@ -82,22 +82,22 @@
8383 $types = smwfGetStore()->getPropertyValues( $subject, new SMWDIProperty( '_TYPE' ) );
8484 $typesvalueforproperty = end( $types );
8585 }
86 - $maintype_pe = SMWExporter::getSpecialElement( 'owl', SMWExporter::getOWLPropertyType( $typesvalueforproperty ) );
 86+ $maintype_pe = SMWExporter::getSpecialNsResource( 'owl', SMWExporter::getOWLPropertyType( $typesvalueforproperty ) );
8787 $label = $subj_title->getText();
8888 break;
8989 default:
9090 $label = $subj_title->getPrefixedText();
91 - $maintype_pe = SMWExporter::getSpecialElement( 'swivt', 'Subject' );
 91+ $maintype_pe = SMWExporter::getSpecialNsResource( 'swivt', 'Subject' );
9292 }
93 - $ed = new SMWExpData( new SMWExpLiteral( $label ) );
94 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdfs', 'label' ), $ed );
95 - $ed = new SMWExpData( new SMWExpResource( '&wikiurl;' . $subj_title->getPrefixedURL() ) );
96 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'page' ), $ed );
97 - $ed = new SMWExpData( new SMWExpResource( SMWExporter::$m_exporturl . '/' . $subj_title->getPrefixedURL() ) );
98 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdfs', 'isDefinedBy' ), $ed );
99 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ), new SMWExpData( $maintype_pe ) );
100 - $ed = new SMWExpData( new SMWExpLiteral( $subject->getNamespace(), null, 'http://www.w3.org/2001/XMLSchema#integer' ) );
101 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'wikiNamespace' ), $ed );
 93+ $ed = new SMWExpLiteral( $label );
 94+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'label' ), $ed );
 95+ $ed = new SMWExpResource( '&wikiurl;' . $subj_title->getPrefixedURL() );
 96+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'page' ), $ed );
 97+ $ed = new SMWExpResource( SMWExporter::$m_exporturl . '/' . $subj_title->getPrefixedURL() );
 98+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'isDefinedBy' ), $ed );
 99+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $maintype_pe );
 100+ $ed = new SMWExpLiteral( $subject->getNamespace(), 'http://www.w3.org/2001/XMLSchema#integer' );
 101+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'wikiNamespace' ), $ed );
102102 return $result;
103103 }
104104
@@ -120,23 +120,25 @@
121121 }
122122 }
123123 } else { // pre-defined property, only exported if known
124 - $subject = $expData->getSubject()->getDatavalue();
125 - if ( $subject == null ) return; // subject datavalue (wikipage) required for treating special properties properly
126 - switch ( $subject->getNamespace() ) {
 124+ $diSubject = $expData->getSubject()->getDataItem();
 125+ if ( ( $diSubject == null ) || ( $diSubject->getDIType() != SMWDataItem::TYPE_WIKIPAGE ) ) {
 126+ return; // subject datavalue (wikipage) required for treating special properties properly
 127+ }
 128+ switch ( $diSubject->getNamespace() ) {
127129 case NS_CATEGORY: case SMW_NS_CONCEPT:
128 - $category_pe = SMWExporter::getSpecialElement( 'rdfs', 'subClassOf' );
 130+ $category_pe = SMWExporter::getSpecialNsResource( 'rdfs', 'subClassOf' );
129131 $subprop_pe = null;
130 - $equality_pe = SMWExporter::getSpecialElement( 'owl', 'equivalentClass' );
 132+ $equality_pe = SMWExporter::getSpecialNsResource( 'owl', 'equivalentClass' );
131133 break;
132134 case SMW_NS_PROPERTY:
133 - $category_pe = SMWExporter::getSpecialElement( 'rdf', 'type' );
134 - $subprop_pe = SMWExporter::getSpecialElement( 'rdfs', 'subPropertyOf' );
135 - $equality_pe = SMWExporter::getSpecialElement( 'owl', 'equivalentProperty' );
 135+ $category_pe = SMWExporter::getSpecialNsResource( 'rdf', 'type' );
 136+ $subprop_pe = SMWExporter::getSpecialNsResource( 'rdfs', 'subPropertyOf' );
 137+ $equality_pe = SMWExporter::getSpecialNsResource( 'owl', 'equivalentProperty' );
136138 break;
137139 default:
138 - $category_pe = SMWExporter::getSpecialElement( 'rdf', 'type' );
 140+ $category_pe = SMWExporter::getSpecialNsResource( 'rdf', 'type' );
139141 $subprop_pe = null;
140 - $equality_pe = SMWExporter::getSpecialElement( 'owl', 'sameAs' );
 142+ $equality_pe = SMWExporter::getSpecialNsResource( 'owl', 'sameAs' );
141143 }
142144 $pe = null;
143145 $cat_only = false; // basic namespace checking for equivalent categories
@@ -147,14 +149,14 @@
148150 case '_URI': $pe = $equality_pe; break;
149151 case '_SUBP': $pe = $subprop_pe; break;
150152 case '_MDAT':
151 - $pe = SMWExporter::getSpecialElement( 'swivt', 'wikiPageModificationDate' );
 153+ $pe = SMWExporter::getSpecialNsResource( 'swivt', 'wikiPageModificationDate' );
152154 break;
153155 case '_REDI': /// TODO: currently no check for avoiding OWL DL illegal redirects is done
154 - if ( $subject->getNamespace() == SMW_NS_PROPERTY ) {
 156+ if ( $diSubject->getNamespace() == SMW_NS_PROPERTY ) {
155157 $pe = null; // checking the typing here is too cumbersome, smart stores will smush the properties anyway, and the others will not handle them equivalently
156158 } else {
157159 $pe = $equality_pe;
158 - $cat_only = ( $subject->getNamespace() == NS_CATEGORY );
 160+ $cat_only = ( $diSubject->getNamespace() == NS_CATEGORY );
159161 }
160162 break;
161163 }
@@ -167,10 +169,10 @@
168170 }
169171 $ed = self::getDataItemExpData( $dataItem );
170172 if ( $ed !== null ) {
171 - if ( ( $property->getKey() == '_CONC' ) && ( $ed->getSubject()->getName() == '' ) ) {
 173+ if ( ( $property->getKey() == '_CONC' ) && ( $ed->getSubject()->getUri() == '' ) ) {
172174 // equivalent to anonymous class -> simplify description
173175 foreach ( $ed->getProperties() as $subp ) {
174 - if ( $subp->getName() != SMWExporter::getSpecialElement( 'rdf', 'type' )->getName() ) {
 176+ if ( $subp->getUri() != SMWExporter::getSpecialNsResource( 'rdf', 'type' )->getUri() ) {
175177 foreach ( $ed->getValues( $subp ) as $subval ) {
176178 $expData->addPropertyObjectValue( $subp, $subval );
177179 }
@@ -226,7 +228,7 @@
227229 }
228230 }
229231
230 - return new SMWExpResource( $localname, $diWikiPage, $namespace, $namespaceid );
 232+ return new SMWExpNsResource( $localname, $namespace, $namespaceid, $diWikiPage );
231233 }
232234
233235 /**
@@ -251,21 +253,25 @@
252254 }
253255
254256 /**
255 - * Create an SMWExportElement for some special element that belongs to a known vocabulary.
256 - * The parameter given must be a supported namespace id (e.g. "rdfs") and a local name (e.g. "label").
257 - * Returns NULL if $namespace is not known.
 257+ * Create an SMWExpNsResource for some special element that belongs to
 258+ * a known vocabulary. An exception is generated when given parameters
 259+ * that do not fit any known vocabulary.
 260+ *
 261+ * @param $namespaceId string (e.g. "rdf")
 262+ * @param $localName string (e.g. "type")
 263+ * @return SMWExpNsResource
258264 */
259 - static public function getSpecialElement( $namespace, $localname ) {
 265+ static public function getSpecialNsResource( $namespaceId, $localName ) {
260266 $namespaces = array(
261267 'swivt' => '&swivt;',
262268 'rdfs' => '&rdfs;',
263269 'rdf' => '&rdf;',
264270 'owl' => '&owl;',
265271 );
266 - if ( array_key_exists( $namespace, $namespaces ) ) {
267 - return new SMWExpResource( $localname, null, $namespaces[$namespace], $namespace );
 272+ if ( array_key_exists( $namespaceId, $namespaces ) ) {
 273+ return new SMWExpNsResource( $localName, $namespaces[$namespaceId], $namespaceId );
268274 } else {
269 - return null;
 275+ throw new InvalidArgumentException( "The vocabulary '$namespaceId' is not a known special vocabulary." );
270276 }
271277 }
272278
@@ -317,12 +323,12 @@
318324 */
319325 static public function getOntologyExpData( $ontologyuri ) {
320326 $data = new SMWExpData( new SMWExpResource( $ontologyuri ) );
321 - $ed = new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Ontology' ) );
322 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ), $ed );
323 - $ed = new SMWExpData( new SMWExpLiteral( date( DATE_W3C ), null, 'http://www.w3.org/2001/XMLSchema#dateTime' ) );
324 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'creationDate' ), $ed );
325 - $ed = new SMWExpData( new SMWExpResource( 'http://semantic-mediawiki.org/swivt/1.0' ) );
326 - $data->addPropertyObjectValue( SMWExporter::getSpecialElement( 'owl', 'imports' ), $ed );
 327+ $ed = SMWExporter::getSpecialNsResource( 'owl', 'Ontology' );
 328+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $ed );
 329+ $ed = new SMWExpLiteral( date( DATE_W3C ), 'http://www.w3.org/2001/XMLSchema#dateTime' );
 330+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'creationDate' ), $ed );
 331+ $ed = new SMWExpResource( 'http://semantic-mediawiki.org/swivt/1.0' );
 332+ $data->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'owl', 'imports' ), $ed );
327333 return $data;
328334 }
329335
@@ -336,22 +342,22 @@
337343 static public function getDataItemExpData( SMWDataItem $dataItem ) {
338344 switch ( $dataItem->getDIType() ) {
339345 case SMWDataItem::TYPE_NUMBER:
340 - $lit = new SMWExpLiteral( $dataItem->getNumber(), $dataItem, 'http://www.w3.org/2001/XMLSchema#double' );
341 - return new SMWExpData( $lit );
 346+ $lit = new SMWExpLiteral( $dataItem->getNumber(), 'http://www.w3.org/2001/XMLSchema#double', $dataItem );
 347+ return $lit;
342348 break;
343349 case SMWDataItem::TYPE_STRING: case SMWDataItem::TYPE_BLOB:
344 - $lit = new SMWExpLiteral( smwfHTMLtoUTF8( $dataItem->getString() ), $dataItem, 'http://www.w3.org/2001/XMLSchema#string' );
345 - return new SMWExpData( $lit );
 350+ $lit = new SMWExpLiteral( smwfHTMLtoUTF8( $dataItem->getString() ), 'http://www.w3.org/2001/XMLSchema#string', $dataItem );
 351+ return $lit;
346352 break;
347353 case SMWDataItem::TYPE_BOOLEAN:
348354 $xsdvalue = $dataItem->getBoolean() ? 'true' : 'false';
349 - $lit = new SMWExpLiteral( $xsdvalue, $dataItem, 'http://www.w3.org/2001/XMLSchema#boolean' );
350 - return new SMWExpData( $lit );
 355+ $lit = new SMWExpLiteral( $xsdvalue, 'http://www.w3.org/2001/XMLSchema#boolean', $dataItem );
 356+ return $lit;
351357 break;
352358 case SMWDataItem::TYPE_URI:
353359 /// TODO This escaping seems very odd. The serialisation should handle such things.
354360 $res = new SMWExpResource( str_replace( '&', '&amp;', $dataItem->getURI() ), $dataItem );
355 - return new SMWExpData( $res );
 361+ return $res;
356362 break;
357363 case SMWDataItem::TYPE_TIME:
358364 $gregorianTime = $dataItem->getForCalendarModel( SMWDITime::CM_GREGORIAN );
@@ -377,8 +383,8 @@
378384 }
379385 }
380386 $xsdvalue .= 'Z';
381 - $lit = new SMWExpLiteral( $xsdvalue, $gregorianTime, $xsdtype );
382 - return new SMWExpData( $lit );
 387+ $lit = new SMWExpLiteral( $xsdvalue, $xsdtype, $gregorianTime );
 388+ return $lit;
383389 break;
384390 case SMWDataItem::TYPE_GEO:
385391 /// TODO
@@ -393,19 +399,19 @@
394400 $title = Title::makeTitle( $dataItem->getNamespace(), $dataItem->getDBkey() ) ;
395401 $file = wfFindFile( $title );
396402 if ( $file !== false ) {
397 - return new SMWExpData( new SMWExpResource( $file->getFullURL() ) );
 403+ return new SMWExpResource( $file->getFullURL() );
398404 } else { // Medialink to non-existing file :-/
399 - return new SMWExpData( SMWExporter::getResourceElement( $dataItem ) );
 405+ return SMWExporter::getResourceElement( $dataItem );
400406 }
401407 } else {
402 - return new SMWExpData( SMWExporter::getResourceElement( $dataItem ) );
 408+ return SMWExporter::getResourceElement( $dataItem );
403409 }
404410 break;
405411 case SMWDataItem::TYPE_CONCEPT:
406412 /// TODO
407413 break;
408414 case SMWDataItem::TYPE_PROPERTY:
409 - return new SMWExpData( SMWExporter::getResourceElement( $dataItem->getDiWikiPage() ) );
 415+ return SMWExporter::getResourceElement( $dataItem->getDiWikiPage() );
410416 break;
411417 }
412418 }
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer_Turtle.php
@@ -107,13 +107,15 @@
108108 $firstvalue = false;
109109
110110 $this->requireNamespace( $property->getNamespaceID(), $property->getNamespace() );
111 - $object = $value->getSubject();
112111
113 - if ( $object instanceof SMWExpLiteral ) {
 112+ if ( $value instanceof SMWExpLiteral ) {
114113 $prop_decl_type = SMW_SERIALIZER_DECL_APROP;
115 - $this->serializeExpLiteral( $object );
116 - } else { // resource (maybe blank node), could have subdescriptions
 114+ $this->serializeExpLiteral( $value );
 115+ } elseif ( $value instanceof SMWExpResource ) {
117116 $prop_decl_type = SMW_SERIALIZER_DECL_OPROP;
 117+ $this->serializeExpResource( $value );
 118+ } elseif ( $value instanceof SMWExpData ) { // resource (maybe blank node), could have subdescriptions
 119+ $prop_decl_type = SMW_SERIALIZER_DECL_OPROP;
118120 $collection = $value->getCollection();
119121 if ( $collection !== false ) { // RDF-style collection (list)
120122 $this->post_ns_buffer .= "( ";
@@ -132,7 +134,7 @@
133135 $this->post_ns_buffer .= "\n";
134136 $this->serializeNestedExpData( $value, $indent . "\t\t" );
135137 } else { // resource without data: may need to be queued
136 - $this->serializeExpResource( $object );
 138+ $this->serializeExpResource( $value->getSubject() );
137139 }
138140 }
139141 }
@@ -147,7 +149,7 @@
148150 }
149151
150152 protected function serializeExpLiteral( SMWExpLiteral $element ) {
151 - $this->post_ns_buffer .= '"' . str_replace( array( '\\', "\n", '"' ), array( '\\\\', "\\n", '\"' ), $element->getName() ) . '"';
 153+ $this->post_ns_buffer .= '"' . str_replace( array( '\\', "\n", '"' ), array( '\\\\', "\\n", '\"' ), $element->getLexicalForm() ) . '"';
152154 $dt = $element->getDatatype();
153155 if ( ( $dt != '' ) && ( $dt != 'http://www.w3.org/2001/XMLSchema#string' ) ) {
154156 $count = 0;
@@ -164,10 +166,10 @@
165167 if ( $element->isBlankNode() ) {
166168 $this->post_ns_buffer .= '[]';
167169 } else {
168 - if ( $element->getQName() !== false ) {
 170+ if ( $element instanceof SMWExpNsResource ) {
169171 $this->post_ns_buffer .= $element->getQName();
170172 } else {
171 - $this->post_ns_buffer .= '<' . str_replace( '>', '\>', SMWExporter::expandURI( $element->getName() ) ) . '>';
 173+ $this->post_ns_buffer .= '<' . str_replace( '>', '\>', SMWExporter::expandURI( $element->getUri() ) ) . '>';
172174 }
173175 }
174176 }
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer.php
@@ -216,13 +216,17 @@
217217 * declaration is already available, and records a todo otherwise.
218218 */
219219 protected function requireDeclaration( SMWExpResource $resource, $decltype ) {
220 - $namespaceid = $resource->getNamespaceID();
221220 // Do not declare predefined OWL language constructs:
222 - if ( ( $namespaceid == 'owl' ) || ( $namespaceid == 'rdf' ) || ( $namespaceid == 'rdfs' ) ) return;
 221+ if ( $resource instanceof SMWExpNsResource ) {
 222+ $nsId = $resource->getNamespaceId();
 223+ if ( ( $nsId == 'owl' ) || ( $nsId == 'rdf' ) || ( $nsId == 'rdfs' ) ) {
 224+ return;
 225+ }
 226+ }
223227 // Do not declare blank nodes:
224228 if ( $resource->isBlankNode() ) return;
225229
226 - $name = $resource->getName();
 230+ $name = $resource->getUri();
227231 if ( array_key_exists( $name, $this->decl_done ) && ( $this->decl_done[$name] & $decltype ) ) {
228232 return;
229233 }
@@ -237,12 +241,11 @@
238242 * Update the declaration "todo" and "done" lists for the case that the
239243 * given data has been serialized with the type information it provides.
240244 *
241 - * @param $data specifying the type data upon which declarations are based
 245+ * @param $expData specifying the type data upon which declarations are based
242246 */
243 - protected function recordDeclarationTypes( SMWExpData $data ) {
244 - foreach ( $data->getSpecialValues( 'rdf', 'type') as $typedata ) {
245 - $typeresource = $typedata->getSubject();
246 - if ( $typeresource instanceof SMWExpResource ) {
 247+ protected function recordDeclarationTypes( SMWExpData $expData ) {
 248+ foreach ( $expData->getSpecialValues( 'rdf', 'type') as $typeresource ) {
 249+ if ( $typeresource instanceof SMWExpNsResource ) {
247250 switch ( $typeresource->getQName() ) {
248251 case 'owl:Class': $typeflag = SMW_SERIALIZER_DECL_CLASS; break;
249252 case 'owl:ObjectProperty': $typeflag = SMW_SERIALIZER_DECL_OPROP; break;
@@ -250,7 +253,7 @@
251254 default: $typeflag = 0;
252255 }
253256 if ( $typeflag != 0 ) {
254 - $this->declarationDone( $data->getSubject(), $typeflag );
 257+ $this->declarationDone( $expData->getSubject(), $typeflag );
255258 }
256259 }
257260 }
@@ -264,7 +267,7 @@
265268 * @param $typeflag integer specifying the type (e.g. SMW_SERIALIZER_DECL_CLASS)
266269 */
267270 protected function declarationDone( SMWExpResource $element, $typeflag ) {
268 - $name = $element->getName();
 271+ $name = $element->getUri();
269272 $curdone = array_key_exists( $name, $this->decl_done ) ? $this->decl_done[$name] : 0;
270273 $this->decl_done[$name] = $curdone | $typeflag;
271274 if ( array_key_exists( $name, $this->decl_todo ) ) {
@@ -288,9 +291,9 @@
289292 * used as such, hence it is enough to check the property. Moreover, we do
290293 * not use OWL Datatypes in SMW, so rdf:type, rdfs:domain, etc. always
291294 * refer to classes.
292 - * @param SMWExpResource $property
 295+ * @param SMWExpNsResource $property
293296 */
294 - protected function isOWLClassTypeProperty( SMWExpResource $property ) {
 297+ protected function isOWLClassTypeProperty( SMWExpNsResource $property ) {
295298 $locname = $property->getLocalName();
296299 if ( $property->getNamespaceID() == 'rdf' ) {
297300 return ( $locname == 'type' );
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php
@@ -152,8 +152,8 @@
153153 if ( !$this->isValid() ) return null;
154154
155155 $result = new SMWExpData( new SMWExpResource( '', $this ) ); // bnode
156 - $ed = new SMWExpData( SMWExporter::getSpecialElement( 'swivt', 'Container' ) );
157 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ), $ed );
 156+ $ed = new SMWExpData( SMWExporter::getSpecialNsResource( 'swivt', 'Container' ) );
 157+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $ed );
158158 $count = 0;
159159 foreach ( $this->getDVs() as $value ) {
160160 $count++;
@@ -162,11 +162,11 @@
163163 }
164164 if ( ( $value->getTypeID() == '_wpg' ) || ( $value->getTypeID() == '_uri' ) || ( $value->getTypeID() == '_ema' ) ) {
165165 $result->addPropertyObjectValue(
166 - SMWExporter::getSpecialElement( 'swivt', 'object' . $count ),
 166+ SMWExporter::getSpecialNsResource( 'swivt', 'object' . $count ),
167167 $value->getExportData() );
168168 } else {
169169 $result->addPropertyObjectValue(
170 - SMWExporter::getSpecialElement( 'swivt', 'value' . $count ),
 170+ SMWExporter::getSpecialNsResource( 'swivt', 'value' . $count ),
171171 $value->getExportData() );
172172 }
173173 }
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Concept.php
@@ -102,13 +102,13 @@
103103 $exact = true;
104104 $owldesc = $this->descriptionToExpData( $desc, $exact );
105105 if ( $owldesc === false ) {
106 - $element = new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Thing' ) );
 106+ $element = new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Thing' ) );
107107 }
108108 if ( !$exact ) {
109109 $result = new SMWExpData( new SMWExpResource( '' ) );
110 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ),
111 - new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Class' ) ) );
112 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdfs', 'subClassOf' ), $owldesc );
 110+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ),
 111+ new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Class' ) ) );
 112+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'subClassOf' ), $owldesc );
113113 return $result;
114114 } else {
115115 return $owldesc;
@@ -121,18 +121,18 @@
122122 public function descriptionToExpData( $desc, &$exact ) {
123123 if ( ( $desc instanceof SMWConjunction ) || ( $desc instanceof SMWDisjunction ) ) {
124124 $result = new SMWExpData( new SMWExpResource( '' ) );
125 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ),
126 - new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Class' ) ) );
 125+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ),
 126+ new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Class' ) ) );
127127 $elements = array();
128128 foreach ( $desc->getDescriptions() as $subdesc ) {
129129 $element = $this->descriptionToExpData( $subdesc, $exact );
130130 if ( $element === false ) {
131 - $element = new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Thing' ) );
 131+ $element = new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Thing' ) );
132132 }
133133 $elements[] = $element;
134134 }
135135 $prop = ( $desc instanceof SMWConjunction ) ? 'intersectionOf':'unionOf';
136 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'owl', $prop ),
 136+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'owl', $prop ),
137137 SMWExpData::makeCollection( $elements ) );
138138 } elseif ( $desc instanceof SMWClassDescription ) {
139139 if ( count( $desc->getCategories() ) == 1 ) { // single category
@@ -143,35 +143,35 @@
144144 foreach ( $desc->getCategories() as $cat ) {
145145 $elements[] = new SMWExpData( SMWExporter::getResourceElement( $cat ) ); ;
146146 }
147 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'owl', 'unionOf' ),
 147+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'owl', 'unionOf' ),
148148 SMWExpData::makeCollection( $elements ) );
149149 }
150 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ),
151 - new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Class' ) ) );
 150+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ),
 151+ new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Class' ) ) );
152152 } elseif ( $desc instanceof SMWConceptDescription ) {
153153 $result = new SMWExpData( SMWExporter::getResourceElement( $desc->getConcept() ) );
154154 } elseif ( $desc instanceof SMWSomeProperty ) {
155155 $result = new SMWExpData( new SMWExpResource( '' ) );
156 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ),
157 - new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Restriction' ) ) );
158 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'owl', 'onProperty' ),
 156+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ),
 157+ new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Restriction' ) ) );
 158+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'owl', 'onProperty' ),
159159 new SMWExpData( SMWExporter::getResourceElement( $desc->getProperty() ) ) );
160160 $subdata = $this->descriptionToExpData( $desc->getDescription(), $exact );
161161 if ( ( $desc->getDescription() instanceof SMWValueDescription ) &&
162162 ( $desc->getDescription()->getComparator() == SMW_CMP_EQ ) ) {
163 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'owl', 'hasValue' ), $subdata );
 163+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'owl', 'hasValue' ), $subdata );
164164 } else {
165165 if ( $subdata === false ) {
166166 $owltype = SMWExporter::getOWLPropertyType( $desc->getProperty()->getPropertyTypeID() );
167167 if ( $owltype == 'ObjectProperty' ) {
168 - $subdata = new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Thing' ) );
 168+ $subdata = new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Thing' ) );
169169 } elseif ( $owltype == 'DatatypeProperty' ) {
170 - $subdata = new SMWExpData( SMWExporter::getSpecialElement( 'rdfs', 'Literal' ) );
 170+ $subdata = new SMWExpData( SMWExporter::getSpecialNsResource( 'rdfs', 'Literal' ) );
171171 } else { // no restrictions at all with annotation properties ...
172 - return new SMWExpData( SMWExporter::getSpecialElement( 'owl', 'Thing' ) );
 172+ return new SMWExpData( SMWExporter::getSpecialNsResource( 'owl', 'Thing' ) );
173173 }
174174 }
175 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'owl', 'someValuesFrom' ), $subdata );
 175+ $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'owl', 'someValuesFrom' ), $subdata );
176176 }
177177 } elseif ( $desc instanceof SMWValueDescription ) {
178178 if ( $desc->getComparator() == SMW_CMP_EQ ) {

Status & tagging log