Buckminster rmap to p2 (composite) repository metadata

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"
    <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:when test="contains(bm:uri/@format, '?importType=binary')">
                            <child location="{substring-before(bm:uri/@format, '?importType=binary')}"/>
                            <child location="{bm:uri/@format}"/>

    <xsl:template match="/">

            <repository name='&quot;{$title}&quot;' type='{$type}' version='1.0.0'>

              <properties size='2'>
                <property name='p2.compressed' value='true'/>
                <property name='p2.timestamp' value='{$timestamp}'/>
                <child location='{$repository}'/>
                <!-- match all the child nodes of the template match=/ node -->



Want to comment? Send me an email to blog-comments-2018 at lemmster d.t de and I'll paste it here (I won't publish your address). Why don't you use an external comment service like disqus, you ask? Well, I like to keep this site under my control, comments included. You can use markdown to format your comment.