Skip to content

Commit

Permalink
fix (translator/shexml): Fix generation of extend function for blankn…
Browse files Browse the repository at this point in the history
…odes
  • Loading branch information
s-minoo committed Apr 16, 2024
1 parent b2ca9f7 commit a90c5a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
17 changes: 12 additions & 5 deletions translator/src/shexml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn add_rename_extend_op_from_quads(
expr_ident,
&doc.iterators,
&expression_stmt.expr_enum,
source_iter_ident,
source_iter_ident,
);
expression_extend_func_pairs.extend(concate_extend_pairs);

Expand Down Expand Up @@ -230,9 +230,16 @@ fn add_rename_extend_op_from_quads(
Some(&subj.prefix),
&subj.expression,
) {
let subj_term_iri_func = Function::Iri {
inner_function: subj_term_func.into(),
};
let subj_term_iri_func =
if subj.prefix == PrefixNameSpace::BNodePrefix {
Function::BlankNode {
inner_function: subj_term_func.into(),
}
} else {
Function::Iri {
inner_function: subj_term_func.into(),
}
};

for (obj, graph_shape_ident) in obj_graph_pairs.iter() {
let subj_variable =
Expand Down Expand Up @@ -293,7 +300,7 @@ fn add_serializer_op_from_quads(
for (subj, pred, obj, graph) in quads {
let subj_variable =
variablized_terms.subject_variable_index.get(*subj).unwrap();
let graph = * graph;
let graph = *graph;

let obj_variable = match &obj.expression {
shexml_interpreter::ShapeExpression::Link { other_shape_ident } => {
Expand Down
16 changes: 12 additions & 4 deletions translator/src/shexml/operators/extend/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ pub fn obj_lang_datatype_function(
rdf_term_function(doc, obj.prefix.as_ref(), &obj.expression);

let obj_inner_function = obj_function_opt?;
if obj.prefix.is_some() {
Some(Function::Iri {
inner_function: obj_inner_function.into(),
})
if let Some(obj_prefix) = &obj.prefix {
if obj_prefix == &PrefixNameSpace::BNodePrefix {
Some(Function::BlankNode {
inner_function: obj_inner_function.into(),
})
} else {
Some(Function::Iri {
inner_function: obj_inner_function.into(),
})
}
} else {
let dtype_function = obj.datatype.as_ref().and_then(|dtype| {
rdf_term_function(doc, dtype.prefix.as_ref(), &dtype.local_expr)
Expand Down Expand Up @@ -98,6 +104,8 @@ pub fn rdf_term_function(
Rc::new(new_func),
)],
});
} else if prefix_ns == &PrefixNameSpace::BNodePrefix {
return Some(new_func);
}
} else {
return Some(new_func);
Expand Down

0 comments on commit a90c5a5

Please sign in to comment.