Feb 5, 2022 19:44
Please restate your current confusion as a single question. I will attempt once more to answer but only if I see this converging. I've already extended this discussion well beyond what this Q/A site is designed to support. Back-and-forth that cannot converge promptly is no longer Q/A -- it's a tutoring session or a consulting engagement.
Feb 5, 2022 16:05
So, if you want to use the SoS, you're free to hardcode its location and retrieve it (ugh), distribute the SoS with your code or embed it in your code (less ugh), or just use it during development (most likely).
Feb 5, 2022 15:58
(2, cont) There's no requirement that your code ever has to pull in the SoS to do so.
Feb 5, 2022 15:57
(1) Remember, XSD location is not tied to namespace URIs, which absolutely do not have to be retrievable -- see as just a unique identifier that follows URL syntax as a convenient mechanism to leverage domain name authority. (2) As an XSD processor author, there's no reason that your code has to look-up the SoS, and there's certainly no reason that you would ever want to make a network call to do so even if you wanted to retrieve the SoS. You have to implement the W3C Recommendation.
Feb 5, 2022 15:53
You state that you understand everything explained in the duplicate links and my comment, yet you still ask "How to link the Uri of w3.org/2001/XMLSchema to the real URL of it automatically." Focussing on your restatement of your question regarding the schema of schemas (SoS)...
Feb 5, 2022 15:53
As an XSD author, there is absolutely no need to link to the SoS because an XSD processor will apply its constraints in an implementation-dependent manner (and this is not only allowed but is entirely normal and common). As an XSD processor author, you have the freedom to use or not use the schema of schemas directly -- it doesn't matter as long as you implement the vocabulary and grammar expressed there. Perhaps it would help to realize that the schema of schemas, while normative, is incomplete -- there are more constraints in the Recommendation than are expressed in SoS.
Feb 5, 2022 15:53
The schema for schemas doesn't have to be referenced because XSDs processors work fine with an implicit understanding of XSD semantics. Answers to the rest of your questions (btw, too many for a single post) can be found in the duplicate links.
 
Dec 28, 2021 23:05
Been around and misdiagnosed enough problems to know how it goes. :-)
Dec 28, 2021 23:05
You're welcome!
Dec 28, 2021 23:04
I'm glad we were able to figure it out together.
Dec 28, 2021 22:59
xml_file = etree.parse(args.XSD, parser=recovering_parser)
Dec 28, 2021 22:59
Are you sure you want this:
Dec 28, 2021 22:57
That error suggests it's trying to validate the XSD.
Dec 28, 2021 22:54
Show me the error?
Dec 28, 2021 22:53
ok
Dec 28, 2021 22:52
Do that, and make sure that file:///C:/Users/sleon/source/repos/XML_Validator/crst.xsd comes up when you type that into a browser.
Dec 28, 2021 22:52
And you removed the noNamespaceSchemaLocation for that test?
Dec 28, 2021 22:50
(The command line with the absolute path.)
Dec 28, 2021 22:50
Show that to me.
Dec 28, 2021 22:49
And have you ever gotten this code to work in the past?
Dec 28, 2021 22:47
What did you try?
Dec 28, 2021 22:45
Make sure your command line specification of the location of the XSD is also correct. (Usually -- for conforming XML/XSD processors -- xsi:noNamespaceSchemaLocation is sufficient. You should never need to specify it in both places.)
Dec 28, 2021 22:43
The way you have xsi:noNamespaceSchemaLocation in your file is fine, provided that you use one of the path syntaxes found in my answer. What you had wouldn't work as is.
Dec 28, 2021 22:41
And your command line?
Dec 28, 2021 22:41
Oh I see.
Dec 28, 2021 22:40
What is args.XSD? I don't see it defined anywhere.
Dec 28, 2021 22:40
xml_validator = etree.XMLSchema(file= args.XSD)
Dec 28, 2021 22:40
I see you've updated the question with your python code. In this line,
Dec 28, 2021 22:39
This points to the problem being in lxml or in the way you're trying to specify the XSD location there too.
Dec 28, 2021 22:39
And over the course of the comments, you've verified that the path to the XSD is correct in two ways: same dir or absolute path to different local dir.
Dec 28, 2021 22:38
At the XML and XSD level, you're good.
Dec 28, 2021 22:37
Do you have time to hammer this out in chat live right now?
Dec 28, 2021 22:37
Hi Sam
Dec 28, 2021 22:37
Have you proved file:///C:/Users/usr/source/repos/proj/XSD.xsd is correct and accessible by pulling it up in a browser as I show in the first See also link?
Dec 28, 2021 22:37
Your XML and XSD are fine. You've validated the path to the XSD (1) via Notepad validation and (2) via browser test of the absolute path. XML/XSD processors that use xsi:noNamespaceSchemaLocation properly should require no further help in finding the XSD. This may be an issue with lxml support for xsi:noNamespaceSchemaLocation. Try explicitly telling lxml where the XSD is: Example.
Dec 28, 2021 22:37
lxml documentation does say, XML schema is supported in a similar way, but requires an explicit schema to be provided.
Dec 28, 2021 22:37
That's not the right syntax for the Window's path here. Use the pattern I show.
Dec 28, 2021 22:37
Which XSD locations are failing to validate in lxml?
Dec 28, 2021 22:37
Try the absolute path. If you're on Windows, the drive goes in like this: file:///c:/path/to/my.xsd
 
May 1, 2021 19:15
You're welcome. I'll summarize an answer that covers our chat. Good luck.
May 1, 2021 19:12
All set?
May 1, 2021 19:11
The descendant elements of Roster would have to be declared locally.
May 1, 2021 19:10
The second screen shot shows only a type declaration -- no element declaration. But, yes, if you only want a Roster element to be possible as a root element, make sure it's the only global element declaration in your XSD.
May 1, 2021 19:08
To prevent this, only declare a single element at the root level of the XSD.
May 1, 2021 19:07
Related concern: Any root-level elements declared in an XSD are allowed to be used as a root element in an XML document.
May 1, 2021 19:06
You write an XSD to express the vocabulary and grammar allowed by an XML document. You can then validate the XML against the XSD to learn of any violations of the constraints specified by the XSD.
May 1, 2021 19:03
The notion of creating files (with or without extensions) is utterly foreign to XSD, so that question makes no sense. If you have another tool that's using XSD in such a manner, you're asking about that tool, not about XSD.
May 1, 2021 19:01
So does any problem remain unsolved?
May 1, 2021 18:59
Once you resolve that problem, let me know if you're good-to-go or if you're still trying to "prevent" something.