[lxml-dev] XSD Validation: No matching global declaration.
Hi All: I don't know if my schema is invalid or if this represents a bug in lxml or libxml2. Here is the situation... I have a XML Schema that looks like this: <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sif="http://www.sifinfo.org/infrastructure/1.x" targetNamespace="http://www.sifinfo.org/infrastructure/1.x"> <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/> ... <element name="Authentication"> <complexType> <sequence> <element ref="sif:AuthenticationInfo" minOccurs="0" maxOccurs="unbounded"/> <element ref="sif:SIF_ExtendedElements" minOccurs="0" maxOccurs="1"/> </sequence> <attribute name="RefId" type="sif:RefIdType" use="required"/> <attribute name="SifRefId" type="sif:RefIdType" use="required"/> <attribute name="SifRefIdType" use="required"> <simpleType> <restriction base="string"> <enumeration value="StudentPersonal"/> <enumeration value="StaffPersonal"/> <enumeration value="StudentContact"/> <enumeration value="EmployeePersonal"/> </restriction> </simpleType> </attribute> </complexType> </element> ... </schema> I am trying to validate this data: <?xml version="1.0"?> <Authentication xmlns:ns3="http://www.w3.org/2001/XMLSchema" ns3:RefId="27D1CAEA85C2BAA647A01B551D21E1EB" ns3:SifRefId="211242238C60A55E25B2B86BB337C244" ns3:SifRefIdType="EmployeePersonal"> <AuthenticationInfo> <System xmlns:ns0="http://www.w3.org/2001/XMLSchema" ns0:Type="Application">&1<tNk44}F2</System> <Username>;pl}ee'-</Username> <DistinguishedName>mlZm@JD</DistinguishedName> <Password xmlns:ns1="http://www.w3.org/2001/XMLSchema" ns1:Algorithm="MD5" ns1:KeyName="(v4kSY.">l1uqg!</Password> </AuthenticationInfo> <SIF_ExtendedElements> <SIF_ExtendedElement xmlns:ns2="http://www.w3.org/2001/XMLSchema" ns2:Name="%~T=">ZE72n/l</SIF_ExtendedElement> </SIF_ExtendedElements> </Authentication> The error log shows the following error: ../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml:2:ERROR:S CHEMASV:SCHEMAV_CVC_ELT_1: Element 'Authentication': No matching global declaration available for the validation root. The same code given diffrent files works fine. Does anyone have any ideas why I am getting this message? Required version information: lxml.etree: (1, 3, 4, 0) libxml used: (2, 6, 30) libxml compiled: (2, 6, 30) libxslt used: (1, 1, 21) libxslt compiled: (1, 1, 22) Thanks, John W. Lovell Web Applications Engineer Northwest Educational Service District 1601 R Avenue Anacortes, WA 98221 <mailto:jlovell@esd189.org> www.esd189.org <http://www.esd189.org/> Together We Can ...
John Lovell wrote:
I don't know if my schema is invalid or if this represents a bug in lxml or libxml2. The error log shows the following error:
../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml:2:ERROR:S CHEMASV:SCHEMAV_CVC_ELT_1: Element 'Authentication': No matching global declaration available for the validation root.
I'm not so firm with libxml2's XML Schema implementation, not sure what that means exactly. Is it the only error you get in the log?
The same code given diffrent files works fine. Does anyone have any ideas why I am getting this message?
You can check if "xmllint" (which is the command line tool that comes with libxml2) produces the same error. It is actually unlikely that this is an lxml problem, so this would tell you if libxml2 really thinks that your file is invalid. In that case, you can ask on the libxml2 mailing list instead. Maybe you can also check with a different tool, that might give you more hints on what is wrong here. Stefan
John Lovell wrote:
I don't know if my schema is invalid or if this represents a bug in lxml or libxml2. The error log shows the following error:
../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml:2:ERROR
:S CHEMASV:SCHEMAV_CVC_ELT_1: Element 'Authentication': No matching global declaration available for the validation root.
I'm not so firm with libxml2's XML Schema implementation, not sure what
that means exactly. Is it the only error you get in the log?
I get just one similar error in the log for every file I try to validate with this schema. Only the elements name changes.
The same code given diffrent files works fine. Does anyone have any ideas why I am getting this message?
You can check if "xmllint" (which is the command line tool that comes with libxml2) produces the same error. It is actually unlikely that this is an lxml problem, so this would tell you if libxml2 really thinks that your
file is invalid. In that case, you can ask on the libxml2 mailing list instead.
Okay here we go... jlovell@esd189-10545:~/SIF Toolkit/Data Generator$ xmllint --schema combined.txt ../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml <?xml version="1.0"?> <Authentication xmlns:ns3="http://www.w3.org/2001/XMLSchema" ns3:RefId="27D1CAEA85C2BAA647A01B551D21E1EB" ns3:SifRefId="211242238C60A55E25B2B86BB337C244" ns3:SifRefIdType="EmployeePersonal"> <AuthenticationInfo> <System xmlns:ns0="http://www.w3.org/2001/XMLSchema" ns0:Type="Application">&1<tNk44}F2</System> <Username>;pl}ee'-</Username> <DistinguishedName>mlZm@JD</DistinguishedName> <Password xmlns:ns1="http://www.w3.org/2001/XMLSchema" ns1:Algorithm="MD5" ns1:KeyName="(v4kSY.">l1uqg!</Password> </AuthenticationInfo> <SIF_ExtendedElements> <SIF_ExtendedElement xmlns:ns2="http://www.w3.org/2001/XMLSchema" ns2:Name="%~T=">ZE72n/l</SIF_ExtendedElement> </SIF_ExtendedElements> </Authentication> ../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml:2: element Authentication: Schemas validity error : Element 'Authentication': No matching global declaration available for the validation root. ../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml fails to validate You are right it isn't an lxml problem! Sorry, but I had to start somewhere.
Maybe you can also check with a different tool, that might give you more hints on what is wrong here.
Good idea here is the output from: http://www.xmlme.com/Validator.aspx Validation Results: Schema Error: System.Xml.Schema.XmlSchemaException: The targetNamespace parameter '' should be the same value as the targetNamespace 'http://www.sifinfo.org/infrastructure/1.x' of the schema. at System.Xml.Schema.BaseProcessor.SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) at System.Xml.Schema.SchemaCollectionPreprocessor.Preprocess(XmlSchema schema, String targetNamespace, Compositor compositor) at System.Xml.Schema.SchemaCollectionPreprocessor.Execute(XmlSchema schema, String targetNamespace, Boolean loadExternals, XmlSchemaCollection xsc) at System.Xml.Schema.XmlSchema.CompileSchema(XmlSchemaCollection xsc, XmlResolver resolver, SchemaInfo schemaInfo, String ns, ValidationEventHandler validationEventHandler, XmlNameTable nameTable, Boolean CompileContentModel) at System.Xml.Schema.XmlSchemaCollection.Add(String ns, SchemaInfo schemaInfo, XmlSchema schema, Boolean compile, XmlResolver resolver) at System.Xml.Schema.XmlSchemaCollection.Add(String ns, XmlReader reader, XmlResolver resolver) at System.Xml.Schema.XmlSchemaCollection.Add(String ns, XmlReader reader) at Validator.Button1_Click(Object sender, EventArgs e) Okay, so it is me. At this point, which mailing list should I be bothering? If you know how I can set the targetNamespace of my document to match my schema, please email me but consider carefully if it is appropriate to copy this list. Thanks for all your help, John W. Lovell Web Applications Engineer Northwest Educational Service District 1601 R Avenue Anacortes, WA 98221 www.esd189.org Together We Can ...
Hi,
I have a XML Schema that looks like this:
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sif="http://www.sifinfo.org/infrastructure/1.x" targetNamespace="http://www.sifinfo.org/infrastructure/1.x">
<import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
...
<element name="Authentication"> <complexType>
...
</schema>
I am trying to validate this data:
<?xml version="1.0"?> <Authentication xmlns:ns3="http://www.w3.org/2001/XMLSchema" ns3:RefId="27D1CAEA85C2BAA647A01B551D21E1EB" ns3:SifRefId="211242238C60A55E25B2B86BB337C244" ns3:SifRefIdType="EmployeePersonal">
Shouldn't <Authentication/> be from the namespace "http://www.sifinfo.org/infrastructure/1.x" in the instance document? How do other instance documents that validate fine differ? Holger -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
Hi,
I have a XML Schema that looks like this:
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sif="http://www.sifinfo.org/infrastructure/1.x" targetNamespace="http://www.sifinfo.org/infrastructure/1.x">
<import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
...
<element name="Authentication"> <complexType>
...
</schema>
I am trying to validate this data:
<?xml version="1.0"?> <Authentication xmlns:ns3="http://www.w3.org/2001/XMLSchema" ns3:RefId="27D1CAEA85C2BAA647A01B551D21E1EB" ns3:SifRefId="211242238C60A55E25B2B86BB337C244" ns3:SifRefIdType="EmployeePersonal">
Shouldn't <Authentication/> be from the namespace "http://www.sifinfo.org/infrastructure/1.x" in the instance document?
You are probably right (see my last post). However, I have been unable to figure out how to do that. I just received the O'Reilly XML Schema book so that should change. Although, if you would like to clue me in, that would be great.
How do other instance documents that validate fine differ?
Drastically, one is the very simple PO example while the schema I'm working with is about a half a megabyte. John W. Lovell Web Applications Engineer Northwest Educational Service District 1601 R Avenue Anacortes, WA 98221 www.esd189.org Together We Can ...
Thanks to Holger and Stefan: Holger was right on, my problem was with my instance document not the schema. For anyone this might help, here are my new results: jlovell@esd189-10545:~/SIF Toolkit/Data Generator$ xmllint --schema combined.txt ../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml <?xml version="1.0"?> <Authentication xmlns="http://www.sifinfo.org/infrastructure/1.x" RefId="27D1CAEA85C2BAA647A01B551D21E1EB" SifRefId="211242238C60A55E25B2B86BB337C244" SifRefIdType="EmployeePersonal"> <AuthenticationInfo> <System Type="Application">&1<tNk44}F2</System> <Username>;pl}ee'-</Username> <DistinguishedName>mlZm@JD</DistinguishedName> <Password Algorithm="MD5" KeyName="(v4kSY.">l1uqg!</Password> </AuthenticationInfo> <SIF_ExtendedElements> <SIF_ExtendedElement Name="%~T=">ZE72n/l</SIF_ExtendedElement> </SIF_ExtendedElements> </Authentication> ../1.5r1/XSD/Infrastructure/Authentication__Authentication.xml validates Thanks, John W. Lovell Web Applications Engineer Northwest Educational Service District 1601 R Avenue Anacortes, WA 98221 www.esd189.org Together We Can ...
participants (3)
-
jholg@gmx.de
-
John Lovell
-
Stefan Behnel