From Atom 1.0 to RDF by XSLT
Atom Syndication Format 1.0で記述されたフィードを、XSLTによってRDFに変換する実験です。
This is an experiment to transfer an Atom Syndication Format 1.0 feed to an RDF graph by an XSLT style sheet.
XSLT
テスト用XSLTスタイルシート atom2rdf.xsl は、主として次のような変換を試みます。
- AtomのXML構文をRDFのトリプルとして解釈できるようにするために、いくつかの要素にrdf:parseType="Resource"属性を追加します。atom:entryについては、子要素にrss:itemを追加して内容を包含し、明示的にノード要素をつくります。
- link要素は、- rel属性の値などに応じて、- feedや- item要素の- rdf:aboutとしたり、- rel属性値をプロパティ名として扱います。
- type属性を持つ要素は、その値に応じてXMLLiteralとして扱ったり、外部リソースへのリンクとして扱います。
- atom:generatorはプロパティとみなせる属性とテキスト内容の両方を持つため、内容を- rdf:value属性の値として変換します。
- 出力するRDFでは、Atomの名前空間の末尾に#を加えます。
Atomの語彙は(atom:feedを除いて)基本的にプロパティとして扱い、ノードの型にはRSS1.0などの語彙を充てています。
The XSLT style sheet atom2rdf.xsl will perform the following transformation (See the style sheet for detailed comment).
- Add rdf:parseType="Resource"to some atom elements. Especially,rss:itemwill be added as child node ofatom:entryso as to construct a nice RDF triple.
- atom:linkelements will be transformed to- rdf:aboutof parent node, or to a property element with- relattribute value for its name, according to the context.
- Each element with typeattribute will be treated as plain literal, XMLLiteral or external link accordingly.
- atom:generatorhas both text content and property attributes that violates RDF. Thus its text content will be transformed to- rdf:valueattribute.
- Output atom: namespace URI will be concatinated '#'.
All Atom 1.0 terms (except atom:feed) are regarded as property, and some RSS 1.0 classes are used to give a type to nodes.
Test cases
Atom WikiのKnownAtomFeedsに掲載されているいくつかのAtom1.0フィードを、W3CのXSLTサービスを利用してこのXSLTでRDFに変換し、RDF Validatorで確認してみます。ひととおり、うまく行っていると思われます。
Here some 30 Atom 1.0 feeds listed on KnownAtomFeeds will be transformed to RDF graphs with this XSLT, via W3C's service, and validated with RDF Validator.
All of above transformed RDF's are valid as of 2005-07-26T12:00+09:00.
Related Works
- Quantifying the "RDF tax" by Sam Ruby (2003-08-13) and its XSLT
- Should Atom Use RDF? by Mark Pilgrim for xml.com (2003-08-20) that mentioned another XSLT
- Proof-of-concept RDF mapping for Atom by David Powell for Atom Syntax ML (2005-01-28)
- XmlAndRdf from Atom Wiki
- AtomRdf from ESW Wiki
- Atom-and-RDF Samples by Dan Brickley



