By default, when an Extension Element is found it is represented as a generic extension. This is complete, but rather verbose, and it doesn’t represent the information very semantically.
By defining some <xslt:template> elements in
an XSLT file, and then importing the
atom2rdf-16.xsl you can override the default
behaviour and implement custom serialization for specific
extensions.
There are 4 modes for extension handling:
-
genericis the style described previously. It creates an atomrdf:Extension resource which contains information about the extension. -
passthroughis a style suitable for Simple Extension Elements, or RDF-based extensions. It simply treats namespaceUri+name of the element as the RDF property, and the text content of the property as the property value. -
pluginimplements pluggable extensions. These allow the behaviour of the extension to be defined in XSLT. It is described below. -
Finally,
bothimplements bothgenericandplugin.
Setting the extension mode
To change the extension mode from the default, ‘generic’, define a template such as the one below. The mode element must be ‘query-pluggable-extension’, the match element must match the extension element, and the content of the element should be the word: ‘generic’, ‘passthrough’, ‘plugin’, or ‘both’:
<xsl:template mode="query-pluggable-extension" match="wfw:comment">plugin</xsl:template>
Pluggable Extensions
To implement a pluggable extension define a ‘query-pluggable-extension’ template as described above, setting the mode to ‘plugin’, and define a ‘pluggable-extension’ template which outputs the required XML:
<xsl:template mode="pluggable-extension" match="wfw:comment">
<wfw:comment rdf:resource="{normalize-space(text())}" />
</xsl:template>
Pluggable extensions have some benefits, and some disadvantages. They do make the RDF output more semantic, but then they also make it harder to roundtrip the RDF back to Atom, which is why the ‘both’ option exists.
RSS 1.0
Atom/RDF also supports RSS. If you use an RSS 1.0 file as input, then the default behaviour for extensions is ‘passthrough’ rather than ‘generic’.