Skip to content

Commit

Permalink
Fix #86 by not interpreting typed literals.
Browse files Browse the repository at this point in the history
Pin Rust version to 1.81.0 in CI.
  • Loading branch information
timothee-haudebourg committed Dec 19, 2024
1 parent 5625c9a commit 658f0cc
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.81.0
with:
components: rustfmt, clippy
- name: Check formatting
Expand Down
3 changes: 2 additions & 1 deletion crates/compaction/src/iri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ where
|| (candidate_def.is_some()
&& candidate_def
.and_then(|def| def.value())
.map_or(false, |v| v == var) && value.is_none()))
.map_or(false, |v| v == var)
&& value.is_none()))
{
compact_iri = candidate
}
Expand Down
12 changes: 5 additions & 7 deletions crates/core/src/deserialization/object/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use linked_data::{
xsd_types, CowRdfTerm, LinkedData, LinkedDataGraph, LinkedDataPredicateObjects,
LinkedDataResource, LinkedDataSubject, RdfLiteral, RdfLiteralRef, ResourceInterpretation,
};
use rdf_types::{Interpretation, Term, Vocabulary};
use rdf_types::{Interpretation, LiteralTypeRef, Term, Vocabulary};

use crate::{
object::Literal,
Expand Down Expand Up @@ -62,12 +62,10 @@ impl<V: Vocabulary, I: Interpretation> LinkedDataResource<I, V> for Value<V::Iri

CowRdfTerm::Owned(Term::Literal(RdfLiteral::Xsd(value)))
}
Literal::String(s) => match ty {
Some(ty) => CowRdfTerm::from_str(vocabulary, s.as_str(), ty),
None => CowRdfTerm::Borrowed(Term::Literal(RdfLiteralRef::Xsd(
xsd_types::ValueRef::String(s),
))),
},
Literal::String(s) => CowRdfTerm::Borrowed(Term::Literal(match ty {
Some(ty) => RdfLiteralRef::Any(s.as_str(), LiteralTypeRef::Any(ty)),
None => RdfLiteralRef::Xsd(xsd_types::ValueRef::String(s)),
})),
},
Self::LangString(s) => match s.language().and_then(|l| l.as_well_formed()) {
Some(tag) => CowRdfTerm::Owned(Term::Literal(RdfLiteral::Any(
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub trait Any<T, B> {
}

#[inline]
fn language<'a>(&'a self) -> Option<&LenientLangTag>
fn language<'a>(&'a self) -> Option<&'a LenientLangTag>
where
T: 'a,
B: 'a,
Expand Down
2 changes: 1 addition & 1 deletion crates/expansion/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ where
)
.await?
.into_processed(), // .err_at(|| active_property.as_ref().map(Meta::metadata).cloned().unwrap_or_default())?
// .into_inner(),
// .into_inner(),
);
}

Expand Down
1 change: 1 addition & 0 deletions crates/expansion/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl From<Options> for json_ld_context_processing::Options {
/// is to drop keys that are not defined in the context unless:
/// - there is a vocabulary mapping (`@vocab`) defined in the context; or
/// - the term contains a `:` character.
///
/// In other words, a key that cannot be expanded into an
/// IRI or a blank node identifier is dropped unless it contains a `:` character.
///
Expand Down
18 changes: 10 additions & 8 deletions src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ pub struct Options<I = IriBuf> {
/// to and from RDF.
///
/// - If set to [`RdfDirection::I18nDatatype`], an RDF literal is
/// generated using a datatype IRI based on <https://www.w3.org/ns/i18n#>
/// with both the language tag (if present) and base direction encoded. When
/// transforming from RDF, this datatype is decoded to create a value object
/// containing `@language` (if present) and `@direction`.
/// generated using a datatype IRI based on
/// <https://www.w3.org/ns/i18n#> with both the language tag (if
/// present) and base direction encoded. When transforming from RDF,
/// this datatype is decoded to create a value object containing
/// `@language` (if present) and `@direction`.
/// - If set to [`RdfDirection::CompoundLiteral`], a blank node is emitted
/// instead of a literal, where the blank node is the subject of
/// `rdf:value`, `rdf:direction`, and `rdf:language` (if present)
/// properties. When transforming from RDF, this object is decoded to create
/// a value object containing `@language` (if present) and `@direction`.
/// instead of a literal, where the blank node is the subject of
/// `rdf:value`, `rdf:direction`, and `rdf:language` (if present)
/// properties. When transforming from RDF, this object is decoded to
/// create a value object containing `@language` (if present) and
/// `@direction`.
pub rdf_direction: Option<RdfDirection>,

/// If set to `true`, the JSON-LD processor may emit blank nodes for triple
Expand Down

0 comments on commit 658f0cc

Please sign in to comment.