2012-02-16 54 views
0

我有一組模式,我試圖用它來驗證使用Nokogiri的XML文檔。導入使用原始名稱空間導入另一個模式的模式

我有一個名爲空間http://example.com/root的頂級架構。它導入另一個模式Extension.xsd,其名稱空間爲http://example.com/extension,幷包含模式Types.xsd(顯然其名稱空間爲http://example.com/root)。

Extension.xsd模式使用名稱空間http://example.com/extension導入模式Types.xsd,命名空間爲http://example.com/root

當我嘗試讓Nokogiri加載根架構時,它會投訴 - Element import: The schema document Types.xsd cannot be imported, since it was already included or redefined

當我擺脫Extension.xsd文件中的導入語句時,Nokogiri說不允許引用命名空間http://example.com/root,因爲沒有導入任何內容。 當我擺脫根模式文件中的include語句時,Nokogiri說,來自Types.xsd的根模式中使用的元素不會解析爲元素聲明。

任何想法如何讓Nokogiri接受這種模式結構?這甚至是有效的模式?

回答

1

在模式中使用循環xs:import聲明是完全有效的,事實上,正如本例所示,它通常是必需的。我不知道Nokogiri,所以我不知道是否有修復。

相關問題