开发者

How do I use include in an embedded xsd referencing another embedded xsd?

开发者 https://www.devze.com 2023-02-14 15:47 出处:网络
Inside my web application, I\'m validating Xml documents using xsd files as embedded resources, and that was easy using assembly.GetManifestResourceStream(string).

Inside my web application, I'm validating Xml documents using xsd files as embedded resources, and that was easy using assembly.GetManifestResourceStream(string).

I now need to use the include element (I actually need redefine, but the error I get is the开发者_如何学Go same, so I'm broadening the scope of the question) inside one of my xsd's referencing another embedded xsd, so what I did was:

  • add the following lines to the project's 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)]

  • modified the "include" element inside "ImportOperatoriParametri.xsd" into this:

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

This technique worked when I had to reference an embedded image from an embedded css. Sadly, here it does not, because the GetManifestResourceStream method throws the exception

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

It seems like the "PerformSubstition" attribute wasn't set, because it's trying to read the attribute of schemaLocation as a "regular" string.

What am I doing wrong? Thank you


Looks like you've incorrectly nested double-quotes in the attribute. Simplest would be to use single quotes for the outer pair.

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

精彩评论

暂无评论...
验证码 换一张
取 消