I created my XSD as follows:

Error checking xml schema

I want to make a simple scheme for empty elites

<product orderid="4"/> 

I created my XSD as follows:

 <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.netbeans.org/schema/first" xmlns:tns="http://xml.netbeans.org/schema/first" elementFormDefault="qualified"> <xsd:element name="product" type="prodtype"/> <xsd:complexType name="prodtype"> <xsd:attribute name="prodid" type="xsd:integer"/> </xsd:complexType> </xsd:schema> 

When validating XML on XSD, the following error appears:

  Error resolving component 'prodtype'. It was detected that 'prodtype' has no namespace, but components with no target namespace are not referenceable from schema document 'file:/D:/Teacher%20assistant%202011/First%20term/web%20services/test%20programs/BpelModule1/src/product.xsd'. If 'prodtype' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'prodtype' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:/D:/Teacher%20assistant%202011/First%20term/web%20services/test%20programs/BpelModule1/src/product.xsd'. 
+7
source share
2 answers

This will work by adding to the type 'tns:'.

 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.netbeans.org/schema/first" xmlns:tns="http://xml.netbeans.org/schema/first" elementFormDefault="qualified"> <xsd:element name="product" type="tns:prodtype"/> <xsd:complexType name="prodtype"> <xsd:attribute name="prodid" type="xsd:integer"/> </xsd:complexType> </xsd:schema> 

In this case, prodtype is defined in the target schema namespace: http://xml.netbeans.org/schema/first '. To reference it, you need to include the namespace that is defined in. In your example, we are trying to reference prodtype in a default namespace that is undefined.

+13
source

If you change your XSD and put xmlns="http://xml.netbeans.org/schema/first" in the xsd:schema element, it should work (this was for me)

+7
source

All Articles