ECF has been using an rmap to b3aggr xslt stylesheet for a while now, and today I needed a similar stylesheet to convert to p2 composite repositories (single sourcing repositories feed from Buckminster to the p2 director). It takes an rmap and spits out composite repository metadata referring to all http:// and ftp:// provider uris in the rmap. For an example check out this rmap and the generated metadata. As a generator use
<div class="standard">xsltproc --stringparam timestamp $((`date +%s * 1000)) --stringparam
repository file:///a/local/p2/repo/ rmap2compositeRepository.xsl my.rmap</div>
In case anybody else needs it, here is the xslt stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bm="http://www.eclipse.org/buckminster/RMap-1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<!-- overwrite via parameters -->
<xsl:param name="repository">file:///dev/null</xsl:param>
<xsl:param name="title">vogella Packages Repository</xsl:param>
<xsl:param name="timestamp">13691573970000</xsl:param>
<xsl:param name="type">org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository</xsl:param>
<xsl:template match="bm:provider">
<!-- only accept public http|ftp repositories -->
<xsl:if test="starts-with(bm:uri/@format, 'http://') or starts-with(bm:uri/@format, 'ftp://')">
<!-- remove dangling ?importType=binary -->
<xsl:choose>
<xsl:when test="contains(bm:uri/@format, '?importType=binary')">
<child location="{substring-before(bm:uri/@format, '?importType=binary')}"/>
</xsl:when>
<xsl:otherwise>
<child location="{bm:uri/@format}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="/">
<repository name='"{$title}"' type='{$type}' version='1.0.0'>
<properties size='2'>
<property name='p2.compressed' value='true'/>
<property name='p2.timestamp' value='{$timestamp}'/>
</properties>
<children>
<child location='{$repository}'/>
<!-- match all the child nodes of the template match=/ node -->
<xsl:apply-templates/>
</children>
</repository>
</xsl:template>
</xsl:stylesheet>