473,804 Members | 3,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add non-native attribute to XmlSchema in .NET

I am building an XML Schema with the SOM in .NET and would like to add
a non-native attribute to one of my elements. Does anyone know how to
do this? (Whithout rendering the schema to an XmlDocument to do it.)

Thanks!
Eric
Nov 11 '05 #1
4 3492
Eric wrote:
I am building an XML Schema with the SOM in .NET and would like to add
a non-native attribute to one of my elements. Does anyone know how to
do this? (Whithout rendering the schema to an XmlDocument to do it.)


What do you mean "non-native"?
If that means non-schema attributes (some proprietary attribute say on
xs:element) you can add it by filling UnhandledAttrib utes collection.

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
On Fri, 19 Sep 2003 23:02:12 +0300, Oleg Tkachenko
<oleg@NO_SPAM_P LEASEtkachenko. com> wrote:
Eric wrote:
I am building an XML Schema with the SOM in .NET and would like to add
a non-native attribute to one of my elements. Does anyone know how to
do this? (Whithout rendering the schema to an XmlDocument to do it.)


What do you mean "non-native"?
If that means non-schema attributes (some proprietary attribute say on
xs:element) you can add it by filling UnhandledAttrib utes collection.


Oleg, thanks for the reonse.

Yes, I mean non-schema attributes. UnhandledAttrib utes is an array of
XmlAttribute objects. This looks like it is meant to be used when
reading a schema file. How would I use it in building the schema file?
Nov 11 '05 #3
Eric Farr wrote:
Yes, I mean non-schema attributes. UnhandledAttrib utes is an array of
XmlAttribute objects. This looks like it is meant to be used when
reading a schema file. How would I use it in building the schema file?


Hmm, really. I've got no better idea than using dummy XmlDocument:
XmlSchema schema = new XmlSchema();
XmlSchemaElemen t elem = new XmlSchemaElemen t();
elem.Name = "foo";
elem.SchemaType Name = new XmlQualifiedNam e("string",
"http://www.w3.org/2001/XMLSchema");
XmlDocument dummyDoc = new XmlDocument();
XmlAttribute attr = dummyDoc.Create Attribute("myns :blah",
"http://myns.com");
attr.Value="my own attribute";
elem.UnhandledA ttributes = new XmlAttribute[] {attr};
schema.Items.Ad d(elem);
schema.Write(Co nsole.Out);

Produces:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element myns:blah="my own attribute" name="foo" type="xs:string "
xmlns:myns="htt p://myns.com" />
</xs:schema>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #4
On Sun, 21 Sep 2003 11:28:46 +0200, Oleg Tkachenko
<oleg@NO_SPAM_P LEASEtkachenko. com> wrote:
Eric Farr wrote:
Yes, I mean non-schema attributes. UnhandledAttrib utes is an array of
XmlAttribute objects. This looks like it is meant to be used when
reading a schema file. How would I use it in building the schema file?


Hmm, really. I've got no better idea than using dummy XmlDocument:
XmlSchema schema = new XmlSchema();
XmlSchemaElemen t elem = new XmlSchemaElemen t();
elem.Name = "foo";
elem.SchemaType Name = new XmlQualifiedNam e("string",
"http://www.w3.org/2001/XMLSchema");
XmlDocument dummyDoc = new XmlDocument();
XmlAttribute attr = dummyDoc.Create Attribute("myns :blah",
"http://myns.com");
attr.Value="my own attribute";
elem.UnhandledA ttributes = new XmlAttribute[] {attr};
schema.Items.Ad d(elem);
schema.Write(Co nsole.Out);

Produces:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element myns:blah="my own attribute" name="foo" type="xs:string "
xmlns:myns="ht tp://myns.com" />
</xs:schema>


That gives me exactly what I was looking for. Thanks! It would have
been nice if .NET classes made this a little more straightforward , but
it least it works.
Nov 11 '05 #5

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

Similar topics

5
3759
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence their dtor is called immediately and not at the end of the function. to be able to use return objects (to avoid copying) i often assign them to a const reference. now, casting a const return object from a function to a non-const reference to this...
3
12274
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in nonblocking mode in c++? I did something ugly like --- c/c++ mixture --- mkfifo( "testpipe", 777);
25
7666
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
4531
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
14
8481
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
11
3459
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the vtable pointer is made use of.. eg. class one {
2
6126
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my pointers, but I'm not sure. Please help. The code: void equate(matrix *A, matrix *B) { int i, j; assert(A.row_dim == B.col_dim && A.col_dim == B.col_dim); for(i=0; i < A.row_dim; i++) for(j=0; j < A.col_dim; j++)
0
2349
by: amitvps | last post by:
Secure Socket Layer is very important and useful for any web application but it brings some problems too with itself. Handling navigation between secure and non-secure pages is one of the cumbersome jobs. When a non-secure page references a secure page with relative URL, the web server generates error until absolute URL with https prefix is used. On the other hand when a secure page references a non-secure page, the non-secure page will be...
399
12969
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or to python-3000@python.org In summary, this PEP proposes to allow non-ASCII letters as identifiers in Python. If the PEP is accepted, the following identifiers would also become valid as class, function, or variable names: Löffelstiel,...
12
29922
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10571
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.