2011-03-04 116 views
5

在我的web應用程序中,我使用xsd文件作爲嵌入式資源來驗證xml文檔,使用assembly.GetManifestResourceStream(string)很容易。如何在嵌入式xsd中使用include引用另一個嵌入式xsd?

我現在需要使用include元素(其實我需要redefine,但我得到的錯誤是一樣的,所以我擴大問題的範圍)內我的xsd的一個引用另一個嵌入的XSD,還等什麼我所做的是:

  • 以下行添加到項目的AssemblyInfo.cs中

    [assembly: System.Web.UI.WebResource("TurniArc.xml.schema.ImportOperatoriParametri.xsd", "text/xml", PerformSubstitution = true)]

    [assembly: System.Web.UI.WebResource("TurniArc.xml.schema.ProcessiInput.xsd", "text/xml", PerformSubstitution = true)]

  • 修飾的「ImportOperatoriParametri.xsd」內的「包含」的元素插入此:

    <xs:include schemaLocation="<% = WebResource("TurniArc.xml.schema.ProcessiInput.xsd") %>"> 
    

這種技術工作時,我不得不從嵌入式CSS參考的嵌入圖像。可悲的是,這裏沒有,因爲GetManifestResourceStream方法拋出異常

'<', hexadecimal value 0x3C, is an invalid attribute character. Line 3, position 34. 

這似乎是「PerformSubstition」屬性還沒有設置,因爲它試圖讀取的schemaLocation的屬性爲「正規」的字符串。

我在做什麼錯?謝謝

+0

+1非常有用,也是重要的問題。 – 2011-03-07 00:03:55

回答

1

看起來你在屬性中錯誤地嵌套了雙引號。最簡單的方法是使用單引號作爲外部對。

<xs:include schemaLocation='<% = WebResource("TurniArc.xml.schema.ProcessiInput.xsd") %>'> 
+0

你是對的,我錯過了,但它仍然不能用單引號在內部或外部 – Piddu 2011-03-07 08:26:58

+0

噢 - 相同的錯誤信息? – xan 2011-03-07 21:51:11

+0

同樣的錯誤信息(爲什麼評論必須至少有15個字符長?:-)我本來可以用簡單的回答是) – Piddu 2011-03-08 09:41:25