RDFLib / rdflib-jsonld

JSON-LD parser and serializer plugins for RDFLib
Other
283 stars 71 forks source link

Not to serialize unused namespaces in the graph #1

Closed cardinal27513 closed 9 years ago

cardinal27513 commented 12 years ago

I use surfrdf (http://code.google.com/p/surfrdf/) and it pre-fillies with a lot known namespaces and when serialize in XML, serializer only pulls in namespaces referred to in the graph, but when serialized in json-ld, it pulls in all namespaces including the unused ones. Is there an option to tell serializer to just pull in the one that used in the graph?

{
  "@context": {
    "ANNOTATION": "http://www.w3.org/2000/10/annotation-ns#",
    "ANNOTEA": "http://www.w3.org/2002/01/bookmark#",
    "ATOM": "http://atomowl.org/ontologies/atomrdf#",
    "BIBO": "http://purl.org/ontology/bibo/",
    "BIBO_DEGREES": "http://purl.org/ontology/bibo/degrees/",
    "BIBO_EVENTS": "http://purl.org/ontology/bibo/events/",
    "BIBO_ROLES": "http://purl.org/ontology/bibo/roles/",
    "BIBO_STATUS": "http://purl.org/ontology/bibo/status/",
    "CALENDAR": "http://www.w3.org/2002/12/cal/icaltzd#",
    "CFX": "http://ns.cxf.com/2011/core#",
    "CONTACT": "http://www.w3.org/2000/10/swap/pim/contact#",
    "CORRIB_TAX": "http://jonto.corrib.org/taxonomies#",
    "DBLP": "http://www4.wiwiss.fu-berlin.de/dblp/terms.rdf#",
    "DBPEDIA": "http://dbpedia.org/property/",
    "DC": "http://purl.org/dc/elements/1.1/",
    "DCTERMS": "http://purl.org/dc/terms/",
    "DOAP": "http://usefulinc.com/ns/doap#",
    "EVENT": "http://purl.org/NET/c4dm/event.owl#",
    "EXIF": "http://www.w3.org/2003/12/exif/ns/",
    "FOAF": "http://xmlns.com/foaf/0.1/",
    "FRBR": "http://purl.org/vocab/frbr/core#",
    "FRESNEL": "http://www.w3.org/2004/09/fresnel#",
    "FTI": "http://franz.com/ns/allegrograph/2.2/textindex/",
    "GEO": "http://www.w3.org/2003/01/geo/wgs84_pos#",
    "GR": "http://purl.org/goodrelations/v1#",
    "IBIS": "http://purl.org/ibis#",
    "IDEAS": "http://protege.stanford.edu/rdf",
    "IMDB": "http://www.csd.abdn.ac.uk/~ggrimnes/dev/imdb/IMDB#",
    "JDL_STRUCTURE": "http://www.jeromedl.org/structure#",
    "JONTO_DDC": "http://www.corrib.org/jonto/ddc#",
    "JONTO_PKT": "http://www.corrib.org/jonto/pkt#",
    "LUBM": "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#",
    "MARCONT": "http://www.marcont.org/ontology#",
    "MO": "http://purl.org/ontology/mo/",
    "OWL": "http://www.w3.org/2002/07/owl#",
    "PIM": "http://www.w3.org/2000/10/swap/pim/contact#",
    "RDF": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "RDFS": "http://www.w3.org/2000/01/rdf-schema#",
    "RESUME": "http://captsolo.net/semweb/resume/cv.rdfs#",
    "REVIEW": "http://www.isi.edu/webscripter/communityreview/abstract-review-o#",
    "SERENITY3": "http://serenity.deri.org/imdb#",
    "SIOC": "http://rdfs.org/sioc/ns#",
    "SIOC_SERVICES": "http://rdfs.org/sioc/services#",
    "SIOC_TYPES": "http://rdfs.org/sioc/types#",
    "SKOS": "http://www.w3.org/2004/02/skos/core#",
    "SURF": "http://code.google.com/p/surfrdf/",
    "TIME": "http://www.w3.org/2006/time#",
    "VANN": "http://purl.org/vocab/vann/",
    "VCARD": "http://nwalsh.com/rdf/vCard#",
    "VS": "http://www.w3.org/2003/06/sw-vocab-status/ns#",
    "WGS84_POS": "http://www.w3.org/2003/01/geo/wgs84_pos#",
    "WIKIONT": "http://sw.deri.org/2005/04/wikipedia/wikiont.owl",
    "WORDNET": "http://xmlns.com/wordnet/1.6/",
    "WOT": "http://xmlns.com/wot/0.1/",
    "XFOAF": "http://www.foafrealm.org/xfoaf/0.1/",
    "XSD": "http://www.w3.org/2001/XMLSchema#",
    "YAGO": "http://dbpedia.org/class/yago/",
    "__fallback_namespace": "http://code.google.com/p/surfrdf/",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "v": "http://xmlns.com/wordnet/1.6/"
  },
  "@id": "http://id123",
  "@type": "CFX:ABC",
  "CFX:hasChild": {
    "@id": "http://id234"
  }
}
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
   xmlns:CFX="http://ns.cxf.com/2011/core#"
   xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
  <rdf:Description rdf:about="http://id123">
    <RDF:type rdf:resource="http://ns.cxf.com/2011/core#ABC "/>
    <CFX:hasChild rdf:resource="http://id234"/>
  </rdf:Description>
</rdf:RDF>
niklasl commented 9 years ago

This should no longer happen.