The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,225 other subscribers

XSD/XML Schemas: resolving `Namespace ” is not available to be referenced in this schema` (via: StackOverflow)

Posted by jpluimers on 2013/09/01

While working on my Delphi: First try on an XSD for .groupproj files, I bumped into an error `Namespace ” is not available to be referenced in this schema`.

I added a targetNamespace attribute to the GroupProj.xsd so the .grouproj files would use the right namespace.

That resulted into two funny errors:

  1. Namespace ” is not available to be referenced in this schema.
    Visual Studio (which I normally use for editing XSD) would only throw this error on these elements:
    <xsd:element ...>
    So it would not throw them on nodes using the empty namespace.
    That was really confusing!
  2. When validating .grouproj files using this GroupProj.xsd, I would get this error for all .groupproj files:
    System.Xml.Schema.XmlSchemaValidationException: Type ‘<type>’ is not declared. (in this case for ‘<type>’  ‘ProjectType’).
    That was odd too: the ‘ProjectType’ was indeed declared, and should be valid.

I could hardly find any information about the latter error, but the former gave a few useful hits.

Thanks User weston – Stack Overflow. for answering this: it made me smack to my head (like usual, a case of EBCAK).

To resolve Namespace ” is not available to be referenced in this schema. You can set the default ” namespace without the need to change the rest of the file:

So after adding the below default xmlns to the XSD, not only the first, but also the second error were gone!


This is the work in progress on GroupProj.xsd:

<?xml version="1.0" encoding="utf-8"?>
<!– This very small subset of ";.
Normally that namespace is defined in Microsoft.Build.xsd/Microsoft.Build.Core.xsd/Microsoft.Build.Commontypes.xsd.
Actually this subset is not a trimmed down version of the original, but started from scracth to
only contains types used by Delphi/RAD Studio/C++ Builder.
In the future, I might add some better restrictions here and there, but so far it is sufficient engough to
– validate .groupproj documents
– use the Delphi XML Data Binding Wizard to generate a Delphi unit that allows generation and reading of .groupproj files.
The default values for `minOccurs` and `maxOccurs` are 1, so make `maxOccurs` larger to allow `repeating` in the Delphi XML Data Binding Wizard.
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0"
<xsd:element name="Project" type="ProjectType"/>
<xsd:complexType name="ProjectType">
<xsd:element name="PropertyGroup" type="PropertyGroupType"/>
<!– Delphi XE2 sometimes has an empty `ItemGroup` element –>
<xsd:element name="ItemGroup" type="ItemGroupType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="ProjectExtensions" type="ProjectExtensionsType"/>
<xsd:element name="Target" type="TargetType" maxOccurs="unbounded"/>
<xsd:element name="Import" type="ImportType"/>
<xsd:complexType name="ImportType">
<xsd:attribute name="Project" type="xsd:string"/>
<xsd:attribute name="Condition" type="xsd:string"/>
<xsd:complexType name="TargetType">
<xsd:element name="MSBuild" type="MSBuildType"/>
<xsd:element name="CallTarget" type="CallTargetType"/>
<xsd:attribute name="DependsOnTargets" type="xsd:string" use="optional"/>
<xsd:attribute name="Name" type="xsd:string"/>
<xsd:complexType name="MSBuildType">
<xsd:attribute name="Projects" type="xsd:string"/>
<!– –>
<xsd:attribute name="Targets" type="xsd:string" use="optional"/>
<xsd:complexType name="CallTargetType">
<xsd:attribute name="Targets" type="xsd:string"/>
<xsd:complexType name="ProjectExtensionsType">
<xsd:element name="Borland.Personality" type="xsd:string"/>
<xsd:element name="Borland.ProjectType" type="xsd:string"/>
<xsd:element name="BorlandProject" type="BorlandProjectType"/>
<xsd:complexType name="BorlandProjectType">
<xsd:element name="Default.Personality" type="xsd:string"/>
<!– Delphi 2010 can have a nested `BorlandProject` element –>
<xsd:element name="BorlandProject" type="BorlandProjectType"/>
<xsd:complexType name="ItemGroupType">
<xsd:element name="Projects" type="ProjectsType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:complexType name="ProjectsType">
<xsd:element name="Dependencies" type="xsd:string"/>
<xsd:attribute name="Include" type="xsd:string"/>
<xsd:complexType name="PropertyGroupType">
<xsd:element name="ProjectGuid" type="guid"/>
<xsd:simpleType name="guid">
<xsd:documentation xml:lang="en">
The representation of a GUID, generally the id of an element.
<xsd:restriction base="xsd:string">
<xsd:pattern value="\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}"/>

view raw


hosted with ❤ by GitHub


via: How do I use inheritance (ie xs:extension) in my own xml schema? – Stack Overflow.

2 Responses to “XSD/XML Schemas: resolving `Namespace ” is not available to be referenced in this schema` (via: StackOverflow)”

  1. uligerhardt said

    s/through/throw/ please. :-)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: