Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1262

Turtle serializer: sort & align prefixes; sort "paragraphs"

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • Cmd line tools

    Description

      1. Sort & align prefixes. Instead of this:

      @prefix lcc-3166-1: <http://www.omg.org/spec/LCC/Countries/ISO3166-1-CountryCodes/> .
      @prefix dct:   <http://purl.org/dc/terms/> .
      @prefix owl:   <http://www.w3.org/2002/07/owl#> .
      @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
      @prefix lcc-3166-2: <http://www.omg.org/spec/LCC/Countries/ISO3166-2-SubdivisionCodes/> .
      @prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
      @prefix skos:  <http://www.w3.org/2004/02/skos/core#> .
      @prefix sm:    <http://www.omg.org/techprocess/ab/SpecificationMetadata/> .
      @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
      @prefix lcc-lr: <http://www.omg.org/spec/LCC/Languages/LanguageRepresentation/> .
      @prefix lcc-cr: <http://www.omg.org/spec/LCC/Countries/CountryRepresentation/> .
      

      it would be great to produce that:

      @prefix dct:        <http://purl.org/dc/terms/> .
      @prefix lcc-3166-1: <http://www.omg.org/spec/LCC/Countries/ISO3166-1-CountryCodes/> .
      @prefix lcc-3166-2: <http://www.omg.org/spec/LCC/Countries/ISO3166-2-SubdivisionCodes/> .
      @prefix lcc-cr:     <http://www.omg.org/spec/LCC/Countries/CountryRepresentation/> .
      @prefix lcc-lr:     <http://www.omg.org/spec/LCC/Languages/LanguageRepresentation/> .
      @prefix owl:        <http://www.w3.org/2002/07/owl#> .
      @prefix rdf:        <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
      @prefix rdfs:       <http://www.w3.org/2000/01/rdf-schema#> .
      @prefix skos:       <http://www.w3.org/2004/02/skos/core#> .
      @prefix sm:         <http://www.omg.org/techprocess/ab/SpecificationMetadata/> .
      @prefix xsd:        <http://www.w3.org/2001/XMLSchema#> .
      

      2. "Paragraphs"
      (this applies only to non-streaming mode, i.e. --formatted=turtle).
      By "paragraphs" I mean statements with the same subject, which RIOT separates by an empty line (i.e. that also matches the common definition of paragraph in text processing tools like Emacs).
      If you sort them, in a well-constructed ontology that will output first the ontology, then Classes, the properties: which GREATLY aids understanding.
      Eg see attached the FIBO BusinessRegistries ontology reformatted in this way (the comment lines are added manually).

      ## ontology
      
      fibo-fbc-fct-breg:  a        owl:Ontology ;
              rdfs:label           "Business Registries Ontology" ;
              dct:license          "http://www.omg.org/techprocess/ab/SpecificationMetadata/MITLicense"^^xsd:anyURI ;
              sm:contentLanguage   "http://www.omg.org/spec/ODM/"^^xsd:anyURI , "http://www.w3.org/standards/techs/owl#w3c_all"^^xsd:anyURI ;
              sm:copyright         "Copyright (c) 2015 EDM Council, Inc.\nCopyright (c) 2015 Object Management Group, Inc." ;
              sm:fileAbbreviation  "fibo-fbc-fct-breg" ;
              sm:filename          "BusinessRegistries.rdf" ;
              owl:imports          fibo-fnd-aap-agt: , fibo-fnd-utl-av: , fibo-fbc-fct-ra: , fibo-be-le-fbo: , fibo-fnd-law-jur: , fibo-fnd-utl-bt: , fibo-fnd-rel-rel: , fibo-fnd-plc-adr: , lcc-cr: , fibo-fnd-dt-fd: ;
              owl:versionIRI       <http://www.omg.org/spec/EDMC-FIBO/FBC/20150801/FunctionalEntities/BusinessRegistries/> .
      
      ## classes
      
      fibo-fbc-fct-breg:BusinessRegistrationAuthority
              a                            owl:Class ;
              rdfs:label                   "business registration authority" ;
              rdfs:subClassOf              fibo-fbc-fct-ra:RegistrationAuthority ;
              rdfs:subClassOf              [ a                         owl:Restriction ;
                                             owl:onClass               fibo-fnd-law-jur:Jurisdiction ;
                                             owl:onProperty            fibo-fnd-rel-rel:isGovernedBy ;
                                             owl:qualifiedCardinality  "1"^^xsd:nonNegativeInteger
                                           ] ;
              rdfs:subClassOf              [ a                            owl:Restriction ;
                                             owl:minQualifiedCardinality  "1"^^xsd:nonNegativeInteger ;
                                             owl:onClass                  fibo-fbc-fct-breg:BusinessRegistry ;
                                             owl:onProperty               fibo-fnd-rel-rel:manages
                                           ] ;
              fibo-fnd-utl-av:adaptedFrom  "http://www.leiroc.org/publications/gls/lou_20140620.pdf"^^xsd:anyURI ;
              skos:definition              "a governmental registration authority that is responsible for maintaining a registry of business entities for a particular jurisdiction" .
      ...
      
      ## properties
      
      fibo-fbc-fct-breg:hasAddressLine1
              a                owl:DatatypeProperty ;
              rdfs:domain      fibo-fbc-fct-breg:RegistrationAddress ;
              rdfs:label       "has address line 1" ;
              rdfs:range       fibo-fnd-utl-bt:text ;
              fibo-fnd-utl-av:definitionOrigin
                      "http://www.leiroc.org/publications/gls/lou_20140620.pdf"^^xsd:anyURI ;
              skos:definition  "the first line of the street address" .
      ...
      

      Attachments

        1. BusinessRegistries.ttl
          11 kB
          Vladimir Alexiev

        Issue Links

          Activity

            People

              andy Andy Seaborne
              vladimir.alexiev Vladimir Alexiev
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: