Language tags - patzomir/xsparql GitHub Wiki

Adding a language tag

There are 2 ways to add language tag to a literal:

  • Using it a xQuery expression construct {foaf:s1 foaf:p1 "o1"@{"en"}.}
  • Using hard-coded tag construct {foaf:s1 foaf:p1 "o1"@en.}

Please note that the language tag will always be overridden if a data-type(excluding xs:string and xs:untypedAtomic) is present. Example:

declare function local:rdf_analysis ($url) as xs:string {
  let $url := $url
    construct {
      foaf:sdsa foaf:analysis {$url}@{"bg"}.
    }
};
let $check := xs:gYearMonth("2016-12")
return 
    local:rdf_analysis($check)

output: foaf:sdsa foaf:analysis "2016-12"^^xs:gYearMonth .

Language tags present in XML will be carried to RDF

In case this is desired select the node itself and not its text

  • Example
    • XML: <Name xml:lang="en">patzo</Name>
    • XSPARQL: foaf:s1 foaf:p1 {$parent/Name}.} - Note that we select the whole node
    • Output: foaf:s1 foaf:p1 "patzo"@en .
  • You can override the xml:lang:
    • XSPARQL: foaf:s1 foaf:p1 {$parent/Name}@{"bg-latn"}.}
    • Output: foaf:s1 foaf:p1 "patzo"@bg-latn .

In case this is not desired select the text and not the node itself

  • Example (You probably don't want your dates to have language)
    • XML: <ContentDate xml:lang="en">2016-11-21T02:54:53.885Z</ContentDate>
    • XSPARQL: foaf:s1 foaf:p1 {$parent/ContentDate/text()}.}
    • Output: foaf:s1 foaf:p1 "2016-11-21T02:54:53.885Z" .
⚠️ **GitHub.com Fallback** ⚠️