Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,169 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,902 people online right now. Registration is fast and FREE... Join Now!




XML Schema Question

 
Reply to this topicStart new topic

XML Schema Question

codemonkey83
27 Dec, 2007 - 12:09 PM
Post #1

New D.I.C Head
*

Joined: 10 Feb, 2007
Posts: 43


My Contributions
I've recently been working on a project for my job that is used in writing requirements documents. The application uses XML to sort and store data. I've been working on a schema that is used for validating the document. The problem is, I can't seem to find any answers as to how to define an element that contains a single attribute, and CDATA.

I currently have it defined as such, which I know is wrong.
CODE

<xsd:element name = "comment" type="xsd:string">
    <xsd:complexType>
        <xsd:attribute ref = "date" use = "required"/>
    </xsd:complexType>
</xsd:element>


I know this is wrong, but this might give you an idea of what I'm trying to do. For the record, this project is being written in C# and C# Express is what is complaining at me about this and my previous version which simply had an element with just a type, min occurance, and max occurance but no name inside of the sequence tags.

I don't know if anyone here has come across this, but if they have, an idea of how this can be defined would be appreciated.
User is offlineProfile CardPM
+Quote Post

codemonkey83
RE: XML Schema Question
27 Dec, 2007 - 12:21 PM
Post #2

New D.I.C Head
*

Joined: 10 Feb, 2007
Posts: 43


My Contributions
Here's one for the books, I'v never since this type of Schema definition before, but it works and does exactly what I need.

CODE

<xsd:element name = "comment">
    <xsd:complexType>
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute ref = "date" use = "required"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
</xsd:element>


Sorry for wasting your time to anyone who decided to try and figure this out. I googled for about the seventh time and found out this answer by accident and when I tried it, it worked.
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: XML Schema Question
27 Dec, 2007 - 12:24 PM
Post #3

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 14,931



Thanked: 47 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
What were you googling for before you found the solution?

User is offlineProfile CardPM
+Quote Post

codemonkey83
RE: XML Schema Question
27 Dec, 2007 - 12:49 PM
Post #4

New D.I.C Head
*

Joined: 10 Feb, 2007
Posts: 43


My Contributions
QUOTE(skyhawk133 @ 27 Dec, 2007 - 01:24 PM) *

What were you googling for before you found the solution?


I googled alot of different things.

What finally found it was:
CODE

.xsd schema examples


Go figure. :-p
User is offlineProfile CardPM
+Quote Post

baavgai
RE: XML Schema Question
27 Dec, 2007 - 02:01 PM
Post #5

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,019



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
In C#, Visual Studio, create an empty dataset and then fill in the tables and look at the source created.

Even better, you can right click on an xsd file in visual studio and choose the tool to edit it with. In addtion to the standard dataset tool, there's also an XML schema tool.

If you have a sample xml document, you can use xsd.exe to generate an xsd file from that, then look at it and massage the datatypes as needed.

Hope this helps.

User is offlineProfile CardPM
+Quote Post

codemonkey83
RE: XML Schema Question
28 Dec, 2007 - 07:13 AM
Post #6

New D.I.C Head
*

Joined: 10 Feb, 2007
Posts: 43


My Contributions
QUOTE(baavgai @ 27 Dec, 2007 - 03:01 PM) *

In C#, Visual Studio, create an empty dataset and then fill in the tables and look at the source created.

Even better, you can right click on an xsd file in visual studio and choose the tool to edit it with. In addtion to the standard dataset tool, there's also an XML schema tool.

If you have a sample xml document, you can use xsd.exe to generate an xsd file from that, then look at it and massage the datatypes as needed.

Hope this helps.

Actually, adding it to the project was never a problem, it just refused to agree with that one element. Once I finally found the solution, it stopped complaining and everything worked perfectly.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:30AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month