I have an xml fragment for which I need to write XSD
<root xmlns="http://xmlns.oracle.com/sca/1.0" xmlns:id="http://xmlns.oracle.com/id/1.0">
<service name="Book" id:number="465"/>
</root>
The following XSD gives error while JAXB class generation.
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/sca/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="service">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name"/>
<xs:attribute ref="ns:number" xmlns:ns="http://xmlns.oracle.com/id/1.0"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Error is
C:\Program Files\Java\jdk1.7.0_06\bin>xjc -p test C:\book.xsd parsing a schema... [ERROR] src-resolve.4.2: Error resolving component 'ns:number'. It was detected that 'ns:number' is in namespace 'http://xmlns.oracle.com/id/1.0', but component s from this namespace are not referenceable from schema document 'file:/C:/book. xsd'. If this is the incorrect namespace, perhaps the prefix of 'ns:number' need s to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/C:/book.xsd'. line 10 of file:/C:/book.xsd