-
Notifications
You must be signed in to change notification settings - Fork 21
Support duplicated type identifiers across schema files #210
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
Conversation
060ab89 to
2668cdf
Compare
7618ca3 to
baf8c07
Compare
|
Looks good! I noticed two things: My override for a built-in type config.interpreter.types.push((IdentTriple::from((IdentType::BuildIn, None, "bool")), MetaType {
display_name: None,
documentation: vec![],
form: None,
schema: None,
variant: MetaTypeVariant::Custom(CustomMeta::new("MsBool")),
}));stopped working and I had to change it to: config.interpreter.types.push((IdentQuadruple::from((IdentType::BuildIn, NamespaceIdent::Id(NamespaceId::UNKNOWN), None::<SchemaIdent>, "bool")), MetaType {The second observation concerns groups. Given the following schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bar="Bar" xmlns:baz="Baz">
<xs:import schemaLocation="bar.xsd" namespace="Bar" />
<xs:import schemaLocation="baz.xsd" namespace="Baz" />
<xs:complexType name="Outer">
<xs:sequence>
<xs:group ref="bar:Inner" />
<xs:group ref="baz:Inner" />
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="Bar" targetNamespace="Bar" elementFormDefault="qualified">
<xs:group name="Inner">
<xs:sequence>
<xs:element name="A" type="xs:string" />
</xs:sequence>
</xs:group>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="Baz" targetNamespace="Baz">
<xs:group name="Inner">
<xs:sequence>
<xs:element name="B" type="xs:string" />
</xs:sequence>
</xs:group>
</xs:schema>Previously this would create the |
Strange, I though I've added fallbacks for the old type 🤔 I will check this.
Ok. I'll have a look too and add a suitable test to catch this. Might be possible that the new stack entry broke some stuff. |
Some XML schemas reuse the same type name in different files. While this pattern isn't fully spec-compliant, it occurs in real world schemas so we have to support it too. This also makes implementing future support for `xs:redefine` and `xs:override` easier. This commit restructures identifier handling: - Split the previous `Ident` type into distinct `TypeIdent`, `NodeIdent`, and `PropertyIdent`, reducing ambiguity between kinds of identifiers. - Make `TypeIdent` include a `SchemaId`, so the generator knows which schema the type came from in addition to its namespace. - Update the `Interpreter` and related logic to correctly resolve and differentiate types even when they share the same name across files. These changes allow `xsd-parser` to handle duplicated type names across schema files in a coherent way and lay groundwork for future override support.
baf8c07 to
6791d55
Compare
|
Hey @main--, I had some time today to address your findings.
This is cause because I changed this: impl<N, X> From<(IdentType, N, X)> for IdentTriple
where
N: Into<Option<NamespaceIdent>>,
X: Into<String>,
{
fn from((type_, ns, name): (IdentType, N, X)) -> Self {
/* ... */
}
}Into this: impl<N, X> From<(IdentType, N, X)> for IdentQuadruple
where
N: Into<NamespaceIdent>,
X: Into<String>,
{
fn from((type_, ns, name): (IdentType, N, X)) -> Self {
/* ... */
}
}
impl<N, X> From<(IdentType, Option<N>, X)> for IdentQuadruple
where
N: Into<NamespaceIdent>,
X: Into<String>,
{
fn from((type_, ns, name): (IdentType, Option<N>, X)) -> Self {
/* ... */
}
}So you now have to either specifiy the exact type of your passed I known this is some kind of breaking change of the public API, but I would like to keep it as is, because the new implementation gives you the option to construct the value like so
I fixed that and added a suitable test. |
That's not what I meant. The problem is that I can confirm that the groups are back to the old behavior now. 👍 |
|
Ah, Ok. Now I got it. The new approach makes a difference between the "anonymous" namespace and "this namespace is unknown", which were both covered by |
Some XML schemas reuse the same type name in different files. While this pattern isn't fully spec-compliant, it occurs in real world schemas so we have to support it too. This also makes implementing future support for
xs:redefineandxs:overrideeasier.This commit restructures identifier handling:
Identtype into distinctTypeIdent,NodeIdent, andPropertyIdent, reducing ambiguity between kinds of identifiers.TypeIdentinclude aSchemaId, so the generator knows which schema the type came from in addition to its namespace.Interpreterand related logic to correctly resolve and differentiate types even when they share the same name across files.These changes allow
xsd-parserto handle duplicated type names across schema files in a coherent way and lay groundwork for future override support.This is a fork/rewrite of the original PR provided by @main-- in #186.
Related to #156.