forked from masagroup/soft.gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpom.xslt
42 lines (36 loc) · 1.44 KB
/
pom.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<xsl:stylesheet version="3.0"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:pom="http://maven.apache.org/POM/4.0.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="artifactId"/>
<xsl:param name="version"/>
<xsl:template match="/">
<xsl:variable name="inputs"
select="collection(iri-to-uri('.?select=pom.xml;recurse=yes'))"
as="document-node()*"/>
<xsl:for-each select="$inputs">
<xsl:variable name="uri" select="document-uri()"/>
<xsl:result-document href="{$uri}">
<xsl:apply-templates mode="inPom" select="@*|node()"/>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<!--identity template copies everything forward by default-->
<xsl:template match="node()|@*" mode="inPom">
<xsl:copy>
<xsl:apply-templates mode="inPom" select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="pom:version/text()" mode="inPom">
<xsl:choose>
<xsl:when test="../../pom:artifactId = $artifactId">
<xsl:value-of select="$version"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>