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

teach xsd.Schema how to merge type maps #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidalpert
Copy link
Contributor

a new MergeTypes method is added to the xsd.Schema type
which merges the types from one xsd.Schema into another
provided that the TargetNS values are equivalent.

this MergeTypes method is then used when collecting
the map of namespaces to schemas so that when a single
schema is spread across multiple files (e.g. when
imports are used to tie them together) the types from
a namespace are all collected together, regardless of
which files they came from.

this allows the resolvePartialTypes method to operate
as expected, since following the imports will now
merge the types into a single xsd.Schema.

a new MergeTypes method is added to the xsd.Schema type
which merges the types from one xsd.Schema into another
provided that the TargetNS values are equivalent.

this MergeTypes method is then used when collecting
the map of namespaces to schemas so that when a single
schema is spread across multiple files (e.g. when
imports are used to tie them together) the types from
a namespace are all collected together, regardless of
which files they came from.

this allows the resolvePartialTypes method to operate
as expected, since following the imports will now
merge the types into a single xsd.Schema.
previously when a single target namespace was spread across
multiple files, the last schema file read for each target namespace
would clobber any previously read type maps

this commit adds some minimal target namespace collision
detection and delegates to the xsd.Schema class the responsibility
to resolve that conflict.
// the receiving schema, returns error if the schemas have
// different target namespaces.
func (s *Schema) MergeTypes(incoming *Schema) error {
if !strings.EqualFold(s.TargetNS, incoming.TargetNS) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that XML namespaces are case sensitive. What is the reason for using EqualFold over == here?

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

Successfully merging this pull request may close these issues.

None yet

2 participants