0

guys. Here's a question. Look at the XML file first.

    <?xml version="1.0" encoding="UTF-8"?>
<root>
    <gun:shop xmlns:gun="https://www.gun-shop.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.gun-shop.com/ example_schema1.xsd">
        <gun:guns>
            <gun:gun name="Revolver" price="1250$" max_ammo="7" />
            <gun:gun name="M4A1" price="3250$" max_ammo="30" />
            <gun:gun name="9mm Pistol" price="450$" max_ammo="12" />
        </gun:guns>
    </gun:shop>

    <fish:shop xmlns:fish="https://www.fish-shop.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.fish-shop.com/ example_schema2.xsd">
        <fish:fishes>
            <fish:fish name="Shark" price="1000$" />
            <fish:fish name="Tuna" price="5$" />
            <fish:fish name="Capelin" price="1$" />
        </fish:fishes>
    </fish:shop>
</root>

I tried to connect two schemas for two different namespaces, but it doesn't work. Schemas don't validate anything. Can somebody answer to the question is "how to connect 2+ XSD schemas and use them in XML"?

P.S. Schemas contains nothing but one element. For gun is "gun" element and for fish is "fish" element. Here is no validation errors are occured in my IDE.

rapid88
  • 25
  • 4
  • Oh, yeah, I forgot. targetNamespaces in schemas equal to gun and fish namespaces. In example_schema1.xsd's targetNamespace equals to https://www.gun-shop.com/ and the same with example_schema1.xsd's targetNamespace and https://www.fish-shop.com/ . – rapid88 May 05 '18 at 13:42
  • *I tried to connect two schemas for two different namespaces, but it doesn't work.* Show us your XSDs so that we can be specific in our help. A single XSD that uses [**`xsd:import`**](https://stackoverflow.com/q/2357943/290085) to bring in the other two is the general answer. – kjhughes May 05 '18 at 16:35

0 Answers0