Stream: implementers
Topic: xsd not valid
V.Cuvelier (Jul 13 2021 at 07:39):
Hi,
I hope you are doing well today.
I must work in data integration on new project. The goal is the validation of all input flows using the FHIR norme v4.0.1.
I work with Websphere Transformation extender (IBM technology) and I am not familiar with the normative FHIR.
I download all xsd (v4.0.1: R4 - Mixed Normative and STU) on the official web page http://hl7.org/fhir/downloads.html.
1) I have an error while I try to import these xsd because there are not valid. The problem occurs for example on claim.xsd, fhir-base.xsd but lot of xsd are concerned by this problem. Following the error message, there is a problem with a reference of a type or a missing reference. You can find all errors that I encountered in the attachment report.txt. report.txt
2) Despite this problem, I found also this disclaimer in the xsd file :
Implementers will still need to be familiar with the content of the specification and with any profiles that apply to the resources in order to make a conformant implementation.
So, it means that the validation is a partial validation? I see that a validator exist in Java. This module is mandatory for the validation of the data?
3) I see also in the downloaded zip, some files with extension sch. Do you know what is the usage of these files?
If you have any advice, I'm more than interested.
Thank you very much in advance
Valentin Cuvelier
Rik Smithies (Jul 13 2021 at 10:19):
sch files are schematrons, an xml assertion language. They add some extra checks that xsd cannot do.
Rik Smithies (Jul 13 2021 at 10:22):
Re 2, yes, and all validation is partial validation ;-) But xsd is mainly for validating the broad structure, and cannot check all your codes and business rules. But that doesn't mean they are not helpful, especially when working with XML by hand.
Rik Smithies (Jul 13 2021 at 10:24):
The java validator is an alternative to the xsds, and is more complete. But may be less convenient - it depends what you are trying to do.
Rik Smithies (Jul 13 2021 at 10:26):
Your #1 is different. Let us know what the error is. The schemas should work ok, whether or not they are what you need. Some code complains about circular references, but it is actually legal.
V.Cuvelier (Jul 13 2021 at 10:40):
Hi Rik,
Thanks for your answer. It is more clear for me for point 2 and 3.
For first point, I try to validate the claim.xsd and it include the xsd fhir-base.xsd and I have the error for fhir-base.xsd.
You have all details in the report file (report.txt) which I attached in previous message.
Here, you have the first error that I encountered.
For fhir-base.xsd
This is the first error XML spy is producing.
The schema doesn't appear to be valid by itself (as a part of another schema, it might still be OK).
Value '(\s([0-9a-zA-Z\/\+\=]){4}\s)+' is not a valid XML regular expression.
Error location: xs:schema / xs:simpleType / xs:restriction / xs:pattern / @value
Details
invalid-escape: The given character escape is not recognized.
dt-pattern: Value '(\s*([0-9a-zA-Z*\/*\+\=]){4}\s*)+' is not a valid XML regular expression.
When we correct this problem, there are others errors like 'ResourceType' must refer to an existing simple or complex type.
It is really strange for me that the xsd are not valid. Maybe, there is something missing? The full zip that I downloaded. fhir-all-xsd.zip
Rik Smithies (Jul 13 2021 at 12:27):
There are some know problems with recent versions of the generated schemas, in the current build. But the R4 package is ok as far as I know. The date on those files of 28th June suggest these are from the build.
V.Cuvelier (Jul 14 2021 at 10:19):
Ok,
Nobody reproduce my problem?
I downloaded the official xsd and I cannot do anything with it. I try to search an older version. I find the specification 3.5a.0 and for older version but I cannot downloaded the xsd package. From this webpage http://hl7.org/fhir/2018Dec/downloads.html, we can downloaded the xsd version but we have this error message.
The file you were looking for was not found. If you arrived at this page from one of your bookmarks, or you believe the location of your file might have changed, you may find it beneficial to try one of the following:
Browse the HL7 Site Map
Search our website for your file.
Visit the HL7.org homepage.
Send an e-mail to webmaster@HL7.org.
So, it means the resource is not available now.
Maybe you have a working version? Where can I find it or can you share it?
Thank you in advance.
Rik Smithies (Jul 14 2021 at 12:17):
This is the direct link for 4.01 http://hl7.org/fhir/fhir-all-xsd.zip
I just downloaded this, loaded fhir-all.xsd into Oxygen, and it validated ok.
Shahim Essaid (Sep 14 2021 at 08:36):
I came across this issue in version 4.6.0 and latest build. There are many references to the complex type ResourceType that do not resolve. In 4.01 there is only one reference to this type, the reference is from ExampleScenario.Instance.resourceId, and the ResourceType is defined in examplescenario.xsd and it also shows up in fhir-single.xsd. In the newer builds there are many more references, 12 I think, to ResourceType but it is no longer defined in any of the XSD files or in fhir-single.xsd.
Shahim Essaid (Sep 14 2021 at 08:37):
I also get the following error in 4.6.0 for this XSD:
<xs:simpleType name="base64Binary-primitive">
<xs:restriction base="xs:base64Binary">
<xs:pattern value="(\s([0-9a-zA-Z\/\+\=]){4}\s)+"/>
</xs:restriction>
</xs:simpleType>
Error (in Visual Studio Code):
InvalidRegex: Pattern value '(\s([0-9a-zA-Z\/\+\=]){4}\s)+' is not a valid regular expression. The reported error was: 'This expression is not supported in the current option setting.'.
Lloyd McKenzie (Sep 15 2021 at 04:19):
@Grahame Grieve
Shahim Essaid (Sep 16 2021 at 04:59):
A little typo in my earlier post but can't edit to fix. It should be: ExampleScenario.Instance.resourceType (not .resourceId as I stated above) that is an example of where there is a reference to ResourceType.
Out of curiosity, I took a quick look at the JSON Schema for 4.0.1. The same path, ExampleScenario.Instance.resourceType, is not bound to the same enumeration/valueset as the XSD shows. It only says that ExampleScenario.Instance.resourceType is a code, not an enumeration of the valueset.
Grahame Grieve (Oct 13 2021 at 04:16):
@Shahim Essaid @Rik Smithies this will be fixed in 4.6.0 in a couple of days (when all my changes make their way into build.fhir.org. But: oxygen is complaining about this line:
Grahame Grieve (Oct 13 2021 at 04:16):
<xs:simpleType name="base64Binary-primitive">
<xs:restriction base="xs:base64Binary">
<xs:pattern value="\s*([0-9a-zA-Z\+\=]{4}\s*)+"/>
</xs:restriction>
</xs:simpleType>
Grahame Grieve (Oct 13 2021 at 04:16):
I can't see why - that's a valid pattern as far as I'm concerned.
Shahim Essaid (Oct 13 2021 at 05:19):
@Grahame Grieve I don't think the escapes are needed in the character class.
Grahame Grieve (Oct 13 2021 at 05:42):
since when was that a problem though?
Rik Smithies (Oct 13 2021 at 11:55):
Its the "\=" I think.
From a recent build I have this:
<xs:pattern value="(\s*([0-9a-zA-Z*\/*\+\=]){4}\s*)+"/>
Neither Xerces nor Saxon like that.
But they are ok with this:
<xs:pattern value="(\s*([0-9a-zA-Z*/*\+=]){4}\s*)+"/>
Presumably the "/" and "=" don't need escaping. The forward slash isn't there at all in your new version.
These are not mentioned here as special characters,
https://www.w3.org/XML/2008/03/xsdl-regex/re.xml
"A metacharacter is either ., \, ?, *, +, {, } (, ), |, [, or ]. "
Maybe some parsers leniently allow the escape character in places where it isn't meant to be.
Shahim Essaid (Oct 13 2021 at 13:55):
Inside a character class most meta characters are regular characters according to: https://www.regular-expressions.info/xml.html and the section about metacharacters here https://www.regular-expressions.info/charclass.html#special
Looking at the spec here https://www.w3.org/TR/xmlschema-2/#cces only the one before the "=" seems to be the problem. I confirmed that the error goes away in VSC if I only remove the one before the equals sign.
Rik Smithies (Oct 13 2021 at 14:41):
@Shahim Essaid Does this page https://www.w3.org/TR/xmlschema-2/#cces allow "\/"? In Oxygen it is not enough to just remove the one before equals.
Shahim Essaid (Oct 13 2021 at 14:57):
@Rik Smithies I meant only removing the one before the equals from Grahame's example works. "\/" is not a valid escape sequence according to the XSD regex grammar shown at that link/table.
Shahim Essaid (Oct 13 2021 at 14:59):
The way I'm understanding this is that first the escape sequence has to be legal according to that link. But, inside a character class, less escaping is needed but it's still allowed. Removing the \ from your \/ and \= example fixes the error in VSC.
Rik Smithies (Oct 13 2021 at 15:17):
yes good point - Grahame has already removed \/ in his new version.
Grahame Grieve (Oct 13 2021 at 19:48):
https://jira.hl7.org/browse/FHIR-34126
Last updated: Apr 12 2022 at 19:14 UTC