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
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") %>'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With