I have some XML that I'm trying to parse against a schema and I'm getting odd errors.
First, the .xsd schema looks like:
<?xml version="1.0"?><xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema"xmlns="http://xml.example.com/thing"targetNamespace="http://xml.example.com/thing">
.... lots of elements ....
<xs:elementname="CmdServerResponse"><xs:complexType>
.... more stuff ....
</xs:complexType></xs:element></xs:schema>
Now the XML I'm trying to parse looks like this:
<CmdServerResponsexmlns="http://xml.example.com/thing">
... lots of tags ....
</CmdServerResponse>
The parse Fails with:
pyxb.exceptions_.UnrecognizedContentError: UnrecognizedContentError: too few
Now if I change the xml to include the namespace prefix (xmlns:TH), it parses just fine.
<TH:CmdServerResponsexmlns:TH="http://xml.example.com/thing">
... lots of tags ....
</TH:CmdServerResponse>
My problem is, my XML is coming from a Legacy source and I can not modify it on that end. So, Is a default namespace specifier xmlns without a prefix out of spec or is this a bug? Am I going to have to do some translations and put in that prefix before I let PyXB parse it?
Thank You
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, that should all work fine. The Unrecognized Content Error "too few" is a cryptic indication that the incoming document does not validate: the content model has a minimum occurrence requirement that is not met. You might try adding
pyxb.RequireValidWhenParsing(false)
to see what happens when validation is turned off.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Greetings,
I have some XML that I'm trying to parse against a schema and I'm getting odd errors.
First, the .xsd schema looks like:
Now the XML I'm trying to parse looks like this:
The parse Fails with:
Now if I change the xml to include the namespace prefix (xmlns:TH), it parses just fine.
My problem is, my XML is coming from a Legacy source and I can not modify it on that end. So, Is a default namespace specifier xmlns without a prefix out of spec or is this a bug? Am I going to have to do some translations and put in that prefix before I let PyXB parse it?
Thank You
Sorry, Those semicolons after the <CmdServerResponse> Tags are not actually there. Typo.
No, that should all work fine. The Unrecognized Content Error "too few" is a cryptic indication that the incoming document does not validate: the content model has a minimum occurrence requirement that is not met. You might try adding
to see what happens when validation is turned off.