How do XML Schema namespaces map to C# class namespaces? - c#

For an XSD document such as this, say I was to create a C# class using some tool like xsd.exe or xsd2code, How do I define the namespace each class belongs to? Or do they all belong to only one namespace?
?xml version="1.0" encoding="UTF-8"?><xsd:schema targetNamespace="http://com.ibm.wbit.comptest.controller"
xmlns:Q1="http://com.ibm.wbit.comptest.controller" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="TestResults">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="testSuites" type="Q1:TestSuiteRun"/>
</xsd:sequence>
<xsd:attribute name="testProject" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="TestSuiteRun">
<xsd:complexContent>
<xsd:extension base="Q1:TestRun">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="testCases" type="Q1:TestCaseRun">
</xsd:element>
</xsd:sequence>
<xsd:attribute name="tests" type="xsd:int"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="TestCaseRun">
<xsd:complexContent>
<xsd:extension base="Q1:TestRun">
<xsd:sequence>
<xsd:element name="result" type="Q1:Severity"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="variations" type="Q1:VariationRun">
</xsd:element>
</xsd:sequence>
<xsd:attribute name="variationCount" type="xsd:int"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="VariationRun">
<xsd:complexContent>
<xsd:extension base="Q1:TestRun">
<xsd:sequence>
<xsd:element name="result" type="Q1:Severity"/>
<xsd:element name="exception" nillable="true" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
This element is used to display the exception of a failure or error.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:simpleType name="Severity">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="pass"/>
<xsd:enumeration value="fail"/>
<xsd:enumeration value="error"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="TestRun">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="startTime" type="xsd:dateTime"/>
<xsd:attribute name="endTime" type="xsd:dateTime"/>
<xsd:attribute name="result" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>

Related

When adding Schema to XmlSchemaSet, I get an exception

I have this XSD I made
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:complexType name="FunnyType">
<xsd:element name="Prueba1" type="xsd:string"/>
<xsd:element name="Prueba2" type="xsd:int"/>
</xsd:complexType>
<xsd:element name="Funnys">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="funny" type="FunnyType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Which gives me a System.Xml.Schema.XmlSchemaException: 'http://www.w3.org/2001/XMLSchema:element' is invalid in this context. (not the exact error, I translated it from spanish).
I have gone up and down everywhere (here, asking colleagues, etc) and made changes to the file, yet I cannot find the error.
What am I lacking here that makes c# throw an exception?
Thank you
You can't have this:
<xsd:complexType name="FunnyType">
<xsd:element name="Prueba1" type="xsd:string" />
<xsd:element name="Prueba2" type="xsd:int" />
</xsd:complexType>
You have to begin the complexType with one of the 3 compositors: xsd:sequence, xsd:all or xsd:choice:
For example:
<xsd:complexType name="FunnyType">
<!-- Can also be xsd:all or xsd:choice -->
<xsd:sequence>
<xsd:element name="Prueba1" type="xsd:string" />
<xsd:element name="Prueba2" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
You need to decide which one to use that best suits what your complex type is meant to model.

How to make either of the fields mandatory in XML schema

I have a requirement like either ParcelNumber or co-ordinates like CoordinateX or CoordinateY mandatory and these two contains different hierarchy in XML . So if the input xml contains parcel number it should return success or if it contains both co-ordinates, then it should return success.I created following schema ,and it will return success if i send only parcel number, but if i send Co-ordinates it will fail ,it is asking to send parcel number which is wrong.How to achieve it.In Nutshell i have following question
1>If i send both coordinates and no parcel number it should return success
2>IF i send x coordinate then it should fail and ask to send Y co ordinate
Following is what i have done so far
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified" elementFormDefault="qualified">
<xsd:element name="NOCPlantMapRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Applicationtype" minOccurs="0" type="xsd:string"/>
<xsd:element name="RelatedNOCRefNumber" minOccurs="0" type="xsd:string"/>
<xsd:element name="WorkLocation" minOccurs="1" maxOccurs="1" type="LocationType"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="LocationType">
<xsd:all>
<xsd:element name="ParcelNumber" type="ParcelNumberType" maxOccurs="1"/>
<xsd:element name="WorkArea" type="WorkAreaType" maxOccurs="1"/>
<xsd:element name="Roads" type="RoadListType" maxOccurs="1"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="RoadListType">
<xsd:sequence>
<xsd:element name="WorkLocationRoad" type="WorkLocationRoadType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="WorkLocationRoadType">
<xsd:sequence>
<xsd:element name="RoadName" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CommunitiesListType">
<xsd:sequence>
<xsd:element name="WorkLocationRoad" type="WorkLocationRoadType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="ParcelNumberType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:complexType name="WorkAreaType">
<xsd:sequence>
<xsd:element name="WorkArea" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Coordinates" minOccurs="1" type="CoordinatesType"/>
<xsd:element name="Communities" type="CommunitiesListType" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CoordinatesType">
<xsd:sequence>
<xsd:element name="WorkLocationCoordinate" type="WorkLocationCoordinateType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="WorkLocationCoordinateType">
<xsd:sequence>
<xsd:element name="CoordinateX" type="xsd:string"/>
<xsd:element name="CoordinateY" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
EDIT
Any idea of how to use choice properly here
You can do something like this:-
<xs:choice>
<xs:sequence>
<xs:element name="ParcelNumber" />
<xs:element name="CoOrdinates" minOccurs="0" />
</xs:sequence>
<xs:sequence>
<xs:element name="CoOrdinates" />
<xs:element name="ParcelNumber" minOccurs="0" />
</xs:sequence>
</xs:choice>
Try this
<xsd:complexType name="WorkLocationCoordinateType">
<xsd:sequence>
<xsd:element name="CoordinateX" type="xsd:string" minOccurs="1"/>
<xsd:element name="CoordinateY" type="xsd:string" minOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
​

.NET consume SAP web service

I'm trying to figure out how to consume a SAP webservice. I have a .WSDL file which looks for certain info in SAP.
My .WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="Customer_Out" targetNamespace="..." xmlns:p1="...." xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation/>
<wsp:UsingPolicy wsdl:required="true"/>
<wsp:Policy wsu:Id="OP_CustomerRead_sync"/>
<wsdl:types>
<xsd:schema targetNamespace="..." xmlns="..." xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MT_CustomerRead_response" type="DT_CustomerRead_response"/>
<xsd:element name="FMT_Customer">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="standard" type="ExchangeFaultData"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="MT_CustomerRead_request" type="DT_CustomerRead_request"/>
<xsd:complexType name="ExchangeFaultData">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">..</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="faultText" type="xsd:string"/>
<xsd:element name="faultUrl" type="xsd:string" minOccurs="0"/>
<xsd:element name="faultDetail" type="ExchangeLogData" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_Customer">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="BpId" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Name" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="AccountGroup" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Street" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Number" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="City" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Country" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Region" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_CustomerRead_request">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="RowLimit" type="xsd:integer"/>
<xsd:element name="BpId" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Name" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="ExternalCustomer" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="AccountGroup" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ExchangeLogData">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="severity" type="xsd:string" minOccurs="0"/>
<xsd:element name="text" type="xsd:string"/>
<xsd:element name="url" type="xsd:string" minOccurs="0"/>
<xsd:element name="id" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_CustomerRead_response">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Customer" type="DT_Customer" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Remark" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MT_CustomerRead_request">
<wsdl:documentation/>
<wsdl:part name="MT_CustomerRead_request" element="p1:MT_CustomerRead_request"/>
</wsdl:message>
<wsdl:message name="MT_CustomerRead_response">
<wsdl:documentation/>
<wsdl:part name="MT_CustomerRead_response" element="p1:MT_CustomerRead_response"/>
</wsdl:message>
<wsdl:message name="FMT_Customer">
<wsdl:documentation/>
<wsdl:part name="FMT_Customer" element="p1:FMT_Customer"/>
</wsdl:message>
<wsdl:portType name="Customer_Out">
<wsdl:documentation/>
<wsdl:operation name="CustomerRead_sync">
<wsdl:documentation/>
<wsp:Policy>
<wsp:PolicyReference URI="#OP_CustomerRead_sync"/>
</wsp:Policy>
<wsdl:input message="p1:MT_CustomerRead_request"/>
<wsdl:output message="p1:MT_CustomerRead_response"/>
<wsdl:fault name="FMT_Customer" message="p1:FMT_Customer"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Customer_OutBinding" type="p1:Customer_Out">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:operation name="CustomerRead_sync">
<soap:operation soapAction="http://sap.com/xi/WebService/soap1.1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:input>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:output>
<wsdl:fault name="FMT_Customer">
<soap:fault use="literal" name="FMT_Customer" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Customer_OutService">
<wsdl:port name="HTTP_Port" binding="p1:Customer_OutBinding">
<soap:address location="..." xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I've added a Service Reference to my .NET project which references the .WSDL file. This creates a namespace which allows me to make an instance of a couple of classes (9 in total).
I can't seem to find how to pass the request and receive the corresponding response. Should I parse these requests/responses? I'm aware of this tutorial but it doesn't really correspond with the file which I'm dealing with.
A request looks like this:
<man:MT_CustomerRead_request>
<RowLimit>100</RowLimit>
<!--Optional:-->
<!-- <CustomerId>?
<!--Optional:-->
<Name>Dell*</Name>
<!--Optional:-->
<!--Optional:-->
<AccountGroup>ABC</AccountGroup>
</man:MT_CustomerRead_request>
Thanks in advance
I'm just working on this topic and here's an example on how to create a request and call the SAP service in .NET (C#).
// Create the client
SapServiceReference.ECC_WS sapService = new SapServiceReference.ECC_WS();
sapService.Credentials = new NetworkCredential("Account", "Password");
// Prepare the parameters
SapServiceReference._parameters param = new SapServiceReference._parameters();
param.id = 1;
param.action = "R";
// Call SAP service
SapServiceReference._ws_Response response = sapService._someFunction(param);
string result = response.EvDescriptionText.Tdline;

Load Dataset Columns From Xsd using ReadXmlSchema

I've tried to load dataset columns from a schema with ReadXmlSchema method.
It's working but 0 column loads. And I could not see any problem with the xsd file. Here my xsd file:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns3="http://tempuri.org/Ortak_Tip.xsd" xmlns:ns4="http://tempuri.org/Ortak_Risk.xsd" xmlns:ns5="http://tempuri.org/Ek.xsd" xmlns:t="http://tempuri.org/Form.xsd" targetNamespace="http://tempuri.org/Form.xsd" elementFormDefault="qualified">
<xsd:import namespace="http://tempuri.org/Ortak_Tip.xsd" schemaLocation="http://tempuri.org/Ortak_Tip.xsd"/>
<xsd:import namespace="http://tempuri.org/Ortak_Risk.xsd" schemaLocation="http://tempuri.org/Ortak_Risk.xsd"/>
<xsd:import namespace="http://tempuri.org/Ek.xsd" schemaLocation="http://tempuri.org/Ek.xsd"/>
<xsd:element name="Form">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="Veri">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="Satir" maxOccurs="unbounded">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="SiraNo" type="ns3:Sayi15"/>
<xsd:element name="KrediIslemHesapNo" type="ns4:Karakter60"/>
<xsd:element name="MusteriNo" type="ns5:Karakter25"/>
<xsd:element name="VergiNo" type="ns4:Sayi11" nillable="true"/>
<xsd:element name="Adi" type="ns3:Karakter255"/>
<xsd:element name="UlkeKodu" type="ns3:UlkeKodu"/>
<xsd:element name="IslemTuru" type="xsd:boolean"/>
<xsd:element name="TarafKodu" type="ns3:IslemTarafKodu"/>
<xsd:element name="MusteriRiskSinif" type="ns4:MusterininRiskSinifi2"/>
<xsd:element name="IslemTutarAnaparaTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:element name="IslemTutarFaizTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:element name="IslemTutarToplamTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:element name="IslemOrijinalParaKodu" type="ns3:ParaKodu2"/>
<xsd:element name="ParaKoduEndeks" type="ns3:ParaKoduEndeks" nillable="true"/>
<xsd:element name="MKIhracciUnvan" type="ns3:Karakter255"/>
<xsd:element name="MKISINKodu" type="ns3:Karakter12"/>
<xsd:element name="PiyasaFiyatTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:element name="MKParaKodu" type="ns3:ParaKodu2"/>
<xsd:element name="MKVade" type="xsd:date" nillable="true"/>
<xsd:element name="IslemVade" type="xsd:date"/>
<xsd:element name="Portfoy" type="ns4:Portfoy2"/>
<xsd:element name="BilancoDeger" type="ns5:Yuzde14_2"/>
<xsd:element name="NominalDeger" type="ns5:Yuzde14_2"/>
<xsd:element name="AlacakVolAyarKatsayi" type="ns4:Yuzde5_3" nillable="true"/>
<xsd:element name="KurVolAyarKatsayi" type="ns4:Yuzde5_3" nillable="true"/>
<xsd:element name="TeminatVolAyarKatsayi" type="ns4:Yuzde5_3" nillable="true"/>
<xsd:element name="KarsiTarafRiskAgirlik" type="ns3:Sayi4" nillable="true"/>
<xsd:element name="TeminatRiskAgirlik" type="ns3:Sayi4" nillable="true"/>
<xsd:element name="RAV" type="ns5:Yuzde14_2" nillable="true"/>
<xsd:element name="IslemTHPKodu" type="ns3:Karakter8"/>
<xsd:element name="MKTHPKodu" type="ns3:Karakter8" nillable="true"/>
<xsd:element name="MKSinif" type="ns4:MKIslemSinif"/>
<xsd:element name="IslemSinif" type="ns4:MKIslemSinif"/>
<xsd:element name="EmanetDurumu" type="ns3:Karakter255"/>
<xsd:element name="IlaveTeminat" type="xsd:boolean"/>
<xsd:element name="KRATSonraRAV" type="ns5:Yuzde14_2" nillable="true"/>
<xsd:element name="KarsiTarafDerecelendirmeNotu1" type="ns5:Karakter25" nillable="true"/>
<xsd:element name="KarsiTarafDerecelendirmeNotu2" type="ns5:Karakter25" nillable="true"/>
<xsd:element name="KarsiTarafDerecelendirmeNotu3" type="ns5:Karakter25" nillable="true"/>
<xsd:element name="KarsiTarafDerecelendirmeNotu4" type="ns5:Karakter25" nillable="true"/>
<xsd:element name="MKDerecelendirmeNotu1" type="ns5:Karakter25" nillable="true"/>
<xsd:element name="MKDerecelendirmeNotu2" type="ns5:Karakter25" nillable="true"/>
<xsd:element name="MKDerecelendirmeNotu3" type="ns5:Karakter25" nillable="true"/>
<xsd:element name="MKDerecelendirmeNotu4" type="ns5:Karakter25" nillable="true"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="Gun" type="ns4:Gun" use="required" fixed="1"/>
<xsd:attribute name="Ay" type="ns4:Ay" use="required"/>
<xsd:attribute name="Yil" type="ns3:Sayi4" use="required"/>
<xsd:attribute name="FormKodu" type="ns3:Karakter7" use="required" fixed="RT100AS"/>
<xsd:attribute name="KurulusKodu" type="ns5:Sayi3" use="required"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Could someone please tell me where I'm wrong?
It's working...
That's not believable.
...but 0 column loads.
Now that is believable.
An immediately obvious problem is that the URLs given by the schemaLocations in the xsd:imports of your XSD redirect to www.bing.com. Before anything else, you'll have to resolve this problem.
xsd namespace doesn't like nested tags. Also you need a single root element. Made changes to get xml to read. Not sure if it is what you really need.
code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace ConsoleApplication1
{
class Program
{
const string FILENAME = #"c:\temp\test.xml";
static void Main(string[] args)
{
DataSet ds = new DataSet();
ds.ReadXml(FILENAME, XmlReadMode.ReadSchema);
}
}
}
xml
<?xml version="1.0" encoding="utf-8" ?>
<Root xsd:schema="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001" xmlns:ns3="http://tempuri.org/Ortak_Tip.xsd" xmlns:ns4="http://tempuri.org/Ortak_Risk.xsd" xmlns:ns5="http://tempuri.org/Ek.xsd" xmlns:t="http://tempuri.org/Form.xsd" targetNamespace="http://tempuri.org/Form.xsd" elementFormDefault="qualified">
<xsd:import namespace="http://tempuri.org/Ortak_Tip.xsd" schemaLocation="http://tempuri.org/Ortak_Tip.xsd"/>
<xsd:import namespace="http://tempuri.org/Ortak_Risk.xsd" schemaLocation="http://tempuri.org/Ortak_Risk.xsd"/>
<xsd:import namespace="http://tempuri.org/Ek.xsd" schemaLocation="http://tempuri.org/Ek.xsd"/>
<xsd:element name="Form">
<xsd:complex>
<xsd:complexSequence>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:elementSequence name="Veri">
<xsd:complexContent>
<xsd:complexType>
<xsd:restrictionType base="xsd:anyType">
<xsd:sequenceType>
<xsd:table name="Satir" maxOccurs="unbounded">
<xsd:elementAttribute>
<xsd:complexAttribute>
<xsd:restrictionAttribute base="xsd:anyType">
<xsd:sequenceAttribute>
<xsd:attribute name="SiraNo" type="ns3:Sayi15"/>
<xsd:attribute name="KrediIslemHesapNo" type="ns4:Karakter60"/>
<xsd:attribute name="MusteriNo" type="ns5:Karakter25"/>
<xsd:attribute name="VergiNo" type="ns4:Sayi11" nillable="true"/>
<xsd:attribute name="Adi" type="ns3:Karakter255"/>
<xsd:attribute name="UlkeKodu" type="ns3:UlkeKodu"/>
<xsd:attribute name="IslemTuru" type="xsd:boolean"/>
<xsd:attribute name="TarafKodu" type="ns3:IslemTarafKodu"/>
<xsd:attribute name="MusteriRiskSinif" type="ns4:MusterininRiskSinifi2"/>
<xsd:attribute name="IslemTutarAnaparaTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:attribute name="IslemTutarFaizTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:attribute name="IslemTutarToplamTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:attribute name="IslemOrijinalParaKodu" type="ns3:ParaKodu2"/>
<xsd:attribute name="ParaKoduEndeks" type="ns3:ParaKoduEndeks" nillable="true"/>
<xsd:attribute name="MKIhracciUnvan" type="ns3:Karakter255"/>
<xsd:attribute name="MKISINKodu" type="ns3:Karakter12"/>
<xsd:attribute name="PiyasaFiyatTLKarsilik" type="ns5:Yuzde14_2"/>
<xsd:attribute name="MKParaKodu" type="ns3:ParaKodu2"/>
<xsd:attribute name="MKVade" type="xsd:date" nillable="true"/>
<xsd:attribute name="IslemVade" type="xsd:date"/>
<xsd:attribute name="Portfoy" type="ns4:Portfoy2"/>
<xsd:attribute name="BilancoDeger" type="ns5:Yuzde14_2"/>
<xsd:attribute name="NominalDeger" type="ns5:Yuzde14_2"/>
<xsd:attribute name="AlacakVolAyarKatsayi" type="ns4:Yuzde5_3" nillable="true"/>
<xsd:attribute name="KurVolAyarKatsayi" type="ns4:Yuzde5_3" nillable="true"/>
<xsd:attribute name="TeminatVolAyarKatsayi" type="ns4:Yuzde5_3" nillable="true"/>
<xsd:attribute name="KarsiTarafRiskAgirlik" type="ns3:Sayi4" nillable="true"/>
<xsd:attribute name="TeminatRiskAgirlik" type="ns3:Sayi4" nillable="true"/>
<xsd:attribute name="RAV" type="ns5:Yuzde14_2" nillable="true"/>
<xsd:attribute name="IslemTHPKodu" type="ns3:Karakter8"/>
<xsd:attribute name="MKTHPKodu" type="ns3:Karakter8" nillable="true"/>
<xsd:attribute name="MKSinif" type="ns4:MKIslemSinif"/>
<xsd:attribute name="IslemSinif" type="ns4:MKIslemSinif"/>
<xsd:attribute name="EmanetDurumu" type="ns3:Karakter255"/>
<xsd:attribute name="IlaveTeminat" type="xsd:boolean"/>
<xsd:attribute name="KRATSonraRAV" type="ns5:Yuzde14_2" nillable="true"/>
<xsd:attribute name="KarsiTarafDerecelendirmeNotu1" type="ns5:Karakter25" nillable="true"/>
<xsd:attribute name="KarsiTarafDerecelendirmeNotu2" type="ns5:Karakter25" nillable="true"/>
<xsd:attribute name="KarsiTarafDerecelendirmeNotu3" type="ns5:Karakter25" nillable="true"/>
<xsd:attribute name="KarsiTarafDerecelendirmeNotu4" type="ns5:Karakter25" nillable="true"/>
<xsd:attribute name="MKDerecelendirmeNotu1" type="ns5:Karakter25" nillable="true"/>
<xsd:attribute name="MKDerecelendirmeNotu2" type="ns5:Karakter25" nillable="true"/>
<xsd:attribute name="MKDerecelendirmeNotu3" type="ns5:Karakter25" nillable="true"/>
<xsd:attribute name="MKDerecelendirmeNotu4" type="ns5:Karakter25" nillable="true"/>
</xsd:sequenceAttribute>
</xsd:restrictionAttribute>
</xsd:complexAttribute>
</xsd:elementAttribute>
</xsd:table>
</xsd:sequenceType>
</xsd:restrictionType>
</xsd:complexType>
</xsd:complexContent>
</xsd:elementSequence>
</xsd:sequence>
<xsd:attribute name="Gun" type="ns4:Gun" use="required" fixed="1"/>
<xsd:attribute name="Ay" type="ns4:Ay" use="required"/>
<xsd:attribute name="Yil" type="ns3:Sayi4" use="required"/>
<xsd:attribute name="FormKodu" type="ns3:Karakter7" use="required" fixed="RT100AS"/>
<xsd:attribute name="KurulusKodu" type="ns5:Sayi3" use="required"/>
</xsd:restriction>
</xsd:complexSequence>
</xsd:complex>
</xsd:element>
<!--</xsd:schema>-->
</Root>

I'm validating XML against XSD in Windows Forms using C# .NET and it's giving me the error "Please Suggest the fix"

I'm validating XML against XSD in Windows Forms using C# .NET and it's giving me the error "Please Suggest the fix"
Here is my code
namespace XMLValidation
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Validation Error Count
static int ErrorsCount = 0;
// Validation Error Message
static string ErrorMessage = "";
public static void ValidationHandler(object sender,
ValidationEventArgs args)
{
ErrorMessage = ErrorMessage + args.Message + "\r\n";
ErrorsCount++;
}
private void button1_Click(object sender, EventArgs e)
{
XDocument doc1 = XDocument.Load("C:\\Hit.xml");
Validate(doc1.ToString());
}
public void Validate(string strXMLDoc)
{
try
{
// Declare local objects
XmlTextReader tr = null;
XmlSchemaCollection xsc = null;
XmlValidatingReader vr = null;
// Text reader object
tr = new XmlTextReader("C:\\ScreeningReport.xsd");
xsc = new XmlSchemaCollection();
xsc.Add(null, tr);
// XML validator object
vr = new XmlValidatingReader(strXMLDoc,
XmlNodeType.Document, null);
vr.Schemas.Add(xsc);
// Add validation event handler
vr.ValidationType = ValidationType.Schema;
vr.ValidationEventHandler +=
new ValidationEventHandler(ValidationHandler);
// Validate XML data
while (vr.Read()) ;
vr.Close();
// Raise exception, if XML validation fails
if (ErrorsCount > 0)
{
throw new Exception(ErrorMessage);
}
// XML Validation succeeded
MessageBox.Show("XML validation succeeded.\r\n");
}
catch (Exception error)
{
// XML Validation failed
MessageBox.Show("XML validation failed." + "\r\n" +
"Error Message: " + error.Message);
}
}
}
}
My XML file
<ScreeningReport xmlns="http://www.sterlingtesting.com/hrxml/1.0">
<DocumentIDGroup>
<DocumentID schemeID="CorrelationID" schemeAgencyID="TRACKER">5500209_1</DocumentID>
</DocumentIDGroup>
<ScreeningPackageResult>
<ScreeningSubjectPersonDetails>
<PersonLegalID schemeAgencyName="" schemeAgencyID="AG" schemeName="SSN" schemeID="">346455645</PersonLegalID>
<PersonName>
<GivenName>Testfn</GivenName>
<FamilyName>Testln</FamilyName>
</PersonName>
<BirthDateDetails>
<YearMonthDate>1980-01-01</YearMonthDate>
</BirthDateDetails>
</ScreeningSubjectPersonDetails>
<ScreeningUserDetails>
<UserID>CRIMT</UserID>
</ScreeningUserDetails>
<ScreeningResult>
<IDGroup>
<ID schemeID="CorrelationID" schemeAgencyID="TRACKER">5500209_1</ID>
<ID schemeID="OrderID" schemeAgencyID="TRACKER">5500209</ID>
<ID schemeID="ScreeningID" schemeAgencyID="TRACKER">5911635</ID>
</IDGroup>
<ScreeningStatusDetails>
<ScreeningOrderStatusCode>Hit</ScreeningOrderStatusCode>
<Score>ExactMatch</Score>
</ScreeningStatusDetails>
<Ordered>true</Ordered>
<Count>1</Count>
<CriminalReport>
<CriminalCase>
<IDGroup>
<ID schemeID="Case" schemeAgencyID="AG">57675</ID>
</IDGroup>
<JurisdictionType>County</JurisdictionType>
<CountryCode>US</CountryCode>
<CountrySubdivisionCode>AK</CountrySubdivisionCode>
<CountyName>DENALI</CountyName>
<ScreeningSubjectPersonDetails>
<PersonLegalID schemeAgencyID="AG" schemeName="SSN">346455645</PersonLegalID>
<PersonName>
<GivenName>Testfn</GivenName>
<FamilyName>Testln</FamilyName>
</PersonName>
<BirthDateDetails>
<YearMonthDate>1980-01-01</YearMonthDate>
</BirthDateDetails>
</ScreeningSubjectPersonDetails>
<Charge>
<IDGroup>
<ID schemeID="Charge" schemeAgencyID="AG">7546</ID>
<ID schemeID="ConvictedOffenseCode" schemeAgencyID="AG" />
<ID schemeID="StatuteNumber" schemeAgencyID="AG" />
</IDGroup>
<ChargeOrComplaint>test charge</ChargeOrComplaint>
<Disposition>disp1</Disposition>
<AdditionalItems qualifier="Parsed">
<UserArea>
<ChargeInfo>
<ChargeType>Conviction</ChargeType>
<ChargeLevel>Felony</ChargeLevel>
<Sentences />
</ChargeInfo>
<SterlingFields>
<Field name="Convicted Offense Description">test charge</Field>
</SterlingFields>
</UserArea>
</AdditionalItems>
<AdditionalItems qualifier="ParsedSentence">
<UserArea>
<SterlingFields>
<Field name="Enhanced Firearm Penalty">test charge</Field>
</SterlingFields>
</UserArea>
</AdditionalItems>
<AdditionalItems qualifier="ParsedCharge">
<UserArea>
<SterlingFields>
<Field name="ChargeCHARGE_LEVEL_ID">Felony</Field>
</SterlingFields>
</UserArea>
</AdditionalItems>
</Charge>
<AdditionalItems qualifier="Parsed">
<UserArea>
<CaseInfo>
<CaseArrestDate>
<YearMonthDate>2011-02-08</YearMonthDate>
</CaseArrestDate>
<CaseDispositionDate>
<YearMonthDate>2011-02-02</YearMonthDate>
</CaseDispositionDate>
<CaseStatus>Closed Case</CaseStatus>
<ReportingDecision>DO_NOT_REPORT</ReportingDecision>
<Sentences>
<Sentence>
<Type>Costs</Type>
<Suspended>false</Suspended>
<FineAmount>123</FineAmount>
<OtherInfo>suspended fine=123</OtherInfo>
</Sentence>
</Sentences>
<CaseType>Conviction</CaseType>
<CaseLevel>Felony</CaseLevel>
</CaseInfo>
</UserArea>
</AdditionalItems>
<AdditionalItems qualifier="ParsedCriminalCase">
<UserArea>
<SterlingFields>
<Field name="CriminalCaseAdditionalInfo">additional ionfo text</Field>
<Field name="CriminalCaseGovernmentID">346455645</Field>
<Field name="CriminalCaseReportDecision">DO NOT REPORT</Field>
<Field name="CriminalCasePossibleRecord">false</Field>
</SterlingFields>
</UserArea>
</AdditionalItems>
</CriminalCase>
</CriminalReport>
<AdditionalItems qualifier="FulfillmentType">
<UserArea>
<Text>MANUAL</Text>
</UserArea>
</AdditionalItems>
<AdditionalItems qualifier="ResearcherType">
<UserArea>
<Text>Internal</Text>
</UserArea>
</AdditionalItems>
<AdditionalItems qualifier="TrackerUserId">
<UserArea>
<Text>ed</Text>
</UserArea>
</AdditionalItems>
</ScreeningResult>
</ScreeningPackageResult>
</ScreeningReport>
My XSD
<xsd:schema xmlns="http://www.sterlingtesting.com/hrxml/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.sterlingtesting.com/hrxml/1.0" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- top level screening result definition -->
<xsd:element name="ScreeningReport" type="ScreeningReportType"/>
<xsd:complexType name="ScreeningReportType">
<xsd:sequence>
<xsd:element name="DocumentIDGroup" type="DocumentIDGroupType"/>
<xsd:element name="ScreeningPackageResult" type="ScreeningPackageResultType"/>
<xsd:element name="ScreeningException" type="ScreeningExceptionType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- document ID according to the new hrxml/oagis specifications -->
<xsd:complexType name="DocumentIDGroupType">
<xsd:sequence>
<xsd:element name="DocumentID" type="DocumentIDType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- single document id specification, according to the hrxml/oagis specification -->
<xsd:complexType name="DocumentIDType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="schemeAgencyID" type="xsd:string" use="required"/>
<xsd:attribute name="schemeID" type="xsd:string" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!--
top level package container for screenings
(or batch in IFN terminology)
-->
<xsd:complexType name="ScreeningPackageResultType">
<xsd:sequence>
<xsd:element name="ScreeningSubjectPersonDetails" type="ScreeningSubjectPersonDetailsType" minOccurs="0"/>
<xsd:element name="ScreeningUserDetails" type="ScreeningUserDetailsType" minOccurs="0"/>
<xsd:element name="CompletionDate" type="CompletionDateType" minOccurs="0"/>
<xsd:element name="ScreeningOptionCode" type="ScreeningOptionCodeType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="ScreeningResult" type="ScreeningResultType" maxOccurs="unbounded"/>
<xsd:element name="ScreeningException" type="ScreeningExceptionType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- optional codes to tweak the screening request -->
<xsd:complexType name="ScreeningOptionCodeType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- details for the screening client -->
<xsd:complexType name="ScreeningUserDetailsType">
<xsd:sequence>
<xsd:element name="UserID" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the completion date -->
<xsd:complexType name="CompletionDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- the individual screening (or result in IFN terminology) -->
<xsd:complexType name="ScreeningResultType">
<xsd:sequence>
<xsd:element name="IDGroup" type="IDGroupType"/>
<xsd:element name="ScreeningException" type="ScreeningExceptionType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="ScreeningStatusDetails" type="ScreeningStatusDetailsType" minOccurs="0"/>
<xsd:element name="Ordered" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="Count" type="xsd:int" minOccurs="0"/>
<xsd:choice minOccurs="0">
<xsd:element name="CriminalReport" type="CriminalReportType"/>
<xsd:element name="SanctionReport" type="SanctionReportType"/>
</xsd:choice>
<xsd:element name="AdditionalItems" type="AdditionalItemsType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- sanction report -->
<xsd:complexType name="SanctionReportType">
<xsd:sequence>
<xsd:element name="SubjectConfirmationMethodCode" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- an exception on the individual result -->
<xsd:complexType name="ScreeningExceptionType">
<xsd:sequence>
<xsd:element name="ExceptionIdentifier" type="xsd:string"/>
<xsd:element name="ExceptionSeverity" type="xsd:string"/>
<xsd:element name="ExceptionMessage" type="xsd:string"/>
<xsd:element name="ExceptionPath" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- status type -->
<xsd:complexType name="ScreeningStatusDetailsType">
<xsd:sequence>
<xsd:element name="ScreeningOrderStatusCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="ScreeningResultCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="Score" type="xsd:string" minOccurs="0"/>
<xsd:element name="StatusDate" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- grouping of IDs according to the new hrxml/oagis specifications -->
<xsd:complexType name="IDGroupType">
<xsd:sequence>
<xsd:element name="ID" type="IDType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- single id specification, according to the hrxml/oagis specification -->
<xsd:complexType name="IDType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="schemeAgencyID" type="xsd:string" use="required"/>
<xsd:attribute name="schemeID" type="xsd:string" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- criminal report type definition -->
<xsd:complexType name="CriminalReportType">
<xsd:sequence>
<xsd:element name="CriminalCase" type="CriminalCaseType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CriminalCaseType">
<xsd:sequence>
<xsd:element name="IDGroup" type="IDGroupType"/>
<xsd:element name="ArrestingAgency" type="xsd:string" minOccurs="0"/>
<xsd:element name="JurisdictionType" type="JurisdictionTypeEnumType"/>
<xsd:element name="CourtName" type="xsd:string" minOccurs="0"/>
<xsd:element name="CourtType" type="xsd:string" minOccurs="0"/>
<xsd:element name="CourtJurisdiction" type="xsd:string" minOccurs="0"/>
<xsd:element name="CountryCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="CountrySubdivisionCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="CountyName" type="xsd:string" minOccurs="0"/>
<xsd:element name="CityName" type="xsd:string" minOccurs="0"/>
<xsd:element name="ChargeTypeClassification" type="xsd:string"/>
<xsd:element name="CaseFileDate" type="CaseFileDateType" minOccurs="0"/>
<xsd:element name="SubjectConfirmation" type="SubjectConfirmationType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="ScreeningSubjectPersonDetails" type="ScreeningSubjectPersonDetailsType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="Charge" type="ChargeType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="AdditionalItems" type="AdditionalItemsType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the Subject Confirmation -->
<xsd:complexType name="SubjectConfirmationType">
<xsd:sequence>
<xsd:element name="ConfirmByFamilyName" type="xsd:string" minOccurs="0"/>
<xsd:element name="ConfirmByGivenName" type="xsd:string" minOccurs="0"/>
<xsd:element name="ConfirmByMiddleName" type="xsd:string" minOccurs="0"/>
<xsd:element name="ConfirmByDateOfBirth" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the charge date -->
<xsd:complexType name="ChargeType">
<xsd:sequence>
<xsd:element name="IDGroup" type="IDGroupType"/>
<xsd:element name="ChargeOrComplaint" type="xsd:string"/>
<xsd:element name="ChargeTypeClassification" type="xsd:string"/>
<xsd:element name="ChargeClassification" type="xsd:string"/>
<xsd:element name="ArrestDate" type="ArrestDateType"/>
<xsd:element name="ChargeDate" type="ChargeDateType"/>
<xsd:element name="OffenseDate" type="OffenseDateType"/>
<xsd:element name="Sentence" type="xsd:string"/>
<xsd:element name="SentenceDate" type="SentenceDateType"/>
<xsd:element name="Disposition" type="xsd:string"/>
<xsd:element name="DispositionDate" type="DispositionDateType"/>
<xsd:element name="ProbationStatus" type="xsd:string"/>
<xsd:element name="AdditionalItems" type="AdditionalItemsType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the disposition date -->
<xsd:complexType name="DispositionDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the arrest date -->
<xsd:complexType name="ArrestDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the charge date -->
<xsd:complexType name="ChargeDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the case file date -->
<xsd:complexType name="CaseFileDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the offense date -->
<xsd:complexType name="OffenseDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the sentence date -->
<xsd:complexType name="SentenceDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- *********************** REFACTOR **************************** -->
<!-- details about the subject for the screening -->
<xsd:complexType name="ScreeningSubjectPersonDetailsType">
<xsd:sequence>
<xsd:element name="ScreeningSubjectDetailsTypeCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="PersonLegalID" type="PersonIDType" minOccurs="0"/>
<xsd:element name="PersonName" type="PersonNameType" minOccurs="0"/>
<xsd:element name="PostalAddress" type="PostalAddressType" minOccurs="0"/>
<xsd:element name="GenderCode" type="GenderCodeEnumType" minOccurs="0"/>
<xsd:element name="BirthDateDetails" type="BirthDateDetailsType" minOccurs="0"/>
<xsd:element name="RaceCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="EyeColor" type="xsd:string" minOccurs="0"/>
<xsd:element name="HairColor" type="xsd:string" minOccurs="0"/>
<xsd:element name="Height" type="xsd:string" minOccurs="0"/>
<xsd:element name="Weight" type="xsd:string" minOccurs="0"/>
<xsd:element name="Age" type="xsd:string" minOccurs="0"/>
<xsd:element name="Licenses" type="LicensesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Type" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- licenses -->
<xsd:complexType name="LicensesType">
<xsd:sequence>
<xsd:element name="License" type="LicenseType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="LicenseType">
<xsd:sequence>
<xsd:element name="LicenseName" type="xsd:string"/>
<xsd:element name="IssuingAuthority" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- postal address -->
<xsd:complexType name="PostalAddressType">
<xsd:sequence>
<xsd:element name="AddressLine" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="CityName" type="xsd:string" minOccurs="0"/>
<xsd:element name="CountrySubDivisionCode" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<!-- state/province ISO code -->
<xsd:element name="CountryCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="PostalCode" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- details for the personal legal id -->
<xsd:complexType name="PersonIDType">
<xsd:simpleContent>
<xsd:extension base="xsd:normalizedString">
<xsd:attribute name="schemeID" type="xsd:normalizedString" use="optional"/>
<xsd:attribute name="schemeName" type="xsd:string" use="optional"/>
<xsd:attribute name="schemeAgencyID" type="xsd:normalizedString" use="optional"/>
<xsd:attribute name="schemeAgencyName" type="xsd:string" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!--
gender enumeration from the hrxml-3.0 spec
http://ns.hr-xml.org/3.0/documentation/components/GenderCode-element.php
-->
<xsd:simpleType name="GenderCodeEnumType">
<xsd:restriction base="xsd:integer">
<xsd:enumeration value="0"/>
<xsd:enumeration value="1"/>
<xsd:enumeration value="2"/>
<xsd:enumeration value="9"/>
<!-- not known -->
<!-- male -->
<!-- female -->
<!-- not specified -->
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="JurisdictionTypeEnumType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="National"/>
<xsd:enumeration value="State"/>
<xsd:enumeration value="County"/>
<xsd:enumeration value="Federal District"/>
<xsd:enumeration value="Local District"/>
</xsd:restriction>
</xsd:simpleType>
<!-- generic name reference -->
<xsd:complexType name="PersonNameType">
<xsd:sequence>
<xsd:choice>
<xsd:element name="FormattedName" type="xsd:string"/>
<xsd:sequence>
<xsd:element name="GivenName" type="xsd:string"/>
<xsd:element name="MiddleName" type="xsd:string" minOccurs="0"/>
<xsd:element name="FamilyName" type="xsd:string"/>
</xsd:sequence>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<!-- details for the birth date -->
<xsd:complexType name="BirthDateDetailsType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<!-- additional details -->
<xsd:complexType name="AdditionalItemsType">
<xsd:sequence>
<xsd:element name="Text" type="xsd:string" minOccurs="0"/>
<xsd:element name="UserArea" type="UserAreaType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="vendor" type="xsd:string" use="optional"/>
<xsd:attribute name="type" type="xsd:string" use="optional"/>
<xsd:attribute name="qualifier" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- user area definition -->
<!--
<xsd:complexType name="UserAreaType" block="restriction">
<xsd:sequence>
<xsd:choice/>
<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
-->
<xsd:complexType name="UserAreaType" block="restriction">
<xsd:sequence>
<xsd:element name="ChargeInfo" type="ChargeInfoType" minOccurs="0"/>
<xsd:element name="CaseInfo" type="CaseInfoType" minOccurs="0"/>
<xsd:element name="UserInfo" type="UserInfoType" minOccurs="0"/>
<xsd:element name="SterlingFields" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Field" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Text" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ChargeInfoType">
<xsd:sequence>
<xsd:element name="ChargeType" type="xsd:string" minOccurs="0"/>
<xsd:element name="ChargeLevel" type="xsd:string" minOccurs="0"/>
<xsd:element name="Sentences" type="SentencesType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SentencesType">
<xsd:sequence>
<xsd:element name="Sentence" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Consecutive" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="LengthMonths" type="xsd:string" minOccurs="0"/>
<xsd:element name="LengthDays" type="xsd:string" minOccurs="0"/>
<xsd:element name="LengthHours" type="xsd:string" minOccurs="0"/>
<xsd:element name="LengthYears" type="xsd:string" minOccurs="0"/>
<xsd:element name="LengthWeeks" type="xsd:string" minOccurs="0"/>
<xsd:element name="Type" type="xsd:string" minOccurs="0"/>
<xsd:element name="MappedSentenceType" type="xsd:string" minOccurs="0"/>
<xsd:element name="Suspended" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="FineAmount" type="xsd:string" minOccurs="0"/>
<xsd:element name="OtherInfo" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CaseInfoType">
<xsd:sequence>
<xsd:element name="CaseArrestDate" type="CaseArrestDateType" minOccurs="0"/>
<xsd:element name="CaseDispositionDate" type="CaseDispositionDateType" minOccurs="0"/>
<xsd:element name="CaseDisposition" type="xsd:string" minOccurs="0"/>
<xsd:element name="CaseStatus" type="xsd:string" minOccurs="0"/>
<xsd:element name="ReportingDecision" type="ReportingDecisionEnumType" minOccurs="0"/>
<xsd:element name="ReportingDecisionRule" type="xsd:string" minOccurs="0"/>
<xsd:element name="ReportingDecisionRuleBlurb" type="xsd:string" minOccurs="0"/>
<xsd:element name="Sentences" type="SentencesType" minOccurs="0"/>
<xsd:element name="CaseType" type="xsd:string" minOccurs="0"/>
<xsd:element name="CaseLevel" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CaseArrestDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CaseDispositionDateType">
<xsd:sequence>
<xsd:element name="YearMonthDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="ReportingDecisionEnumType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="REPORT"/>
<xsd:enumeration value="DO_NOT_REPORT"/>
<xsd:enumeration value="CONTACT_CLIENT_UNORDERED_HIT"/>
<xsd:enumeration value="CONTACT_CLIENT_NO_SALARY"/>
<xsd:enumeration value="DATA_ERROR"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="UserInfoType">
<xsd:sequence>
<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
The error is:
The element 'CriminalCase' in namespace 'http://www.sterlingtesting.com/hrxml/1.0' has invalid child element 'ScreeningSubjectPersonDetails' in namespace 'http://www.sterlingtesting.com/hrxml/1.0'. List of possible elements expected: 'http://www.sterlingtesting.com/hrxml/1.0:CityName http://www.sterlingtesting.com/hrxml/1.0:ChargeTypeClassification'.
ScreeningSubjectPersonDetails is the child element. Why is it showing INVALID CHILD?
Do you really believe anyone is going to read through this HUGE pile of code?
Anyway, the error message simply says that your XML file doesn't conform to the XSD...

Categories

Resources