Issue with generating sources from xsd schema

I’m getting the following error when generating sources for my project. I have extracted a few common types to a schema called CommonTypes.xsd and I get the following error:

org.xml.sax.SAXParseException: src-resolve.4.1: Error resolving component 'nonEmptyString'. It was detected that 'nonEmptyString' has no namespace, but components with no target namesp
ace are not referenceable from schema document 'file:/C:/Workspace/CommonTypes.xsd'. If 'nonEmptyString' is
 intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'nonEmptyString' has no namespace, then an 'import' without a "namespace" attribute should
be added to 'file:/C:/Workspace/lps-performance-calculation-service/pcs-data/src/main/resources/xsd/calc/lps/CommonTypes.xsd'.

The following simple type is defined in my CommonTypes.xsd schema as below:

<xsd:schema xmlns:xsd=""
            elementFormDefault="qualified" attributeFormDefault="unqualified"
    <!-- import types -->
    <xsd:import namespace=""/>
    <!-- other common types -->
    <xsd:simpleType name="nonEmptyString">
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="1"/>
            <xsd:pattern value=".*[^s].*"/>

And line 241 which causes the error is below:

<xsd:complexType name="Message">
            <xsd:extension base="nonEmptyString">
                <xsd:attribute type="xsd:string" name="code" use="required"/>
                <xsd:attribute name="category" use="required">
                        <xsd:restriction base="xsd:token">
                            <xsd:enumeration value="Error"/>
                            <xsd:enumeration value="Info"/>
                <xsd:attribute type="xsd:string" name="component" use="required"/>

Do you have any idea what may cause the error? I’ve tried searching through StackOverflow and experimenting with the targetNamespace and xmlns, but with no success.


You are trying to refer to a simple type which has

  • name ‘nonEmptyString’
  • namespace “”

But the simple type ‘nonEmptyString’ is defined in this XSD, which has targetNamespace="". So you should be referring to a simple type which has

  • name ‘nonEmptyString’
  • namespace “”

You simply need to change this:

<xsd:extension base="nonEmptyString">

to this:

<xsd:extension base="types:nonEmptyString">