Click to See Complete Forum and Search --> : XML Definition
beginner101
01-24-2009, 12:53 PM
<!Doctype CourseInfo[
<!ELEMENT CourseInfo (Year,Subject,Name,Section,Component,Number,Taught,Start,End,BldgRoom,Instructor,Notes,Status)>
<!ELEMENT Year (#PCDATA)>
<!ELEMENT Subject (#PCDATA)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Section (#PCDATA)>
<!ELEMENT Component (#PCDATA)>
<!ELEMENT Number (#PCDATA)>
<!ELEMENT Taught (#PCDATA)>
<!ELEMENT Start (#PCDATA)>
<!ELEMENT End (#PCDATA)>
<!ELEMENT BldgRoom (#PCDATA)>
<!ELEMENT Instructor (#PCDATA)>
<!ELEMENT Notes (#PCDATA)>
<!ELEMENT Status (#PCDATA)> ]>
Thats what I have, and im not sure if ive created my xml DTD definition file correctly, can someone take a look? and see if i did it right? thank you very much :)
rpgfan3233
01-24-2009, 01:30 PM
Other than DOCTYPE needing to be in all caps, it appears to be alright...assuming your XML file will follow the exact structure listed.
beginner101
01-24-2009, 01:42 PM
thank you sir, yea ill end up posting the two things after Im done
but atleast I know that I did it correctly, and it doesnt matter if I use two words such as "CourseInfo"?
all the class examples had one word, so i was just curious
rpgfan3233
01-24-2009, 04:18 PM
Oh, it doesn't matter how many words you use. You could also write CourseInfo like this:
course_info
course-info
course.info
Of course, using "course.info" might cause issues with some CSS engines, so I wouldn't exactly recommend using it. Anyway, just remember that XML is case-sensitive. If you declare a "course_info" element in the doctype declaration (DTD) and use "Course_Info" in your XML, it isn't really the same element.
beginner101
01-24-2009, 06:43 PM
thank you :)
and i had 1 more question, ive noticed that some of the schemas have their lines indented (tabbed) in a certain way. (wavy almost)
ex:
http://xml.netbeans.org/specs/axiom/images/source.png
Does it matter if my definition is just the way its shown above??? or does it have to have the indents?
And does my Schema have to be indented like the example shown? thanks
rpgfan3233
01-24-2009, 07:16 PM
No, indentation is not necessary. It is done more for readability than anything else. After all, I'd rather edit the second set of code rather than the first:
<?xml version="1.0" encoding="utf-8"?> <blah> <foo att="example-bar">Random Text</foo> </blah>
or
<?xml version="1.0" encoding="utf-8"?>
<blah>
<foo att="example-bar">Random Text</foo>
</blah>
It's simply easier to read, and the structure is clearer. Anyway, both documents are serialized to relatively the same thing, in terms of the document object model (DOM). The only difference is that when you have newlines that are more than one byte (Windows/DOS), you use one extra byte for the newline character rather than the single byte for the space (or even no extra bytes if you don't use the space, which is rather common).
Of course, XML schemas are written in XML, so the rules that someone might use for normal XML and HTML documents would probably be applied to a schema they write. You can structure your DTD the same way. Some "all-purpose" editors like GNU Emacs have special indentation rules for languages like XML, but they fail to indent the inline DTD section because those rules aren't created/available/whatever. Whatever the case, you can always indent it yourself. ^_^
beginner101
01-24-2009, 07:57 PM
thank you very much, if i have any other questions, ill be sure to ask!
beginner101
01-24-2009, 11:59 PM
So here is my current XML Definiton:'
<!DOCTYPE CourseInfo[
<!ELEMENT CourseInfo (Year,Subject,Name,Section,Component,Number,Taught,Start,End,BldgRoom,Instructor,Notes,Status)>
<!ELEMENT Year (#PCDATA)>
<!ELEMENT Subject (#PCDATA)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Section (#PCDATA)>
<!ELEMENT Component (#PCDATA)>
<!ELEMENT Number (#PCDATA)>
<!ELEMENT Taught (#PCDATA)>
<!ELEMENT Start (#PCDATA)>
<!ELEMENT End (#PCDATA)>
<!ELEMENT BldgRoom (#PCDATA)>
<!ELEMENT Instructor (#PCDATA)>
<!ELEMENT Notes (#PCDATA)>
<!ELEMENT Status (#PCDATA)> ]>
And here is my XML document I recently created using the info above:
<CourseInfo>
<Year>2008/2009</Year>
<Subject>Calculus</Subject>
<Name>CALCULUS 2502A - ADVANCED CALCULUS I</Name>
<Section>001</Section>
<Component>Lecture</Component>
<Number>4506</Number>
<Taught>Monday Wednesday Friday</Taught>
<Start>1:30pm</Start>
<End>2:30pm</End>
<BldgRoom>SSC-3022</BldgRoom>
<Instructor>Lemire</Instructor>
<Notes>None</Notes>
<Status>Not Full</Status>
</CourseInfo>
If I did it right or wrong, I dont know, can someone confirm if this was done correctly? but I had 1 Question also:
How do I also embed or add in this info to whats already there?
I need to add 4508 as a second number
Also, the BldgRoom i need to add: NCB-113 as a second room
Also, another instructor: Macisaac and a second teacher
help would be greatly appreciated :)
rpgfan3233
01-25-2009, 01:06 AM
You could use a '+' after the necessary element names in the content model of the CourseInfo element. You could also split them up into individual courses:
<!DOCTYPE CourseInfo [
<!ELEMENT CourseInfo (Year, Subject+)>
<!ELEMENT Year (#PCDATA)>
<!ELEMENT Subject (Name, Course+)>
<!ELEMENT Course (Name, Section, Component, Number, Taught,
Start, End, BldgRoom, Instructor, Notes,
Status)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Section (#PCDATA)>
<!ELEMENT Component (#PCDATA)>
<!ELEMENT Number (#PCDATA)>
<!ELEMENT Taught (#PCDATA)>
<!ELEMENT Start (#PCDATA)>
<!ELEMENT End (#PCDATA)>
<!ELEMENT BldgRoom (#PCDATA)>
<!ELEMENT Instructor (#PCDATA)>
<!ELEMENT Notes (#PCDATA)>
<!ELEMENT Status (#PCDATA)>
]>
<CourseInfo>
<Year>2008/2009</Year>
<Subject>
<Name>Calculus</Name>
<Course>
<Name>CALCULUS 2502A - ADVANCED CALCULUS I</Name>
<Section>001</Section>
<Component>Lecture</Component>
<Number>4506</Number>
<Taught>Monday Wednesday Friday</Taught>
<Start>1:30pm</Start>
<End>2:30pm</End>
<BldgRoom>SSC-3022</BldgRoom>
<Instructor>Lemire</Instructor>
<Notes>None</Notes>
<Status>Not Full</Status>
</Course>
<!-- More courses in the same manner -->
</Subject>
<!-- More subjects using the same syntax -->
</CourseInfo>
Notice the '+' signs? That's how you would use it.
I hope this helps! ^_^
beginner101
01-25-2009, 11:48 AM
thank you rpgfan, but i just made a mistake, instead of a Definition,
i have to replace that with an XML Schema, so Ill come back to this post with the work I have done, to see if you can help me
thank you for all the help so far :)