Groups | Blog | Home
all groups > dotnet xml > october 2005 >

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



comic_rage NO[at]SPAM yahoo.com
10/26/2005 7:07:19 PM
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
10/27/2005 12:00:00 AM


[quoted text, click to view]


[quoted text, click to view]

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")

--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button