<xs:schema xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" >
<xs:include schemaLocation="voc.xsd"/>
<xs:annotation>
<xs:documentation>
Generated by $Id: v3dt-schema.xsl,v 1.5 2005/05/24 05:44:38 lmckenzi Exp $
</xs:documentation>
</xs:annotation>
<xs:complexType name="ANY" abstract="true">
<xs:annotation>
<xs:documentation>
Defines ...
</xs:documentation>
</xs:annotation>
<xs:attribute name="nullFlavor" type="NullFlavor" use="optional">
<xs:annotation>
<xs:documentation>
An exceptional value expressing missing information
and possibly the reason why the information is missing.
</xs:documentation>
</xs:annotation>
</xs:attribute>
Ошибка при загрузке xsd схемы, Не распознаётся тип.
Вот пример кода:
Код:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private string TheXml;
private string TheXsd;
private string Outcome;
private string Output;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Outcome = "<font color=\"green\">Succeeded</font>";
Output = "";
//load schema
XmlSchemaCollection xsc = new XmlSchemaCollection();
try
{
xsc.Add("urn:hl7-org:v3", TheXsd);
Validate(TheXml, xsc);
}
catch (Exception ex)
{
richTextBox1.Text = ex.ToString();
}
}
private void Validate(String filename, XmlSchemaCollection xsc)
{
XmlTextReader reader = null;
XmlValidatingReader vreader = null;
reader = new XmlTextReader(filename);
vreader = new XmlValidatingReader(reader);
vreader.Schemas.Add(xsc);
vreader.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
try
{
while (vreader.Read()) { }
}
catch
{
Output = "XML Document is not well-formed.";
}
vreader.Close();
}
public void ValidationCallBack(object sender, ValidationEventArgs args)
{
Outcome = "<font color=\"red\">Failed:</font>";
Output += "Validation error: <font color=\"red\">" + args.Message + "</font><br>";
}
private void Form1_Load(object sender, EventArgs e)
{
TheXml = @"Sample.xml";
TheXsd = @":\coreschemas\infrastructureRoot.xsd";
Outcome = "";
}
}
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private string TheXml;
private string TheXsd;
private string Outcome;
private string Output;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Outcome = "<font color=\"green\">Succeeded</font>";
Output = "";
//load schema
XmlSchemaCollection xsc = new XmlSchemaCollection();
try
{
xsc.Add("urn:hl7-org:v3", TheXsd);
Validate(TheXml, xsc);
}
catch (Exception ex)
{
richTextBox1.Text = ex.ToString();
}
}
private void Validate(String filename, XmlSchemaCollection xsc)
{
XmlTextReader reader = null;
XmlValidatingReader vreader = null;
reader = new XmlTextReader(filename);
vreader = new XmlValidatingReader(reader);
vreader.Schemas.Add(xsc);
vreader.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
try
{
while (vreader.Read()) { }
}
catch
{
Output = "XML Document is not well-formed.";
}
vreader.Close();
}
public void ValidationCallBack(object sender, ValidationEventArgs args)
{
Outcome = "<font color=\"red\">Failed:</font>";
Output += "Validation error: <font color=\"red\">" + args.Message + "</font><br>";
}
private void Form1_Load(object sender, EventArgs e)
{
TheXml = @"Sample.xml";
TheXsd = @":\coreschemas\infrastructureRoot.xsd";
Outcome = "";
}
}
}
часть хсд схемы которая загружает другую:
Код:
вот что загружает voc.xsd
Код:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mif="urn:hl7-org:v3/mif">
....
<xs:simpleType name="NullFlavor">
<xs:annotation>
<xs:documentation>vocSet: D10609 (C-0-D10609-cpt)</xs:documentation>
</xs:annotation>
<xs:union memberTypes="NoInformation">
<xs:simpleType>
<xs:restriction base="cs">
<xs:enumeration value="NP"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="NoInformation">
<xs:annotation>
<xs:documentation>specDomain: V10610 (C-0-D10609-V10610-cpt)</xs:documentation>
</xs:annotation>
<xs:union memberTypes="Other Unknown">
<xs:simpleType>
<xs:restriction base="cs">
<xs:enumeration value="NI"/>
<xs:enumeration value="MSK"/>
<xs:enumeration value="NA"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="Other">
<xs:annotation>
<xs:documentation>specDomain: V10616 (C-0-D10609-V10610-V10616-cpt)</xs:documentation>
</xs:annotation>
<xs:restriction base="cs">
<xs:enumeration value="OTH"/>
<xs:enumeration value="NINF"/>
<xs:enumeration value="PINF"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Unknown">
<xs:annotation>
<xs:documentation>specDomain: V10612 (C-0-D10609-V10610-V10612-cpt)</xs:documentation>
</xs:annotation>
<xs:union memberTypes="AskedButUnknown">
<xs:simpleType>
<xs:restriction base="cs">
<xs:enumeration value="UNK"/>
<xs:enumeration value="NASK"/>
<xs:enumeration value="TRC"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
....
....
<xs:simpleType name="NullFlavor">
<xs:annotation>
<xs:documentation>vocSet: D10609 (C-0-D10609-cpt)</xs:documentation>
</xs:annotation>
<xs:union memberTypes="NoInformation">
<xs:simpleType>
<xs:restriction base="cs">
<xs:enumeration value="NP"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="NoInformation">
<xs:annotation>
<xs:documentation>specDomain: V10610 (C-0-D10609-V10610-cpt)</xs:documentation>
</xs:annotation>
<xs:union memberTypes="Other Unknown">
<xs:simpleType>
<xs:restriction base="cs">
<xs:enumeration value="NI"/>
<xs:enumeration value="MSK"/>
<xs:enumeration value="NA"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="Other">
<xs:annotation>
<xs:documentation>specDomain: V10616 (C-0-D10609-V10610-V10616-cpt)</xs:documentation>
</xs:annotation>
<xs:restriction base="cs">
<xs:enumeration value="OTH"/>
<xs:enumeration value="NINF"/>
<xs:enumeration value="PINF"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Unknown">
<xs:annotation>
<xs:documentation>specDomain: V10612 (C-0-D10609-V10610-V10612-cpt)</xs:documentation>
</xs:annotation>
<xs:union memberTypes="AskedButUnknown">
<xs:simpleType>
<xs:restriction base="cs">
<xs:enumeration value="UNK"/>
<xs:enumeration value="NASK"/>
<xs:enumeration value="TRC"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
....
Вопрос, почему не загружается voc , хотя находятся в одном каталоге