You are here

function taxonomy_xml_rdf_document in Taxonomy import/export via XML 6

Same name and namespace in other branches
  1. 5.2 rdf_format.inc \taxonomy_xml_rdf_document()
  2. 5 rdf_format.inc \taxonomy_xml_rdf_document()
  3. 6.2 rdf_format.inc \taxonomy_xml_rdf_document()
  4. 7 rdf_utils.inc \taxonomy_xml_rdf_document()

Set up an RDF document preamble. Returns a document, also sets the passed handle to the RDF node that content should land in

1 call to taxonomy_xml_rdf_document()
taxonomy_xml_rdf_create in ./rdf_format.inc
Return an XML/RDF document representing this vocab

File

./rdf_format.inc, line 536
Include routines for RDF parsing and taxonomy/term creation.

Code

function taxonomy_xml_rdf_document() {
  $dom = new domdocument('1.0', 'UTF-8');
  $dom
    ->appendchild($dom
    ->createcomment(xmlentities('
    This file was created by Drupal taxonomy_xml import/export tool.
    http://drupal.org/project/taxonomy_xml

    The RDF schema in this file is intended to follow the Working Draft
    described at http://www.w3.org/TR/wordnet-rdf/ for the notation of
    thesauri and taxonomies.
    ')));
  $dom
    ->appendchild($dom
    ->createprocessinginstruction('xml-stylesheet', 'href="render-taxonomy-rdf.xsl" type="text/xsl"'));
  $domcontainer = $dom
    ->createelementns(TAXONOMY_XML_RDF_NS, 'rdf:RDF');

  #  $rdfnode->setattribute('xmlns', TAXONOMY_XML_RDFS_NS);
  $dom
    ->appendchild($domcontainer);

  // Why can't I set more namespaces?
  // By appending a namespaced att, the extra namespaces appear at the top.
  // Otherwise the appear everywhere. There must be a better way
  $domcontainer
    ->setattributens(TAXONOMY_XML_RDFS_NS, 'rdfs:title', "Initializing namespace in PHP is hard");
  $domcontainer
    ->setattributens(TAXONOMY_XML_OWL_NS, 'owl:hack', "Initializing namespace in PHP is hard");

  // Note that one way to get namespaces to work right is by adding new
  // elements to their context asap, not by waiting until after further bits are added.
  return $domcontainer;
}