How to get key value pairs from resx file using powershell script? - c#

I need to obtain values from c# resx file using powershell script.Is it possible to obtain these xml values using only PS scripting?I wrote a code only in PS but it didn't work.Snippets would help!!

Using ResXResourceSet Class:
$File = 'c:\path\to\file.resx'
# Add assembly containing class, not sure if needed, but wouldn't hurt
Add-Type -AssemblyName System.Windows.Forms
# Create new ResXResourceSet, pass path to the resx file to the constructor
$ResourceSet = New-Object -TypeName 'System.Resources.ResXResourceSet' -ArgumentList $File
# Get resources
$ResourceSet.GetString('TestString')
$ResourceSet.GetString('AnotherTestString')
ResX example:
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="TestString" xml:space="preserve">
<value>This is some test string...</value>
</data>
<data name="AnotherTestString" xml:space="preserve">
<value>Another test string...</value>
</data>
</root>
Output:
This is some test string...
Another test string...
P.S.
ResX files are XML, so you can get values from them using XPath or other methods.
References:
How to clean up resx files with PowerShell

Related

ResourceManager.GetString returns "" when the value is " " in .NET Core

ResourceManager.GetString returns " " in .NET Freamework, but the exact same method returns "" in .NETCore. The actual value is " "
Here is a simple .NET Core program:
namespace ResxTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var resourceManager = new ResourceManager("ResxTest.Resource1", typeof(Program).Assembly);
var test1 = resourceManager.GetString("all_space");
var test2 = resourceManager.GetString("begin_with_space");
var test3 = resourceManager.GetString("end_with_space");
var test4 = resourceManager.GetString("no_space");
Console.WriteLine("");
}
}
}
if you run it, test1 will be "" instead of " "
Resource1.resx (added the resx file as a new item in Visual Studio => did not make it manually):
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="all_space" xml:space="preserve">
<value> </value>
</data>
<data name="begin_with_space" xml:space="preserve">
<value> x</value>
</data>
<data name="end_with_space" xml:space="preserve">
<value>x </value>
</data>
<data name="no_space" xml:space="preserve">
<value>x</value>
</data>
</root>

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>

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

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>

XSD relation between classes, + hierarchy relation

I have some xml in the following format where in the group state can either be states of true false as defined in definition state, or use another group with one of it's values.
How can I use xsd for this relation contsraint - using ID and IDref solved for the definition and group name, but how do I constrain that the value of the group is really a value as defined in the group?
Also is there any way to distinguish between the ID, in case using definition the value should be true / false string. in case using another group state should be one of its defined state?
<Definitions>
<Definition Name="Name1"/>
<Definition Name="Name2" />
</Definitions>
<ValueGrps>
<Group Name="grp1">
<ComplexState Name="state1">
<State Name="Name1" Value="true" />
<State Name="Name2" Value="true" />
</ComplexState>
<ComplexState Name="state2">
<State Name="Name1" Value="false" />
<State Name="Name2" Value="true" />
</ComplexState>
</Group>
<Group Name="grp2">
<ComplexState Name="state1">
<State Name="grp1" Value="state1" />
</ComplexState>
</Group>
</ValueGrps>
XSD 1.0 alone cannot help you here. You could apply Schematron for sure; there is an XSLT 1.0 implementation which works on .NET (since you've indicated C#).
XSD 1.1 has built in support for what you need. However, XSD 1.1 is poorly supported on .NET as in you either buy Saxon's EE for NET OR you use IKVM to "port" XercesJ on .NET (I've done it and it works). You would have issues, in an open environment, to have other people using XSD 1.1 schemas.
If this is a new design, I would probably also change some of the design... for example, a State referencing a group is not the same as a State referencing a Definition - I would then define different content models for the different reference types. I would also drop ID/IDREF in favour of key(unique)/keyref. I am attaching an example below which would work with the provided XML.
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Definitions">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Definition">
<xsd:complexType>
<xsd:attribute name="Name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ValueGrps">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Group">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="ComplexState">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="State">
<xsd:complexType>
<xsd:attribute name="Name" type="xsd:string" use="required" />
<xsd:attribute name="Value" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="Name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="Name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="PK_1">
<xsd:selector xpath="Definitions/Definition|ValueGrps/Group"/>
<xsd:field xpath="#Name"/>
</xsd:key>
<xsd:keyref name="FK_1" refer="PK_1">
<xsd:selector xpath="ValueGrps/Group/ComplexState/State"/>
<xsd:field xpath="#Name"/>
</xsd:keyref>
</xsd:element>
</xsd:schema>

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