473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert schema to an xml document

How can I convert an existing schema to an xml document. I have a series of schema documents that validate xml documents that describe metadata. Normally the metadata is first defined in a database, then schemas generated from the database. In this case I was given the schemas and I am writing an application to create the database entries.
I can't use a dataset as we have a very specific database structure.

I started to load them into an XMLDocument and using SelectNodes() start parsing them. However, they contain multiple namespaces and imports which also contain imports.

I have the following:
<xsd:complexType name="AnimalType">
<xsd:complexContent>
<xsd:extension base="ns:Super">
<xsd:sequence>
<xsd:element ref="ns:Animal"/>
<xsd:element ref="nx:ImageIndicator" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Key" type="xsd:string" use="required"/>
<xsd:attribute name="Type" type="xsd:string" use="optional"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

which is described in another schema (imported). When I do a SelectNodes() on <xsd:element ref="ns:Animal"/(using a namespace manager and all listed namespaces) it says there are no children. I want to get the node and all of it's descendants that are in the imported schema. When I use a tool like XmlSpy it will do the conversion and give me a nice XML document with all the children. I would like to do this myself in C#.

Or maybe this is not the best approach, but I some how need load the schema and all of it's imports into one document.

Thanks!
Pete

Jul 12 '06 #1
5 1748
Hi Pete,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get all the descendants
that is defined in another schema for an element. If there is any
misunderstanding, please feel free to let me know.

As far as I know, we cannot get this directly like XmlSpy does. You have to
load another schema into XmlDocument and parse again. All has to be done
with code manually, it will not get automatically.

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 13 '06 #2
Yes, you understand the issue. I was hoping not to have to do it manually
since I may have to go down 5 levels of schemas.

Thanks!
Pete

"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:Ck**************@TK2MSFTNGXA01.phx.gbl...
Hi Pete,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get all the descendants
that is defined in another schema for an element. If there is any
misunderstanding, please feel free to let me know.

As far as I know, we cannot get this directly like XmlSpy does. You have
to
load another schema into XmlDocument and parse again. All has to be done
with code manually, it will not get automatically.

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 13 '06 #3
Hi Pete,

I'm sorry, but this has to be done by writing our own code. Unlike tools
like XmlSpy which makes you easier to modify an xml doc, XmlDocument is a
class which only provides you programatical interfaces to parse an xml doc.
They just have different target for design. :-)

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 14 '06 #4
Hi Pete,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 18 '06 #5
You might say it is resolved. I am using the XmlSpy API set to do it. I do
have an issue they are working on that I came across, however. Thanks for
the follow-up.

Pete
"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:ll**************@TK2MSFTNGXA01.phx.gbl...
Hi Pete,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 31 '06 #6

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

Similar topics

5
9606
by: Fu Bo Xia | last post by:
anyone know a Java (or Java usable) package that converts XML Schema (XSD) documents into a tree form? thanks, fu bo
2
3303
by: wooks | last post by:
<?xml version='1.0'?> <userlogin xmlns="urn:faster:userlogin" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> <login>mick</login> <password>brown</password> </userlogin> Above is my...
0
4196
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > ...
2
2466
by: Stanimir Stamenkov | last post by:
I'm trying to find out if it is permissible to include a schema document with absent target namespace to a schema with specified target namespace, and if it is, what are the rules to resolve the...
1
8518
by: William Wong | last post by:
Hello Is it possible to convert a dataset into xml document with embeded schema? Thanks William
5
52641
by: jk | last post by:
I'm having trouble converting a datatable into xml, with resonse.write to aspx. I'm basically converting vb code that saved a recordset into a stream into c#, but the format is wrong. I've tried...
4
9700
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
3
1732
by: Lord0 | last post by:
I *think* I need to be able to validate subsets of an XML document using different schema. The functionality I'm trying to implement is this. a) External suppliers produce an XML document...
6
2219
by: Grant Robertson | last post by:
If I use the 'any' element in my schema to allow elements from another schema to be used in instance documents based on my schema, is there a way to force that the contents of that element must be...
0
7125
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
7002
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
7165
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,...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5462
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,...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
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...

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.