Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / October 2005

Tip: Looking for answers? Try searching our database.

need help to declard type=IntType instead type="xsd:int" with xml schema

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
comic_rage@yahoo.com - 27 Oct 2005 03:07 GMT
Hi,

I am writing C# code to produce xml schema.

            //Create attribute
            XmlSchemaAttribute att2 = new XmlSchemaAttribute();
            att2.Name = "CustomerID";
            att2.SchemaTypeName = new XmlQualifiedName("int",schemaNS);
            att2.Use = XmlSchemaUse.Required;
            ct.Attributes.Add(att2);

I need to produce schema with custom data type instead of the
xsd:string or xsd:int

The code above will produce the following schema

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified" version="1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="Customer">
   <xsd:complexType>
     <xsd:sequence>
       <xsd:element name="Order">
         <xsd:complexType>
           <xsd:attribute name="CustomerID" type="xsd:int"
use="required" />
           <xsd:attribute name="OrderID" type="xsd:int" use="required"
/>
         </xsd:complexType>
       </xsd:element>
     </xsd:sequence>
     <xsd:attribute name="CustomerID" type="xsd:StringType"
use="required" />
   </xsd:complexType>
 </xsd:element>
</xsd:schema>

I need to produce schema with

<xsd:attribute name="CustomerID" type="IntType" use="required" />
or
<xsd:attribute name="CustomerID" type="StringType" use="required" />

when I use
att2.SchemaTypeName = new XmlQualifiedName("IntType",schemaNS);

I get

<xsd:attribute name="CustomerID" type="xsd:IntType" use="required" />

How do I get the type to equal only "IntType" without the "xsd" part?

Thanks
Martin Honnen - 27 Oct 2005 12:03 GMT
> <xsd:attribute name="CustomerID" type="IntType" use="required" />
> or
> <xsd:attribute name="CustomerID" type="StringType" use="required" />
>
> when I use
> att2.SchemaTypeName = new XmlQualifiedName("IntType",schemaNS);

I would simply try
  att2.SchemaTypeName = new XmlQualifiedName("IntType")
then if your type is in no namespace.
Or if that schema is going to have a targetNamespace then I think you
need to use
  att2.SchemaTypeName = new XmlQualifiedName("IntType",
"targetNamespaceURIGoesHere")

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.