Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Schema type information provided by IXmlSerializable is invalid: Type 'string' is not declared

Reply
Thread Tools

Schema type information provided by IXmlSerializable is invalid: Type 'string' is not declared

 
 
Jeremy
Guest
Posts: n/a
 
      07-18-2007
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("MySche ma")]
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(Syst em.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;
}
}

}


 
Reply With Quote
 
 
 
 
John Saunders [MVP]
Guest
Posts: n/a
 
      07-18-2007
"Jeremy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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("MySche ma")]
> 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(Syst em.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]

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IXmlSerializable.GetSchema creates mutiple schema elements in my wsdl Jeremy ASP .Net Web Services 3 07-18-2007 11:35 PM
declared or not declared ? JohnZing ASP .Net 3 02-05-2006 08:38 PM
IXmlSerializable: return type & difference IE / webservice Thomas D. ASP .Net Web Services 1 09-01-2005 02:29 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Labels not displayed when using Win32::MsgBox, more information provided hurluberlu Perl Misc 1 12-20-2004 08:36 AM



Advertisments