I am quite fresh with XML and even though I have managed quite well, I am now stuck with this tricky situation concerning XML Schema. Below you can see my XML document code and its respective Schema code. Firstly here is mine XML document code.
<?xml version="1.0" encoding="UTF-8"?>
<Cars
xmlns="http://www.verkkokauppa.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.verkkokauppa.com 4Schema.xsd">
<Car>
<Brand>BMW</Brand>
<Model>535d</Model>
<Gear>Automatic</Gear>
<Year>2007</Year>
<Info>It's a german.</Info>
</Car>
</Cars>
And below you can see my representative Schema code
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.verkkokauppa.com" xmlns="http://www.verkkokauppa.com" elementFormDefault = "qualified"> <xsd:element name = "Brand" type = "xsd:string"/> <xsd:element name = "Model" type = "xsd:string"/> <xsd:element name = "Gear" type = "xsd:string"/> <xsd:element name = "Year" type = "xsd:int"/> <xsd:element name = "Information" type = "xsd:string"/> <xsd:complexType name = "CarType"> <xsd:sequence> <xsd:element ref = "Brand"/> <xsd:element ref = "Model"/> <xsd:element ref = "Gear"/> <xsd:element ref = "Year"/> <xsd:element ref = "Information" minOccurs = "0" maxOccurs = "1" /> </xsd:sequence> </xsd:complexType> <xsd:element name = "Cars"> <xsd:complexType> <xsd:sequence> <xsd:element name = "Car" type = "CarType" maxOccurs = "unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
Now, whenever I try to validate my XML document code I get an error: "cvc-elt.1: Cannot find the declaration of element 'Cars'. [6] "
This I think is to do with a namespace issue on the Cars element which is my root element, but I am really not sure.
If there is anyone who could guide me with this, I'd be most thankful.