@@ -153,16 +153,31 @@ pub fn translate_data_property_assertion_axiom(v: &Value) -> Value {
153153 //translate OWL classes
154154 let property = property_translation:: translate ( & owl[ 1 ] ) ;
155155 let from = class_translation:: translate ( & owl[ 2 ] ) ;
156- let to = class_translation:: translate ( & owl[ 3 ] ) ;
156+
157+ let to: Value = if let Some ( s) = owl[ 3 ] . as_str ( ) {
158+ if let Some ( ( literal, datatype) ) = s. split_once ( "^^" ) {
159+ json ! ( { "object" : unquote_once( literal) , "datatype" : datatype } )
160+ } else if let Some ( ( literal, language) ) = s. split_once ( '@' ) {
161+ json ! ( { "object" : unquote_once( literal) , "datatype" : format!( "@{language}" ) } )
162+ } else {
163+ json ! ( { "object" : unquote_once( s) , "datatype" : "http://www.w3.org/2001/XMLSchema#string" } )
164+ }
165+ } else {
166+ Value :: Null
167+ } ;
168+
169+ let literal = to. get ( "object" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
170+ let datatype = to. get ( "datatype" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
171+
157172
158173 let triple = json ! ( {
159174 "assertion" : "1" ,
160175 "retraction" : "0" ,
161176 "graph" : "graph" ,
162177 "subject" : from,
163178 "predicate" : property,
164- "object" : to ,
165- "datatype" : "_IRI" ,
179+ "object" : literal ,
180+ "datatype" : datatype ,
166181 "annotation" : annotation
167182 } ) ;
168183 triple
@@ -226,8 +241,6 @@ pub fn translate_negative_data_property_assertion_axiom(v: &Value) -> Value {
226241 let from = class_translation:: translate ( & owl[ 2 ] ) ;
227242
228243 //TODO: handle data values properly
229- //TODO need to check for datatypes first
230- //let to = class_translation::translate(&owl[3]);
231244 let to: Value = if let Some ( s) = owl[ 3 ] . as_str ( ) {
232245 if let Some ( ( literal, datatype) ) = s. split_once ( "^^" ) {
233246 json ! ( { "object" : unquote_once( literal) , "datatype" : datatype } )
0 commit comments