DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 18 Jul 2007 10:10:33 -0700,    posted on: microsoft.public.dotnet.framework.aspnet.webservices        back       

Thread Index
  1    Jeremy
          2    John Saunders [MVP] john.saunders at trizetto.com


Schema type information provided by IXmlSerializable is invalid: Type 'string' is not declared   
I've added the System.Xml.Serialization.XmlSchemaProvider attribute to my 
class to customize the schema. Some of the datatypes in my schema are 
strings, but I'm getting an error that string type is not declared.  Can 
anyone show me how to do this properly?  I've included the code to my schema 
below:

[System.Xml.Serialization.XmlSchemaProvider("MySchema")]
public class AnyTextData2 : AnyTextData, 
System.Xml.Serialization.IXmlSerializable
{
    public AnyTextData2()
    {
    }

    public static System.Xml.XmlQualifiedName 
MySchema(System.Xml.Schema.XmlSchemaSet xs)
    {
        System.Xml.Serialization.XmlSerializer schemaSerializer =
            new 
System.Xml.Serialization.XmlSerializer(typeof(System.Xml.Schema.XmlSchema));
        System.Xml.Schema.XmlSchema s = AnyTextData2.Schema;
        xs.XmlResolver = new System.Xml.XmlUrlResolver();
        xs.Add(s);
        return new System.Xml.XmlQualifiedName("AnyTextData2");//, ns);
    }
    private static System.Xml.Schema.XmlSchema Schema
    {
        get
        {
            /*
            <s:complexType name="AnyTextData2">
            <s:simpleContent>
            <s:extension base="s:string">
            <s:attribute name="Attribute" type="s:string" />
            </s:extension>
            </s:simpleContent>
            </s:complexType>
            */
            System.Xml.Schema.XmlSchema pSchema = new 
System.Xml.Schema.XmlSchema();
            pSchema.ElementFormDefault = 
System.Xml.Schema.XmlSchemaForm.Qualified;

            //<s:complexType name="CData">
            System.Xml.Schema.XmlSchemaComplexType pComplexType = new 
System.Xml.Schema.XmlSchemaComplexType();
            pComplexType.Name = "AnyTextData2";

            //<xs:simpleContent>
            System.Xml.Schema.XmlSchemaSimpleContent pSimpleContent = new 
System.Xml.Schema.XmlSchemaSimpleContent();

            //<s:extension base="s:string">
            System.Xml.Schema.XmlSchemaSimpleContentExtension pExtension = 
new System.Xml.Schema.XmlSchemaSimpleContentExtension();
            pExtension.BaseTypeName = new 
System.Xml.XmlQualifiedName("string");//"s:string"

            //<s:attribute name="Attribute" type="s:string" />
            System.Xml.Schema.XmlSchemaAttribute pAttribute = new 
System.Xml.Schema.XmlSchemaAttribute();
            pAttribute.Name = "Attribute";
            pAttribute.SchemaTypeName = new 
System.Xml.XmlQualifiedName("string");//"s:string"
            pExtension.Attributes.Add(pAttribute);

            pSimpleContent.Content = pExtension;

            pComplexType.ContentModel = pSimpleContent;

            pSchema.Items.Add(pComplexType);
            return pSchema;
        }
    }

}
Date:Wed, 18 Jul 2007 10:10:33 -0700   Author:  

Re: Schema type information provided by IXmlSerializable is invalid: Type 'string' is not declared   
"Jeremy"  wrote in message 
news:elD886VyHHA.4712@TK2MSFTNGP04.phx.gbl...

> I've added the System.Xml.Serialization.XmlSchemaProvider attribute to my 
> class to customize the schema. Some of the datatypes in my schema are 
> strings, but I'm getting an error that string type is not declared.  Can 
> anyone show me how to do this properly?  I've included the code to my 
> schema below:
>
> [System.Xml.Serialization.XmlSchemaProvider("MySchema")]
> public class AnyTextData2 : AnyTextData, 
> System.Xml.Serialization.IXmlSerializable
> {
>    public AnyTextData2()
>    {
>    }
>
>    public static System.Xml.XmlQualifiedName 
> MySchema(System.Xml.Schema.XmlSchemaSet xs)
>    {
>        System.Xml.Serialization.XmlSerializer schemaSerializer =
>            new 
> System.Xml.Serialization.XmlSerializer(typeof(System.Xml.Schema.XmlSchema));
>        System.Xml.Schema.XmlSchema s = AnyTextData2.Schema;
>        xs.XmlResolver = new System.Xml.XmlUrlResolver();
>        xs.Add(s);
>        return new System.Xml.XmlQualifiedName("AnyTextData2");//, ns);
>    }
>    private static System.Xml.Schema.XmlSchema Schema
>    {
>        get
>        {
>            /*
>            <s:complexType name="AnyTextData2">
>            <s:simpleContent>
>            <s:extension base="s:string">
>            <s:attribute name="Attribute" type="s:string" />
>            </s:extension>
>            </s:simpleContent>
>            </s:complexType>
>            */
>            System.Xml.Schema.XmlSchema pSchema = new 
> System.Xml.Schema.XmlSchema();
>            pSchema.ElementFormDefault = 
> System.Xml.Schema.XmlSchemaForm.Qualified;
>
>            //<s:complexType name="CData">
>            System.Xml.Schema.XmlSchemaComplexType pComplexType = new 
> System.Xml.Schema.XmlSchemaComplexType();
>            pComplexType.Name = "AnyTextData2";
>
>            //<xs:simpleContent>
>            System.Xml.Schema.XmlSchemaSimpleContent pSimpleContent = new 
> System.Xml.Schema.XmlSchemaSimpleContent();
>
>            //<s:extension base="s:string">
>            System.Xml.Schema.XmlSchemaSimpleContentExtension pExtension = 
> new System.Xml.Schema.XmlSchemaSimpleContentExtension();
>            pExtension.BaseTypeName = new 
> System.Xml.XmlQualifiedName("string");//"s:string"


Jeremy, "qualified" means "qualified with a namespace". You have no 
namespace. The name {no namespace}:string is not defined.

You need to qualifiy these names with the "http://www.w3.org/2001/XMLSchema" 
namespace.
-- 
John Saunders [MVP]
Date:Wed, 18 Jul 2007 13:51:52 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us