目前,我试图找出如何使用XSL(xalan的2.7.1)插入一个新的服务器证书发送到行家的settings.xml。我的问题是,输出XML总是在他的标签的空xmlns=""
元件,它的Maven不喜欢!XML插入产生的xmlns条目输出XML
那是基本的XML:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<!-- Server Credentials -->
<servers>
</servers>
</settings>
我的XSL:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mvn="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xslt="http://xml.apache.org/xslt"
exclude-result-prefixes="mvn xsl xslt">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" xslt:indent-amount="4" />
<xsl:param name="server.id" />
<xsl:param name="server.username" />
<xsl:param name="server.password" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="mvn:servers">
<xsl:copy>
<xsl:apply-templates />
<server>
<id>
<xsl:value-of select="$server.id" />
</id>
<username>
<xsl:value-of select="$server.username" />
</username>
<password>
<xsl:value-of select="$server.password" />
</password>
</server>
</xsl:copy>
</xsl:template>
在改造结束后,它看起来像这样:
<!-- Server Credentials -->
<servers>
<server xmlns="">
<id>nexus-nbg</id>
<username>testuser</username>
<password>{PMjrq7GDvwgH4xBziBIjb71GZSlgovs6D85zXogvP9I=}</password>
</server>
</servers>
所以它插入一个空的xmlns
-Maag不喜欢的标签并打印一些警告。也是第一个server
-Tag也有错误的缩进?!所以我已经映射的命名空间,从而使匹配的作品,我也包括exlude-result-prefixes
我都还能做什么?
会很高兴,如果有人在这里长谷的想法!
最良好的祝愿,
丹尼尔