Class NormalizeRDFTerms

java.lang.Object
org.apache.jena.riot.process.normalize.NormalizeRDFTerms
All Implemented Interfaces:
NormalizeTerm

public class NormalizeRDFTerms extends Object implements NormalizeTerm
Convert literals to normalized forms. Sometimes called canonicalization. There is one preferred RDFTerm for a given RDFterm "value" ("value" generalized to include URis and blank nodes). Mostly, this affects literals. Only certain datatypes are supported but applications can add normalization for other datatypes.

Various policies are provided:

  • General (close to Turtle, use the turtle form for long term contract)
  • Turtle
  • *
  • XSD
  • XSD - follows XSD 1.1. Mantissa/exponents are adjusted. xsd:decimal of an integer value does not have a decimal point, and is not suitable for Turtle as a xsd:decimal short form.
  • Turtle - produces decimals, floats and double suitable for Turtle short-form syntax.

XSD Schema 1.1 does not define a canonical form for all cases.

  • Method Details

    • get

      public static NormalizeRDFTerms get()
      General normalization.
    • getTTL

      public static NormalizeRDFTerms getTTL()
      Normalization for use in Turtle output syntax.
      • xsd:decimals always have a decimal point.
      • xsd:doubles always have an exponent. For ones that are less that 10E7, add "e0", otherwise normalize the mantissa and have an exponent ('E').
      • xsd:floats For ones that are less that 10E7, just the decimal, no expoent. Otherwise normalize the mantissa and have an expoent ('E').
      The normalization does produce forms for decimals and doubles that are correct as Turtle syntactic forms. For doubles, but not floats, zero is "0.0e0", whereas Java produces "0.0". For floats, the Java is returned for values with low precision.
    • getXSD

      public static NormalizeRDFTerms getXSD()
      Normalization by XSD 1.1
      • xsd:double and xsd:float - the mantissa and exponent are adjusted based on value. The Exponent is 'E'.
      • xsd;decimal - an integer value does not have a decimal point and may not be suitable for Turtle as a xsd:decimal short form.
    • getXSD11

      public static NormalizeRDFTerms getXSD11()
      Normalize based on XSD 1.1.
    • getXSD10

      public static NormalizeRDFTerms getXSD10()
      Normalize based on XSD 1.0 where decimals always have decimal point.
    • normalizeValue

      public static org.apache.jena.graph.Node normalizeValue(org.apache.jena.graph.Node node)
      Canonicalize a literal, both lexical form and language tag
    • normalize

      public org.apache.jena.graph.Node normalize(org.apache.jena.graph.Node node)
      Canonicalize a literal, both lexical form and language tag
      Specified by:
      normalize in interface NormalizeTerm