我尝试在nodejs上使用JSONIX并使用AJV验证传入的XML。
通常我会使用这样的东西:
News.xml:
<news xmlns="http://news24.tt/news">
<publisher>
<author>Max Mustermann</author>
<company>NEWS24</company>
<resort>Sports</resort>
</publisher>
<topic>HSV wins against FCB!</topic>
<article>Bla bla ... </article>
</news>
但现在我将使用此
Author.xml:
<publisher xmlns="http://news24.tt/news">
<author>Max Mustermann</author>
<company>NEWS24</company>
<resort>Sports</resort>
</publisher>
News.xml:
<news xmlns="http://news24.tt/news" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="Author.xml" />
<topic>HSV wins against FCB!</topic>
<article>Bla bla ... </article>
</news>
是否可以使用JSONIX和AJV来验证这些结构? 我甚至有一个XSD和生成的JSON-Schema。
亲切的问候
马库斯
答案 0 :(得分:0)
Jsonix目前不支持xi:include
。尽管如此但并非未实现,这并非不可能。因此,AJV也无法做任何事情,因为它在JS对象级别上验证,而不是在XML上验证。
免责声明我是Jsonix的作者。