function taxonomy_xml_rdfs_create in Taxonomy import/export via XML 7
Return an XML/RDF document representing this vocab
Uses PHP DOM to create DOM document and nodes.
We use namespaces carefully here, although it may create wordy output if the DOM is not optimizing the declarations for us. Still, best to be explicit, it would seem.
The URI used to refer to other resources is based on the source document location, eg http://this.server/taxonomy/term/{tid}
Preamble should look something like:
<rdf:RDF xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns: rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns: owl="http://www.w3.org/2002/07/owl#"
File
- ./
rdfs_format.inc, line 67
Code
function taxonomy_xml_rdfs_create($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
$vocabulary = taxonomy_vocabulary_load($vid);
$domcontainer = taxonomy_xml_rdf_document();
$dom = $domcontainer->ownerDocument;
#dpm(array(domcontainer => $domcontainer, dom => $dom));
// Use our OWN rdf mapping!
// Define the vocab.
taxonomy_xml_rdfs_add_vocab($domcontainer, $vocabulary);
// And more details?
// Now start adding terms.
// They are listed as siblings, not children of the ontology
$tree = taxonomy_get_tree($vocabulary->vid, $parent, $max_depth, $depth);
taxonomy_xml_rdfs_add_terms($domcontainer, $tree);
$result = $dom
->savexml();
// Minor layout tweak for readability.
$result = preg_replace('|(<[^<]*/[^>]*>)|', "\$1\n", $result);
$result = preg_replace('|><|', ">\n<", $result);
return $result;
}