tasks/jsonld/js/jsonld.js
function _parseRdfaApiData(data) {
  var dataset = {};
  dataset['@default'] = [];

  var subjects = data.getSubjects();
  for(var si = 0; si < subjects.length; ++si) {
    var subject = subjects[si];
    if(subject === null) {
      continue;
    }

    // get all related triples
    var triples = data.getSubjectTriples(subject);
    if(triples === null) {
      continue;
    }
    var predicates = triples.predicates;
    for(var predicate in predicates) {
      // iterate over objects
      var objects = predicates[predicate].objects;
      for(var oi = 0; oi < objects.length; ++oi) {
        var object = objects[oi];

        // create RDF triple
        var triple = {};

        // add subject
        if(subject.indexOf('_:') === 0) {
          triple.subject = {type: 'blank node', value: subject};
        }
        else {
          triple.subject = {type: 'IRI', value: subject};
        }

        // add predicate
        if(predicate.indexOf('_:') === 0) {
          triple.predicate = {type: 'blank node', value: predicate};
        }
        else {
          triple.predicate = {type: 'IRI', value: predicate};
        }

        // serialize XML literal
        var value = object.value;
        if(object.type === RDF_XML_LITERAL) {
          // initialize XMLSerializer
          if(!XMLSerializer) {
            _defineXMLSerializer();
          }
          var serializer = new XMLSerializer();
          value = '';
          for(var x = 0; x < object.value.length; x++) {
            if(object.value[x].nodeType === Node.ELEMENT_NODE) {
              value += serializer.serializeToString(object.value[x]);
            }
            else if(object.value[x].nodeType === Node.TEXT_NODE) {
              value += object.value[x].nodeValue;
            }
          }
        }

        // add object
        triple.object = {};

        // object is an IRI
        if(object.type === RDF_OBJECT) {
          if(object.value.indexOf('_:') === 0) {
            triple.object.type = 'blank node';
          }
          else {
            triple.object.type = 'IRI';
          }
        }
        // literal
        else {
          triple.object.type = 'literal';
          if(object.type === RDF_PLAIN_LITERAL) {
            if(object.language) {
              triple.object.datatype = RDF_LANGSTRING;
              triple.object.language = object.language;
            }
            else {
              triple.object.datatype = XSD_STRING;
            }
          }
          else {
            triple.object.datatype = object.type;
          }
        }
        triple.object.value = value;

        // add triple to dataset in default graph
        dataset['@default'].push(triple);
      }
    }
  }

  return dataset;
}
function _parseRdfaApiData(data) {
  var dataset = {};
  dataset['@default'] = [];

  var subjects = data.getSubjects();
  for(var si = 0; si < subjects.length; ++si) {
    var subject = subjects[si];
    if(subject === null) {
      continue;
    }

    // get all related triples
    var triples = data.getSubjectTriples(subject);
    if(triples === null) {
      continue;
    }
    var predicates = triples.predicates;
    for(var predicate in predicates) {
      // iterate over objects
      var objects = predicates[predicate].objects;
      for(var oi = 0; oi < objects.length; ++oi) {
        var object = objects[oi];

        // create RDF triple
        var triple = {};

        // add subject
        if(subject.indexOf('_:') === 0) {
          triple.subject = {type: 'blank node', value: subject};
        }
        else {
          triple.subject = {type: 'IRI', value: subject};
        }

        // add predicate
        if(predicate.indexOf('_:') === 0) {
          triple.predicate = {type: 'blank node', value: predicate};
        }
        else {
          triple.predicate = {type: 'IRI', value: predicate};
        }

        // serialize XML literal
        var value = object.value;
        if(object.type === RDF_XML_LITERAL) {
          // initialize XMLSerializer
          if(!XMLSerializer) {
            _defineXMLSerializer();
          }
          var serializer = new XMLSerializer();
          value = '';
          for(var x = 0; x < object.value.length; x++) {
            if(object.value[x].nodeType === Node.ELEMENT_NODE) {
              value += serializer.serializeToString(object.value[x]);
            }
            else if(object.value[x].nodeType === Node.TEXT_NODE) {
              value += object.value[x].nodeValue;
            }
          }
        }

        // add object
        triple.object = {};

        // object is an IRI
        if(object.type === RDF_OBJECT) {
          if(object.value.indexOf('_:') === 0) {
            triple.object.type = 'blank node';
          }
          else {
            triple.object.type = 'IRI';
          }
        }
        // literal
        else {
          triple.object.type = 'literal';
          if(object.type === RDF_PLAIN_LITERAL) {
            if(object.language) {
              triple.object.datatype = RDF_LANGSTRING;
              triple.object.language = object.language;
            }
            else {
              triple.object.datatype = XSD_STRING;
            }
          }
          else {
            triple.object.datatype = object.type;
          }
        }
        triple.object.value = value;

        // add triple to dataset in default graph
        dataset['@default'].push(triple);
      }
    }
  }

  return dataset;
}
function _parseRdfaApiData ( data ) { var dataset = { } ; dataset [ '@default' ] = [ ] ; var subjects = data . getSubjects ( ) ; for ( var si = 0 ; si < subjects . length ; ++ si ) { var subject = subjects [ si ] ; if ( subject === null ) { continue ; } // get all related triples var triples = data . getSubjectTriples ( subject ) ; if ( triples === null ) { continue ; } var predicates = triples . predicates ; for ( var predicate in predicates ) { // iterate over objects var objects = predicates [ predicate ] . objects ; for ( var oi = 0 ; oi < objects . length ; ++ oi ) { var object = objects [ oi ] ; // create RDF triple var triple = { } ; // add subject if ( subject . indexOf ( '_:' ) === 0 ) { triple . subject = { type : 'blank node' , value : subject } ; } else { triple . subject = { type : 'IRI' , value : subject } ; } // add predicate if ( predicate . indexOf ( '_:' ) === 0 ) { triple . predicate = { type : 'blank node' , value : predicate } ; } else { triple . predicate = { type : 'IRI' , value : predicate } ; } // serialize XML literal var value = object . value ; if ( object . type === RDF_XML_LITERAL ) { // initialize XMLSerializer if ( ! XMLSerializer ) { _defineXMLSerializer ( ) ; } var serializer = new XMLSerializer ( ) ; value = '' ; for ( var x = 0 ; x < object . value . length ; x ++ ) { if ( object . value [ x ] . nodeType === Node . ELEMENT_NODE ) { value += serializer . serializeToString ( object . value [ x ] ) ; } else if ( object . value [ x ] . nodeType === Node . TEXT_NODE ) { value += object . value [ x ] . nodeValue ; } } } // add object triple . object = { } ; // object is an IRI if ( object . type === RDF_OBJECT ) { if ( object . value . indexOf ( '_:' ) === 0 ) { triple . object . type = 'blank node' ; } else { triple . object . type = 'IRI' ; } } // literal else { triple . object . type = 'literal' ; if ( object . type === RDF_PLAIN_LITERAL ) { if ( object . language ) { triple . object . datatype = RDF_LANGSTRING ; triple . object . language = object . language ; } else { triple . object . datatype = XSD_STRING ; } } else { triple . object . datatype = object . type ; } } triple . object . value = value ; // add triple to dataset in default graph dataset [ '@default' ] . push ( triple ) ; } } } return dataset ; }
Parses the RDF dataset found via the data object from the RDFa API.

@param data the RDFa API data object.

@return the RDF dataset.
Parses the RDF dataset found via the data object from the RDFa API .