【发布时间】:2011-02-13 16:48:23
【问题描述】:
您好!
我想通过 document 函数从 XSLT 中的不同 Maven POM 中提取一些属性。脚本本身工作正常,但只要我在 xmlns="http://maven.apache.org/POM/4.0.0"项目标签。如果我删除它,一切正常。
知道如何在将 xmlns 属性保留在其所属的位置时使其工作,或者为什么这不适用于该属性?
下面是我的 XSLT 的相关部分:
<xsl:template match="abcs">
<xsl:variable name="artifactCoordinate" select="abc"/>
<xsl:choose>
<xsl:when test="document(concat($artifactCoordinate,'-pom.xml'))">
<abc>
<ID><xsl:value-of select="$artifactCoordinate"/></ID>
<xsl:copy-of select="document(concat($artifactCoordinate,'-pom.xml'))/project/properties"/>
</abc>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
Transformation failed: POM "<xsl:value-of select="concat($artifactCoordinate,'-pom.xml')"/>" doesn't exist.
</xsl:message>
</xsl:otherwise>
</xsl:choose>
为了完整起见,还有一个带有“bad”属性的 POM 提取:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ... -->
<properties>
<proalpha.version>[5.2a]</proalpha.version>
<proalpha.openedge.version>[10.1B]</proalpha.openedge.version>
<proalpha.optimierer.version>[1.1]</proalpha.optimierer.version>
<proalpha.sonic.version>[7.6.1]</proalpha.sonic.version>
</properties>
</project>
【问题讨论】:
-
好问题 (+1)。有关问题的解释和最常用的解决方案,请参阅我的答案。 :)