|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||||
|
|||||
|
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:
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:
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:
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Xml + Dtd |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|