Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type instead of ref? #23

Closed
pjanck opened this issue Oct 5, 2021 · 2 comments
Closed

type instead of ref? #23

pjanck opened this issue Oct 5, 2021 · 2 comments

Comments

@pjanck
Copy link
Contributor

pjanck commented Oct 5, 2021

Since #15 was prematurely closed, I'm opening a new issue to raise my concerns:

<xs:element ref="xs:restriction" minOccurs="1" maxOccurs="unbounded"/>

I did some digging here:

grafik

xs:restriction is a built-in data type of the namespace xs not an element, right? Therefore it should be type and not ref in my opinion.

@aothms
Copy link

aothms commented Oct 5, 2021

xs:restriction is not a built-in data type. Those are listed here in the spec https://www.w3.org/TR/xmlschema-2/#built-in-datatypes

I also want to stress the obligatory https://www.quora.com/Is-W3Schools-a-reliable-source here I don't think we should base our decisions on that source.

Also there are apparently other issues with xsd.exe handling ref incorrectly (although not very similar to this case) https://stackoverflow.com/questions/44028046/how-to-use-xsd-exe-with-attributegroup-ref I personally have mixed experience with automated codegen from XSD.

In my understanding, but I'm not an XML/XSD expert, and I know @berlotti has consulted people infinitely more knowledgeable than me on this regard, it's as you hinted on in the other issue, in this case mostly a matter of taste. When you use type, you declare something of that type but still need to give it a name local to your schema [in XML files that adhere to the schema you see the local name]. When you use ref you basically nest that thing verbatim in your schema [in XML files that adhere to the schema you see xs:restriction].

Another difference, but not relevant, but what's described in your table, is that type can only be used for, well, types. And ref is much more general, can be used for identifiable elements, including types.

@berlotti
Copy link
Member

berlotti commented Oct 5, 2021

It is an explicit choice to use the xs:restriction as is. We don't want to create an IDS restriction of the same type as an xs:restriction, but use the actual xs:restriction. This brings a lot of added value with the ability to use multiple toolkits for xs:restriction saving implementation time and adding consistency.

Combining two namespaces was a deliberate choice. The use of two namespaces in the XSD is not common, but valid.

Closing this issue.

@berlotti berlotti closed this as completed Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants