Closed pernyga closed 2 years ago
Actually, you could just solve this more elegant just by adding a new flag to the validator settings:
settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
Assuming this xml snippet
xsi:schemaLocation="http://www.cbrain.dk/F2/Noark http://schema.cbrain.net/F2_Noark.xsd
http://www.arkivverket.no/standarder/noark5/arkivstruktur arkivstruktur.xsd
http://www.arkivverket.no/standarder/noark5/metadatakatalog metadatakatalog.xsd"
and by not statically loading the xsd as a stream to the validate method, then this solution would work for local available schemas as well as downloadable schemas.
All associations between xml and xml-schemas is supposed to be connected in the addml-file.
Shortened xml
<dataObject name="arkivstruktur">
<properties>
<property name="file">
<properties>
<property name="name">
<value>arkivstruktur.xml</value>
</property>
</properties>
</property>
<property name="schema">
<value>main</value>
<properties>
<property name="file">
<properties>
<property name="name">
<value>arkivstruktur.xsd</value>
</property>
</properties>
</property>
</properties>
</property>
<property name="schema">
<properties>
<property name="file">
<properties>
<property name="name">
<value>metadatakatalog.xsd</value>
</property>
</properties>
</property>
</properties>
</property>
</properties>
</dataObject>
Or more simplified
dataObject of xml-file
file-properties
"relative filepath"
schema-properties+
file-properties
"relative filepath"
Arkade5 has so far based the validation on hardcoded values. It will soon change to abide by the addml.
Did this explain it?
That would work also ;-)
Saken løst - ref. "Arkade5 has so far based the validation on hardcoded values. It will soon change to abide by the addml. Did this explain it?"
We have additional metadata in our arkivstruktur.xml, as specified in the schemaLocation attribute, eg.
xsi:schemaLocation="http://www.arkivverket.no/standarder/noark5/arkivstruktur arkivstruktur.xsd http://www.cbrain.dk/F2/Noark F2_Noark.xsd"
The current build of Arkade5 does not support this.
I have experimented with a minor change to fix this, but as I'm pretty new to Git I was hoping for someone to fix the issue. Below is a suggested code change in ValidateXmlWithSchema.cs:
Add this new method:
Modify ValidateXml metod
private void ValidateXml(string fullPathToFile, Stream fileStream, params Stream[] xsdResources) { string fileName = Path.GetFileName(fullPathToFile);