XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 1st, 2003, 10:21 PM
mikeg mikeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 mikeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Xml + Dtd

hi,

how would i write an xml and a dtd (both in the same file "bla.xml") for the following:

Branch Table
BranchID | BranchName | BranchAddress
AFR | Africa | 12 bla street, Africa
UKR | Ukraine | 45 moo street, Ukraine

Book Table
BookID | Author | Title
D45 | Austin G | 6 Million $ Man

How do we specify constraints such as Primary Key & Foreign Key?

In the Distributed dbase schema:
Branch ( BranchID , BranchName, BranchAddress )
Book ( BookID, Title, Author )
BookCopies ( BookID, BranchID, NCopies )
BookLoan ( BookID, BranchID, CardNo, DateOut, DueDate, DateIn)
Customer ( CardNo, Name, Address, Sex, CustomerBranch )
Librarian ( StaffID, BranchID, Name, Discipline, Office, Phone )

we know that all items inside the brackets are attributes.

2. but in the xml how do we distinguish elements and attributes?

3. how do we restrict values for elements, eg: BranchID only
either AFR or UKR appears.

4. is there any way we can show them in tables?


Please Help

Reply With Quote
  #2  
Old December 5th, 2003, 05:08 PM
tsprings tsprings is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Seattle, WA
Posts: 55 tsprings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 5
Hello mikeg. I'm not exactly sure what you're trying to do here. My suggestion is that you visit W3 Schools and read up on XML. There is also plenty of information here on DTD's as well.

Quote:
2. but in the xml how do we distinguish elements and attributes?

First, you can read about elements here: W3 Schools - Elements and about attributes here: W3 Schools - Attributes. Now, with the example you gave: Branch ( BranchID , BranchName, BranchAddress ), you could write an XML element that would look like this:
Code:
<Branch branchID="123" BranchName="Something" BranchAddress="123 S 23rd St, Seattle, WA 98168" />

In this example, "Branch" would be the element and "branchID", "BranchName", and "BranchAddress" would all be attributes of "Branch".
Quote:
3. how do we restrict values for elements, eg: BranchID only either AFR or UKR appears.

Again, read about DTD's here: W3 Schools - DTD. So let's say BranchID is AFR or UKR. We could define it in the DTD like this:
Code:
<!ATTLIST BranchID type (AFR|UKR) "AFR">

Like I mentioned before, "BranchID" is an attribute, so we define it as one. Furthermore, we want to specify the values for it, so in this case we include AFR, or (the "|") UKR. Then finally, we specify the default value, so in this case the default value would be "AFR".
Quote:
4. is there any way we can show them in tables?

Yes we can show them in tables, I would recommend using an XSL transformation (so it displays as HTML). Read about those here: W3 Schools - XSL. If you get a working XML document, post it along with what you would like the table to display, and I can give you further help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Xml + Dtd


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT