By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,909 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,909 IT Pros & Developers. It's quick & easy.

Convert schema to an xml document

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.