I have two xsd files (sc1.xsd, sc2.xsd). When I import one of them the the other there is a conflict because of some common elements/types.
How do I import sc2.xsd to sc1.xsd so I can use sc2 elements in sc1.xsd like this <element name="myelement" type="sc2:type1">
Asked
Active
Viewed 55 times
1 Answers
1
The precise rules for conflicts are a little implementation-dependent - if the processor can determine that two declarations are equivalent then it's allowed to ignore the duplicates. But if you have two declarations for the same name and they are different, that's an error and there's no way round it.
Michael Kay
- 156,231
- 11
- 92
- 164
-
I'm using xmlSpy and it's not ignoring it even if the declaration are equivalent... That's why I want to differentiate by using namespaces. – oklayness Feb 14 '18 at 12:58
-
@oklayness: You can only use namespaces to differentiate if you control both the importing and imported XSDs. Is that the case? If so, your solution is trivial. There's a harder case, raised by the duplicate link, where as Michael Kay says, equivalent declarations are encountered, often due to cycles in the import graph. The spec allows implementations to handle such cases differently. For such cases, you'll need an implementation-dependent solution such as Xerces' `honour-all-schemalocations` if you cannot break the cycles in your import graph. – kjhughes Feb 14 '18 at 13:24
-
You can call your type declarations anything you like, so you can always differentiate types by namespace. It's harder with element declarations, because the namespace in the schema has to match the namespace in the instance document. – Michael Kay Feb 14 '18 at 20:54