You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ids.XSD - Invalid xs:element ref="xs:restriction" in idsValue #423
Background:
Started building a Plugin for IDS-Data-Exchange and run into technical problems, as the current IDS.xsd is not fit for automatic validation in standard .XSD parser, due to technical mistakes. Did not find any corresponding issue here. Please point me when I’m wrong (2 of 2). New to the party. Programming civil engineer and CAD dev. Hi! Description:
The ids:idsValue complex type definition includes an xs:element ref="xs:restriction" within its xs:choice group. Problem:
xs:restriction is a schema-defining component used to derive new types by restricting existing ones (see XML Schema Part 1: Structures Second Edition, Section 2.1.3). It is not an element that should appear in an XML instance document, nor is it valid to be referenced by an xs:element for inclusion in a content model. This construct makes the schema invalid. Impact:
The schema fails validation with standard XSD processors. It also indicates an unclear intent for representing restricted values in the instance document. As I scrolled through many issue even the intent of using it doesn’t statisfy the desired functionality. As this is the most used DataType, it is crucial to get it right! Suggested Fix:
Introduce a own restriction class instead of Xs-restriction, with all that community requested condition possibilities: eg. MinValue, MaxValue, MinOccurs, HasToBeUnique, Pattern.
@spaih Thank you very much for this workaround! I am using it as suggested for formal verification of IDS files.
However, when reviewing the definitions for max/minLength, I encountered a problem. I wonder why the proposed length restrictions differ from the definitions for min/max/In/Exclusive. Is there a reason for this?
If not, I would suggest using minLength and maxLength similarly to the other definitions. I also suggest adding length as an additional option.
Just for completeness: In the XML schema there are even more options for the restriction element, but they may not be of interest (totalDigits, whiteSpace, fractDigits).
Regarding the original issue, I agree that the re-use of xs:restriction in the IDS schema needs review in a future release. Partly because we're making life more complex for IDS implementors using the XSD, but also because as @MatthiasWeise has picked up, it's introducing ambiguity in IDS files if people use xs:restriction elements where the intent is not specified in the IDS domain. E.g xs:assertion or xs:whitespace amongst others
e.g. a user could specify totalDigits, whiteSpace, fractDigits etc but, can we guarantee the expected behaviour across the different IDS implementations? There's no reference to these restriction types in the IDS documentation and no IDS test cases either.
It feels like IDS should have extracted the parts we needed into our schema rather than wholesale reference it - which is ultimately what is happening in @spaih's solution above -and in the schema generator in this repo itself.
It may be worth referencing #442 (comment) for details of how you can build code using the current xsd - and how the idslib audit tool handles this.
Here we could also insert the optional much requested "HasToBeUnique" Boolean.
May be worth reviewing #398 (comment) for a proposal on implementing uniqueness in IDS
To add to @spaih's point, I’ve found that some modern XSD libraries (specifically the xmlschema library in Python) do not flag ref="xs:restriction" as an error because of the explicit import of http://www.w3.org/2001/XMLSchema at the top of the file.
While this allows the schema to 'pass' validation technically, it creates a massive semantic blind spot. The validator treats the restriction as a literal XML data block rather than an active validation rule. This explains why this hasn't been caught by all automated tools yet: the schema is technically resolvable but functionally broken for its intended purpose of data constraint.
I understand this was probably intended to be elegant (borrowing literal XSD syntax for IDS, since a parallel is drawn between IDS for IFC and XSD for XML), but it beats the purpose IMO. IDS should use it's own keyword here.
Activity
spaih commentedon Jul 22, 2025
For a technical Fix i did the followin:
Replace
<xs:element ref="xs:restriction" minOccurs="1" maxOccurs="1"/>with
<xs:element ref="ids:restriction" minOccurs="1" maxOccurs="1"/>add
So we make the restriction custom. Here we could also insert the optional much requested "HasToBeUnique" Boolean.
this works with existing .ids files when something like
is called. That moves the xs:restriction and all it's childs to the ids namespace, that we custom-defined above.
I'm just trying to help here to get the standard following the offical XML schema rules, not because I like to complicate things.
NOTE: There were multiple Edit required to come to a solution that works for current IDS files with a standard XSD parser.
MatthiasWeise commentedon Dec 17, 2025
@spaih Thank you very much for this workaround! I am using it as suggested for formal verification of IDS files.
However, when reviewing the definitions for max/minLength, I encountered a problem. I wonder why the proposed length restrictions differ from the definitions for min/max/In/Exclusive. Is there a reason for this?
If not, I would suggest using minLength and maxLength similarly to the other definitions. I also suggest adding length as an additional option.
Just for completeness: In the XML schema there are even more options for the restriction element, but they may not be of interest (totalDigits, whiteSpace, fractDigits).
andyward commentedon Dec 17, 2025
Regarding the original issue, I agree that the re-use of
xs:restrictionin the IDS schema needs review in a future release. Partly because we're making life more complex for IDS implementors using the XSD, but also because as @MatthiasWeise has picked up, it's introducing ambiguity in IDS files if people usexs:restrictionelements where the intent is not specified in the IDS domain. E.gxs:assertionorxs:whitespaceamongst otherse.g. a user could specify totalDigits, whiteSpace, fractDigits etc but, can we guarantee the expected behaviour across the different IDS implementations? There's no reference to these restriction types in the IDS documentation and no IDS test cases either.
It feels like IDS should have extracted the parts we needed into our schema rather than wholesale reference it - which is ultimately what is happening in @spaih's solution above -and in the schema generator in this repo itself.
It may be worth referencing #442 (comment) for details of how you can build code using the current xsd - and how the
idslibaudit tool handles this.May be worth reviewing #398 (comment) for a proposal on implementing uniqueness in IDS
pierremonico commentedon Jan 20, 2026
To add to @spaih's point, I’ve found that some modern XSD libraries (specifically the xmlschema library in Python) do not flag ref="xs:restriction" as an error because of the explicit import of http://www.w3.org/2001/XMLSchema at the top of the file.
While this allows the schema to 'pass' validation technically, it creates a massive semantic blind spot. The validator treats the restriction as a literal XML data block rather than an active validation rule. This explains why this hasn't been caught by all automated tools yet: the schema is technically resolvable but functionally broken for its intended purpose of data constraint.
I understand this was probably intended to be elegant (borrowing literal XSD syntax for IDS, since a parallel is drawn between IDS for IFC and XSD for XML), but it beats the purpose IMO. IDS should use it's own keyword here.