cancel
Showing results for 
Search instead for 
Did you mean: 

Namespace could not be referenced in the schema

former_member203641
Participant
0 Kudos

Hi,

I am having the xsd in which I am creating some elements which are being referenced from their definition while in the Microsoft Visual Administration tool editor I could see that it gives message that Namespace could not be referenced while I have defined the element type  in the same xsd

e.g.

namespace definition

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:gen="http://www.abc/isd/General" targetNamespace="http://www.abc.uk/isd/General" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.10" id="general">

definition

<xsd:simpleType name="LEGAL_STATUS_TYPE">

<xsd:union>

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:enumeration value="Formal"/>

     <xsd:enumeration value="Informal"/>

    </xsd:restriction>

   </xsd:simpleType>

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:minLength value="1"/>

     <xsd:maxLength value="35"/>

    </xsd:restriction>

   </xsd:simpleType>

  </xsd:union>

</xsd:simpleType>

declaration

<xsd:element name="LegalStatus" type="gen:LEGAL_STATUS_TYPE" minOccurs="0" maxOccurs="unbounded"/>

Any idea why this problem is occurring?

Thanks,

Amit

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Amit,

Instead of

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:gen="http://www.abc/isd/General" targetNamespace="http://www.abc.uk/isd/General" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.10" id="general">

Try using

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:gen="http://www.abc/isd/General"

xmlns="http://www.abc.uk/isd/General" targetNamespace="http://www.abc.uk/isd/General" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.10" id="general">

A target namespace still needs an xmlns declaration without a prefix.

Hope this helps,
Mark

former_member203641
Participant
0 Kudos

Mark,

Even xmlns declaration is there in the xsd document header but it did not get copied in my post I guess.

I would explain you the exact thing which I am doing..

I have a xsd which has unions and choice tags which PI does not support so I changed the unions to complexTypes with enumerations as AllowedValues element and length restrictions as FreeValue element.

e.g. for above case I changed it to

<xsd:element name="LEGAL_STATUS_TYPE">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="AllowedValues" minOccurs="0">

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:enumeration value="Formal"/>

     <xsd:enumeration value="Informal"/>

    </xsd:restriction>

   </xsd:simpleType>

</xsd:element>

<xsd:element>

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:minLength value="1"/>

     <xsd:maxLength value="35"/>

    </xsd:restriction>

   </xsd:simpleType>

</xsd:element>

  </xsd:sequence>

</xsd:complexType>

</xsd:element>

As soon as I do this the xsd document now gives error that type LEGAL_STATUS_TYPE is not declared.

Thanks,

Amit

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Amit,

Since xsd:union is not supported, the best you can do is to retain the simpleType and then combine the restrictions (as long as it is only one type) e.g:

<xsd:simpleType name="LEGAL_STATUS_TYPE">

     <xsd:restriction base="xsd:string">

          <xsd:enumeration value="Formal"/> 

          <xsd:enumeration value="Informal"/>

          <xsd:minLength value="1"/>

          <xsd:maxLength value="35"/>

     </xsd:restriction>

</xsd:simpleType>

As for xsd:choice, it will appear as 0..1 so no problems with that.

Hope this helps,

Mark

Answers (2)

Answers (2)

former_member203641
Participant
0 Kudos

All,

Solved my problem. I was referring to element by changing simpleType to element so as to avoid union which is not supported in proxies.

e.g. following was the original xsd and its reference.

<xsd:simpleType name="LEGAL_STATUS_TYPE">

<xsd:union>

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:enumeration value="Formal"/>

     <xsd:enumeration value="Informal"/>

    </xsd:restriction>

   </xsd:simpleType>

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:minLength value="1"/>

     <xsd:maxLength value="35"/>

    </xsd:restriction>

   </xsd:simpleType>

  </xsd:union>

</xsd:simpleType>

<xsd:element name="LegalStatus" type="gen:LEGAL_STATUS_TYPE" minOccurs="0" maxOccurs="unbounded"/>

To avoid unions from xsd I was changing LEGAL_STATUS_TYPE to element from a simpleType as shown below

<xsd:element name="LEGAL_STATUS_TYPE">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="AllowedValues" minOccurs="0">

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:enumeration value="Formal"/>

     <xsd:enumeration value="Informal"/>

    </xsd:restriction>

   </xsd:simpleType>

</xsd:element>

<xsd:element>

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:minLength value="1"/>

     <xsd:maxLength value="35"/>

    </xsd:restriction>

   </xsd:simpleType>

</xsd:element>

  </xsd:sequence>

</xsd:complexType>

</xsd:element>

Since element cannot be type referred so below line in xsd was giving me the error that namespace could not be referred.

<xsd:element name="LegalStatus" type="gen:LEGAL_STATUS_TYPE" minOccurs="0" maxOccurs="unbounded"/>

Solved it by again declaring it as complexType like below instead of element and problem was solved

<xsd:complexType name="LEGAL_STATUS_TYPE">

<xsd:sequence>

<xsd:element name="AllowedValues" minOccurs="0">

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:enumeration value="Formal"/>

     <xsd:enumeration value="Informal"/>

    </xsd:restriction>

   </xsd:simpleType>

</xsd:element>

<xsd:element name="FreeValues" minOccurs="0">

   <xsd:simpleType>

    <xsd:restriction base="xsd:string">

     <xsd:minLength value="1"/>

     <xsd:maxLength value="35"/>

    </xsd:restriction>

   </xsd:simpleType>

</xsd:element>

  </xsd:sequence>

</xsd:complexType>

Reply from Mark was helpful but unfortunately saw that after I implemented it same way .

Thanks,

Amit

baskar_gopalakrishnan2
Active Contributor
0 Kudos

I see gen is the namespace prefix given in the declaration.  So it could not find it. In your targetnamespace specify xmlns:gen as prefix... This would solve your problem. Also use xmlspy or online schema validator for validation.

refer this link for doing this

http://publib.boulder.ibm.com/infocenter/radhelp/v7r5/index.jsp?topic=%2Fcom.ibm.ccl.soa.sdo.xsd.ui....

former_member203641
Participant
0 Kudos

Baskar,

Can you tell me exactly what do you mean by specifying it in target namespace?

because it is already there in the tag <xsd:schema>

Thanks,

Amit