是否有一个开源命令行工具(用于Linux)来区分忽略元素顺序的XML文件?
示例输入文件a.xml:
<tag name="AAA">
<attr name="b" value="1"/>
<attr name="c" value="2"/>
<attr name="a" value="3"/>
</tag>
<tag name="BBB">
<attr name="x" value="111"/>
<attr name="z" value="222"/>
</tag>
<tag name="BBB">
<attr name="x" value="333"/>
<attr name="z" value="444"/>
</tag>
Run Code Online (Sandbox Code Playgroud)
b.xml:
<tag name="AAA">
<attr name="a" value="3"/>
<attr name="b" value="1"/>
<attr name="c" value="2"/>
</tag>
<tag name="BBB">
<attr name="z" value="444"/>
<attr name="x" value="333"/>
</tag>
<tag name="BBB">
<attr name="x" value="111"/>
<attr name="z" value="222"/>
</tag>
Run Code Online (Sandbox Code Playgroud)
因此,比较这两个文件不应该输出任何差异.我试图先用XSLT对文件进行排序:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="WINDOWS-1252" omit-xml-declaration="no" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy> …Run Code Online (Sandbox Code Playgroud) 假设我有一个包含大量记录(> 100'000)的表 A 和一个与 A 具有相同列和大约相同数据量的表 B。是否有可能通过一个聪明的选择语句,我可以获得表 A 的所有记录或表 B 的所有记录?
由于性能,我对我目前使用的方法不太满意:
select
column1
,column2
,column3
from (
select 'A' as tablename, a.* from table_a a
union
select 'B' as tablename, b.* from table_b b
) x
where
x.tablename = 'A'
Run Code Online (Sandbox Code Playgroud) 我想检查XSLT是否存在HTML文件.我怎样才能做到这一点?我已经从这里https://gist.github.com/emth/4531924尝试了file-exist.xsl,但它对我不起作用.我一直试图让它运行超过2个小时,但我被卡住了.这是我的蚂蚁片段:
<target name="transform">
<xslt in="/tmp/sample.xml" out="/tmp/out.html" style="/tmp/sample.xsl" />
</target>
Run Code Online (Sandbox Code Playgroud)
这是我的xslt文件:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:java="http://www.java.com/">
<xsl:import href="file-exists.xsl"/>
...
<xsl:if test="java:file-exists('myfile.html', base-uri())">
<!-- do something here... -->
</xsl:if>
....
Run Code Online (Sandbox Code Playgroud)
用ant运行它会得到以下错误:
[xslt] Processing /tmp/sample.xml to /tmp/out.html
[xslt] Loading stylesheet /tmp/sample.xsl
[xslt] : Error! The first argument to the non-static Java function 'fileExists' is not a valid object reference.
[xslt] : Error! Cannot convert data-type 'void' to 'boolean'.
[xslt] : Fatal Error! Could not compile stylesheet
[xslt] Failed to process …Run Code Online (Sandbox Code Playgroud) ant ×1
command-line ×1
db2 ×1
diff ×1
open-source ×1
select ×1
sorting ×1
sql ×1
xml ×1
xslt ×1