377.6. 使用 xsl:include
Camel 2.2 或更早的
如果您使用 xsl:include
在 Camel 2.2 或更早的 XSL 文件中包括,则会使用默认的 javax.xml.transform.URIResolver
。文件将相对于 JVM 启动文件夹解析。
例如,以下 include 语句将从启动应用的文件夹中查找 staff_template.xsl
文件。
<xsl:include href="staff_template.xsl"/>
Camel 2.3 或更高版本
用于 Camel 2.3 或更新版本,提供自己的 URIResolver
实施。这允许 Camel 从 classpath 中加载已包含的文件。
例如,以下代码中的 include 文件将相对于起始端点。
<xsl:include href="staff_template.xsl"/>
这意味着 Camel 将在 classpath 中找到文件为 org/apache/camel/component/xslt/staff_template.xsl
您可以使用 classpath:
或 file:
来指示 Camel 在 classpath 或文件系统中查找。如果省略前缀,则 Camel 将使用端点配置中的前缀。如果在端点配置中没有指定前缀,则默认值为 classpath:
您还可以在包括路径中引用后向后的内容。在以下示例中,xsl 文件将在 org/apache/camel/component
下解决。
<xsl:include href="../staff_other_template.xsl"/>