的XSLT输出我有一个大的XML文档,看起来像这样:产生特定顺序
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<aTable>
<aTableRow Col1="1" Col2="someText"/>
<aTableRow Col1="2" Col2="newText"/>
...
</aTable>
<anotherTable>
<anotherTableRow Col3="someText" Col4="42"/>
<anotherTableRow Col3="myText" Col4="34"/>
...
</anotherTable>
...
</Data>
我需要在SQL INSERT语句中的对应序列转换文档。喜欢的东西:
INSERT INTO aTable (Col1, Col2) VALUES (1, "someText")
我已经从一个“表”到相应的SQL语句的转变,但在文档的同一顺序生成XSLT输出。
有没有办法在aTable之前有另一个例子anotherTable?
编辑
感谢您的意见和答复。读他们我意识到我原来的问题不是很清楚。我会尝试添加更多细节。
我已经生成了一个模板,可以在插入语句序列中正确转换xml数据,假设这个模板名为“insertGeneration”。
然后我写的东西,如:
<xsl:template match="Data/anotherTable">
<xsl:call-template name="insertGeneration"
</xsl:template>
<xsl:template match="Data/aTable">
<xsl:call-template name="insertGeneration"
</xsl:template>
我预计在这个顺序来生成的输出,即所有INSERT INTO aTable
之前的所有INSERT INTO anotherTable
。但结果顺序与源文档相同。
我需要一个特定的顺序,否则我可能会违反执行SQL脚本时的外键约束。
我的XSLT处理器是Visual Studio 2005的嘛,没有正确紧凑XSLT处理器;-)
这将有助于看到您目前的转变。 – hielsnoppe