如何在引用另一个嵌入式xsd的嵌入式xsd中使用include?

Pid*_*ddu 5 c# xsd embedded-resource

在我的Web应用程序中,我使用xsd文件作为嵌入式资源来验证Xml文档,这很容易使用assembly.GetManifestResourceStream(string).

我现在需要使用该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"中的"include"元素修改为:

    <xs:include schemaLocation="<% = WebResource("TurniArc.xml.schema.ProcessiInput.xsd") %>">
    
    Run Code Online (Sandbox Code Playgroud)

当我不得不从嵌入式CSS引用嵌入图像时,这种技术很有用.遗憾的是,这里没有,因为GetManifestResourceStream方法抛出异常

'<', hexadecimal value 0x3C, is an invalid attribute character. Line 3, position 34.
Run Code Online (Sandbox Code Playgroud)

似乎没有设置"PerformSubstition"属性,因为它试图将schemaLocation的属性读作"常规"字符串.

我究竟做错了什么?谢谢

xan*_*xan 1

看起来您在属性中错误地嵌套了双引号。最简单的方法是对外部对使用单引号。

<xs:include schemaLocation='<% = WebResource("TurniArc.xml.schema.ProcessiInput.xsd") %>'>
Run Code Online (Sandbox Code Playgroud)