Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 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

like image 805
Piddu Avatar asked Nov 15 '22 02:11

Piddu


1 Answers

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") %>'>
like image 174
xan Avatar answered Dec 15 '22 12:12

xan