Format specifications for taxonomy_xml in Taxonomy import/export via XML 5.2
Same filename and directory in other branches
Custom Drupal-only XML
The core format for taxonomy files is a custom-made XML schema reflecting the internal data objects of Drupal vocabulary terms pretty directly. It's suitable for exchanging taxonomies between similar versions of Drupal sites.
An XML schema taxonomy.xsd is available for validation. A snippet looks something like:
<vocabulary> <vid>5</vid> <name>Editorial sections</name> <hierarchy>1</hierarchy> <nodes>blog,page,story</nodes> <term> <tid>83</tid> <vid>5</vid> <name>Analysis</name> <description>Examines the connections between known facts.</description> <parent>0</parent> </term> <term> ... </term> </vocabulary>
CSV - Comma Separated Values
For compatibility with the widest range of sources, CSV import is
possible.
See ISO 2788 for notes on expressing thesauri.
Flat-file taxonomies (or "thesauri", or "restricted vocabularies") are
often notated in files looking something like:
Cyclones, Use, Storms Disasters, Used for, Natural disasters Storms, Used for, Cyclones Storms, Broader Terms, Weather Storms, Related Terms, Disasters Tidal waves, Use, Tsunami Tsunami, Used for, Tidal waves Tsunami, Broader Terms, Disasters Tsunami, Related Terms, Oceans Weather, Narrower Terms, Rain Weather, Narrower Terms, Storms Weather, Narrower Terms, Wind Weather, Related Terms, MeteorologyThis (incomplete) set of data would produce a taxonomy model looking like:
-- Disasters (syn: Natural Disasters; rel: Storms) ---- Tsunami (syn: Tidal Waves; rel: Oceans -- Weather (syn: Meteorology) ---- Storms (rel: Disasters, syn: Cyclones) ---- Rain ---- Wind
The shape of these files is pretty similar from many sources,
however the terminology used varies widely.
"Related Term" is sometimes written as ['Related', 'RT', 'seeAlso'];
The same applies to all the other concepts.
Taxonomy_xml imports from CSV attempt to use any of these synonymsb>, so it doesn't
actually matter which words you use! See the
taxonomy_xml_relationship_synonyms() function for the full list. There
is no requirement about source order (you can refer to terms before they
have been 'declared') and there is no requirement for internal
consistency. You can declare one term a parent of another, that one a
child of the first, with a statement either way, or both.
A quick way to prototype up a taxonomy would be to create it in a text file with a term on each line, listing only the parent (or "Broader Term") to simply define an extensive hierarchy. If you are attempting to import from other sources, it should be possible to massage the data into a spreadsheet that can save a CSV looking something like this.
CSV format is only supported for import. No export is yet available. A much simpler (less powerful) module project was taxonomy_csv.module ... only mentioned for historical/comparison reasons.
RDF - Portable Metadata
For interchange with the newer information methodologies on the web, RDF is the preferred syntax. Although it's very verbose, and much harder for humans to read, it has many advantages when it comes to data interchange over the web, including
- the ability to refer to resources (in this case terms) using URIs
- It can decentralize the information, splitting up definitions over several files, or even servers
- It's useful for merging data from many sources, or annotating definitions made somewhere else
- It's a driving force under many Web 2.0 features, like RSS
The dialect of RDF used in this module (even within this strict schema there are markup variations possible) is intended to resemble the (non-normative) examples found in the W3C recommendations, specifically the sample Wine Ontology [RDF].
Other target input sources include :
- supported: The OWL/RDF port of the WordNet Lexicon as discussed (but never usefully implimented) at the W3C,
- supported: The next generation Wordnet RDF 2.0 from the W3c http://www.w3.org/2006/03/wn/wn20/schema/
- SUMO - The Suggested Upper Merged Ontology
- supported: ICRA Content Rating
Dependancies and capabilities
For RDF input parsing, we use a GPL library, ARC from appmosphere arc.semsol.org. This is PHP4 compatible. RDF processing is seldom efficient, either in memory or time, so there may be difficulties with large imports.
For RDF output creation, we use PHP5 XML/DOM
functions this makes RDF output incompatible with PHP4, which
had very flaky XML functions. If you are trying these use the Web2.0
features, you really must upgrade from the (now officially unsupported)
PHP4, as this legacy support would drag development down.
So the situation is, older unpatched servers can take advantage of the
distributed RDF vocabularies, but cannot easily distribute their own.
Author: Dan Morrison (dman) 2008 http://coders.co.nz
File
formats.htmlView source
<html xmlns="http://www.w3.org/1999/xhtml"> <!-- // @file Format specifications for taxonomy_xml // @author Dan Morrison (dman) 2008 http://coders.co.nz --> <head> <title>Format specifications for taxonomy_xml</title> </head> <body> <h1>Format specifications for taxonomy_xml</h1> <h2>Custom Drupal-only XML</h2> <p>The core format for taxonomy files is a custom-made XML schema reflecting the internal data objects of Drupal vocabulary terms pretty directly. It's suitable for exchanging taxonomies between similar versions of Drupal sites.</p> <p>An XML schema taxonomy.xsd is available for validation. A snippet looks something like:</p> <pre> <vocabulary> <vid>5</vid> <name>Editorial sections</name> <hierarchy>1</hierarchy> <nodes>blog,page,story</nodes> <term> <tid>83</tid> <vid>5</vid> <name>Analysis</name> <description>Examines the connections between known facts.</description> <parent>0</parent> </term> <term> ... </term> </vocabulary> </pre> <h2>CSV - Comma Separated Values</h2> <p>For compatibility with the widest range of sources, CSV import is possible. <br /> See ISO 2788 for notes on expressing thesauri. <br /> Flat-file taxonomies (or "thesauri", or "restricted vocabularies") are often notated in files looking something like:</p> <pre> Cyclones, Use, Storms Disasters, Used for, Natural disasters Storms, Used for, Cyclones Storms, Broader Terms, Weather Storms, Related Terms, Disasters Tidal waves, Use, Tsunami Tsunami, Used for, Tidal waves Tsunami, Broader Terms, Disasters Tsunami, Related Terms, Oceans Weather, Narrower Terms, Rain Weather, Narrower Terms, Storms Weather, Narrower Terms, Wind Weather, Related Terms, Meteorology </pre> This (incomplete) set of data would produce a taxonomy model looking like: <pre> -- Disasters (syn: Natural Disasters; rel: Storms) ---- Tsunami (syn: Tidal Waves; rel: Oceans -- Weather (syn: Meteorology) ---- Storms (rel: Disasters, syn: Cyclones) ---- Rain ---- Wind </pre> <p></p> <p>The shape of these files is pretty similar from many sources, however the terminology used varies widely. <br /> "Related Term" is sometimes written as ['Related', 'RT', 'seeAlso']; <br /> The same applies to all the other concepts. <br /> Taxonomy_xml imports from CSV <b>attempt to use any of these synonyms</b>b>, so it doesn't actually matter which words you use! See the taxonomy_xml_relationship_synonyms() function for the full list. There is no requirement about source order (you can refer to terms before they have been 'declared') and there is no requirement for internal consistency. You can declare one term a parent of another, that one a child of the first, with a statement either way, or both.</p> <p>A quick way to prototype up a taxonomy would be to create it in a text file with a term on each line, listing only the parent (or "Broader Term") to simply define an extensive hierarchy. If you are attempting to import from other sources, it should be possible to massage the data into a spreadsheet that can save a CSV looking something like this.</p> <p>CSV format is only supported for import. No export is yet available. A much simpler (less powerful) module project was <a href="http://drupal.org/project/taxonomy_csv">taxonomy_csv.module</a> ... only mentioned for historical/comparison reasons.</p> <h2>RDF - Portable Metadata</h2> <p>For interchange with the newer information methodologies on the web, RDF is the preferred syntax. Although it's very verbose, and much harder for humans to read, it has many advantages when it comes to data interchange over the web, including</p> <ul> <li>the ability to refer to resources (in this case terms) using URIs</li> <li>It can decentralize the information, splitting up definitions over several files, or even servers</li> <li>It's useful for merging data from many sources, or annotating definitions made somewhere else</li> <li>It's a driving force under many Web 2.0 features, like RSS</li> </ul> <p></p> <p>The dialect of RDF used in this module (even within this strict schema there are markup variations possible) is intended to resemble the (non-normative) examples found in the <a href="http://www.w3.org/TR/owl-guide/">W3C recommendations</a>, specifically the sample Wine Ontology [<a href="http://www.w3.org/TR/owl-guide/wine.rdf">RDF</a>].</p> <br /> Other target input sources include : <ul> <li><strong>supported:</strong> <a href="http://wordnet.princeton.edu/">The <a href="http://www.ontologyportal.org/translations/SUMO.owl.txt">OWL/RDF</a> port of the <strong>WordNet</strong> Lexicon</a> as discussed (but never usefully implimented) <a href="http://www.w3.org/2001/sw/BestPractices/WNET/wn-conversion.html">at the W3C</a>,</li> <li><strong>supported:</strong> <a href="http://www.w3.org/TR/wordnet-rdf/">The next generation Wordnet RDF 2.0 from the W3c</a> <a href="http://www.w3.org/2006/03/wn/wn20/schema/">http://www.w3.org/2006/03/wn/wn20/schema/</a> </li> <li><a href="http://www.ontologyportal.org/">SUMO - The Suggested Upper Merged Ontology</a></li> <li><strong>supported:</strong> <a href="http://www.icra.org/vocabulary/">ICRA Content Rating</a></li> </ul> <h3>Dependancies and capabilities</h3> <p>For RDF input parsing, we use a GPL library, ARC from appmosphere <a href="http://arc.semsol.org/">arc.semsol.org</a>. This is PHP4 compatible. RDF processing is seldom efficient, either in memory or time, so there may be difficulties with large imports.</p> <p>For RDF output <strong>creation</strong>, we use PHP5 XML/DOM functions <em>this makes RDF output incompatible with PHP4, which had very flaky XML functions</em>. If you are trying these use the Web2.0 features, you really must upgrade from the (now officially unsupported) PHP4, as this legacy support would drag development down. <br /> So the situation is, older unpatched servers can take advantage of the distributed RDF vocabularies, but cannot easily distribute their own.</p> <p>Author: Dan Morrison (dman) 2008 http://coders.co.nz</p> </body> </html>