473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XsdObjGen and use=required on attributes

Hi all,
I wonder has anyone seen this behaviour with XsdObjGen tool, and if so, how
did you get around it?

I have the following in a schema file:

<xs:attribute name="sid" type="xs:long" use="required"/>

Notice the use="required" attribute...
this genenerates the following code:

[XmlAttribute(AttributeName="sid",Form=XmlSchemaFor m.Unqualified,DataType="long")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public long __sid;

[XmlIgnore]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __sidSpecified;

[XmlIgnore]
public long sid
{
get { return __sid; }
set { __sid = value; __sidSpecified = true; }
}

[XmlAttribute(AttributeName="clientId",Form=XmlSche maForm.Unqualified,DataType="long")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public long __clientId;
In turn, when I view the WSDL that is generated by the webservice, I see
that the attribute now has the form:

<s:attribute form="unqualified" name="sid" type="s:long" />

The required attribute is no longer present. Is there anyway around this?

Pete
Nov 21 '05 #1
2 2893
Hi,

No, there is no way today to make the auto-generated schema reflect the
cardinality requirements of the original schema. This is something you can
handle in one of two ways. Either you publish a hand-corrected or hand
coded WSDL file, or you handle the issue via documentation as a part of
your partner provisioning/SLA terms.

In order to get the value ALWAYS serialized, remember to always call the
MakeSchemaCompliant method on the class. This is where the generated XML
is made schema compliant when XsdObjectGen is used to create classes.

Regards

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: XsdObjGen and use=required on attributes
thread-index: AcTIqEsqJbD4CpzzT9iBwLvuNQcztw==
X-WBNR-Posting-Host: 62.17.162.113
From: =?Utf-8?B?UGV0ZXIgTWNFdm95?= <Pe*********@discussions.microsoft.com>
Subject: XsdObjGen and use=required on attributes
Date: Fri, 12 Nov 2004 03:11:01 -0800
Lines: 41
Message-ID: <2B**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7396
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Hi all,
I wonder has anyone seen this behaviour with XsdObjGen tool, and if so, how
did you get around it?

I have the following in a schema file:

<xs:attribute name="sid" type="xs:long" use="required"/>

Notice the use="required" attribute...
this genenerates the following code:

[XmlAttribute(AttributeName="sid",Form=XmlSchemaFor m.Unqualified,DataType="l
ong")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public long __sid;

[XmlIgnore]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __sidSpecified;

[XmlIgnore]
public long sid
{
get { return __sid; }
set { __sid = value; __sidSpecified = true; }
}

[XmlAttribute(AttributeName="clientId",Form=XmlSche maForm.Unqualified,DataTy
pe="long")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public long __clientId;
In turn, when I view the WSDL that is generated by the webservice, I see
that the attribute now has the form:

<s:attribute form="unqualified" name="sid" type="s:long" />

The required attribute is no longer present. Is there anyway around this?

Pete

Nov 23 '05 #2
Thanks Dan, I went the hardcoded WSDL route - while it's a bit higher
maintenance, I actually find it's better in the long run as I am able to add
alot more documentation to the WSDL.
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert Zurer | last post by:
I want to create a schema element that will allow any element as a child but that child must contain specified attributes This example doesn't work but it might give an idea of what I need to do....
2
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0"...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
4
by: Mike Jansen | last post by:
Does anyone know why if I create a complexType based off another complexType using xsd:extension the attributes don't seem to be inherited? Is this a bug/non-implementation in the .NET Schema...
3
by: SideByEach | last post by:
Check out the sample XML below. Sample XML: <xs:element name="Image"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="Type" type="xs:string"...
6
by: Mark Broadbent | last post by:
This might sound like a bit of a stupid statement (no change there then!) to some of the gurus, but am I the only one left a bit flustered by what appears to be around ten zillion attributes (and...
6
by: uttara | last post by:
Hello All, I was trying to validate an XML document against a XSD which works fine. Then I tried to put in a version attribute on the root element and set it to a fixed value of '1.0' in the...
3
by: LJ | last post by:
I am trying to define two xml attribute in my xsd so that they are mutual exclusive and one of them is required. For example, if I have two attributes, they are either <xsd:attribute name="p"...
0
by: William | last post by:
I am getting a webservice error when using a couple of generated XsdObjectGen complex types. The WebMethod is something like: public RESPONSE_GROUP Order(REQUEST_GROUP rqst) { IOrder rObj =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.