【发布时间】:2012-12-24 21:36:01
【问题描述】:
我有问题。我想将两个 XML 文件的上下文合二为一。这在 MAVEN 项目 (POM) 和 XSL 中的 xslt-generator-maven-plugin 的帮助下。
我的 pom 配置如下:
<plugin>
<groupId>net.sf.xsltmp</groupId>
<artifactId>xslt-generator-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>transform-contex</id>
<goals>
<goal>many-to-one</goal>
</goals>
<configuration>
<srcDir>src/main/webapp/META-INF/</srcDir>
<srcIncludes>**/*context.xml</srcIncludes>
<xslTemplate>src/main/webapp/Temp.xsl</xslTemplate>
<destFile>${project.build.directory}/contextNEW.xml</destFile>
</configuration>
</execution>
</executions>
</plugin>
我有第一个文件,例如:
<?xml version="1.0" encoding="UTF-8"?>
<Context debug="0" reloadable="true" >
<Resourcen name="jdbc/ChiDS"
auth="Container"
type="javax.sql.DataSource"
...
</Context>
第二个喜欢:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Realm className="org.apache.catalina.realm.MemoryRealm"
pathname="webapps/${application.name}/WEB-INF/users.xml"/>
</Context>
并且想得到:
<?xml version="1.0" encoding="UTF-8"?>
<Context debug="0" reloadable="true" >
<Resourcen name="jdbc/ChiDS"
auth="Container"
type="javax.sql.DataSource"
...
<Realm className="org.apache.catalina.realm.MemoryRealm"
pathname="webapps/${application.name}/WEB-INF/users.xml"/>
</Context>
所以我会将第二个 XML 附加到第一个。我需要创建一个正确的 TEMP.xsl 文件。
我“需要”使用以下内容:
- xslt-generator-maven-plugin
我试过了,但标记化是个问题。
<xsl:output method="xml" indent="yes"/>
<xsl:param name="source-file-names" />
<xsl:variable name="names-sequence" select="tokenize($source-file-names,'\|')" />
<xsl:variable name="cfg-files" select="document($names-sequence)" />
有什么线索吗?我尝试了几件事,但没有解决这个问题。
感谢您的帮助。
我已尝试使用此 XSL(我修复了令牌问题)但没有成功:
<xsl:output method="xml" indent="yes"/>
<xsl:param name="source-file-names" />
<xsl:variable name="names-sequence" select="fn:tokenize($source-file-names,'\|')" />
<xsl:variable name="cfg-files" select="document($names-sequence)" />
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="$cfg-files/*"/>
</xsl:copy>
</xsl:template>
我看过这个样本:https://github.com/ivos/xslt-generator-maven-plugin/issues/1 但我这边没有成功。
欢迎任何帮助。 :)
【问题讨论】: