Camel xslt 组件,用于从给定的 xml 数据创建静态 sql 查询



我想使用 camel xslt 组件从 xml 数据创建一个 sql 查询。我尝试使用 xslt 组件使用 xsl 文件(从 xml 文件创建(创建 html 页面。但是没有足够的关于从驼峰xslt组件生成sql查询的信息。

我尝试的如下:

XML 数据:

<?xml version="1.0"?>
<?xml-stylesheet href="employee-sql.xsl" type="text/xsl" ?>
<Employees>
<employee>
<empName>Abc</empName>
<empAddress>Delhi</empAddress>
</employee>
</Employees>

员工-sql.xsl 文件:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0">
<xsl:template match="/" name="TemplateA">
<xsl:param name="param">
</xsl:param>
<xsl:value-of select="/Employees/employee" />
</xsl:template>
<xsl:template match="/">
<html>
<body>
<xsl:output method="xml" />
<xsl:template match="/"><xsl:apply-templates select="/Employees/employee" mode="normalize-space" /></xsl:template>
<xsl:template match="text()" mode="normalize-space"><xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="@*|node()" mode="normalize-space"><xsl:copy><xsl:apply-templates select="@*|node()" mode="normalize-space" /></xsl:copy></xsl:template>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

我在这里生成的xsl文件取自互联网资源。谁能告诉我如何创建 xsl 文件来生成 sql 查询(例如从 xml 数据中选择 * 从 xml 数据}

我认为最简单的方法是:

  1. 将输出从 XML 切换到文本

<xsl:output method="text"/>

  1. >使用 xpath concat 函数生成 SQL 语句:
<xsl:variable name="table_name" select="mytable">
<xsl:value-of select="concat('SELECT * FROM ', $table_name)" />

最新更新