我需要验证XML和XSD不是很容易接受(默认值使用太多xsd:序列和技巧与xsd:选择使验证太可接受(不确定这是正确的词))
那么,有没有好转的方法
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
进入这个
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="cooking">
<title lang="en"></title>
<author></author>
<year></year>
<price></price>
</book>
<book category="children">
<title lang="en"></title>
<author></author>
<year></year>
<price></price>
</book>
<book category="web">
<title lang="en"></title>
<author></author>
<year></year>
<price></price>
</book>
</bookstore>
在带有python / java / go的windows上?它不是一次性工作,我需要自动完成
答案 0 :(得分:1)
用于XML转换的正确工具是XSLT。这个很容易。在XSLT 3.0中它是
java net.sf.saxon.Transform -s:in.xml -xsl:trans.xsl -o:out.xml
你说Java解决方案没问题,所以下载Saxon-HE 9.8并将其作为
运行xsl:mode
如果您更喜欢使用XSLT 1.0或2.0处理器,则可以使用身份模板规则替换SELECT TOP(1) WITH TIES
id,
version,
dt_create = timestamp
FROM [version_history]
ORDER BY ROW_NUMBER() OVER (PARTITION BY id ORDER BY version desc, timestamp)
声明,该规则很容易用Google搜索。