2011-03-04 122 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