How to use include in embedded xsd referencing another embedded xsd?

Inside my web application, I check Xml documents using xsd files as embedded resources, and this was easy with assembly.GetManifestResourceStream(string).

Now I need to use an element include(I really need it redefine, but the error I get is the same, so I am expanding the scope of the question) inside one of my xsd referencing another built-in xsd, so I did:

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

  • changed the "include" element inside "ImportOperatoriParametri.xsd" to the following:

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

This method worked when I had to refer to an inline image from inline css. Unfortunately, this is not the case here because the GetManifestResourceStream method throws an exception

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

It seems that the "PerformSubstition" attribute has not been set because it is trying to read the schemaLocation attribute as a "regular" string.

What am I doing wrong? Thanks you

+5
source share
1 answer

It looks like you entered the double quotes in the attribute incorrectly. The easiest way would be to use single quotes for the outer pair.

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

All Articles