node-rdf
node-rdf copied to clipboard
Print profile
Hello,
I would like to know if exists some function to print the profile, I want to reconstruct the complete turtle file based on a graph I know how to print the triples and create a string variable, but I don't find the way to print in the top of the file the prefix.
You know, I thought there was a function that does this, because I've done that before, but maybe it disappeared.
If you need a quick workaround, try this:
function getTurtlePrefixes(profile){
var prefixes = [];
profile.prefixes.prefixMap.forEach(function(uri, prefix){
prefixes.push('@prefix '+prefix+': '+(new rdf.NamedNode(uri)).toNT()+' .\n');
});
return s.join('');
}
Hey @felipexxx, v4.1.0 is out which should fix some of this. Try this:
function getTurtlePrefixes(profile){
var prefixes = [];
profile.prefixes.list().forEach(function(prefix){
var def = new rdf.NamedNode(profile.prefixes.get(prefix));
prefixes.push('@prefix '+prefix+': '+def.toNT()+' .\n');
});
return s.join('');
}
Please let me know if this works for you, or if you have any additional feedback!