PDA

View Full Version : XML im i missing something? (very novice)


bearsdenred
11-23-2004, 12:55 AM
Hello wondering if you guys can help me understand all about XML XSL and DTD's

i bought a book on XML "XML by example" by Marchal Benoit and i cant make head or tail of the problems im facing creating a XML store.

Heres my problem.

I want to create a XML document to store, say a stock list of CD's for a e-commerce site. this file needs to be searched, and added to..

heres an example of my coding so far.... please dont laugh, im not a programmer. :(

=============
Stock XML

<!DOCTYPE stock SYSTEM "stock.dtd">
<stock id="555-12-3434">
<title>Fifa 2005</title>
<format>PCCD</format>
<description>Football Game</description>
<code>EA3323</code>
<price>£29.99</price>
<gene>Football</gene>
</stock>

============

DTD

<!-- Stock,DTD -->
<!ELEMENT stock (title, format, description, code, price, gene)>
<!ATTLIST employee
id CDATA #REQUIRED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT format (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT code (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT gene (#PCDATA)>


Im i missing a lot of information? are these genuie XML documents? any help appreicated.. :)

Alex Vincent
11-23-2004, 02:49 AM
Looks good, so far. Where's your <!ELEMENT employee> definition? Where would the employee element fit in your XML document's structure?

Or, alternatively, why do you have a <!ATTLIST employee ...> there?

bearsdenred
11-23-2004, 11:41 AM
the attlist employee, is actually taken from an example from W3schools.com it was an example layout of how to design an XML document, it doesnt need to be there.

How to i view a DTD or XML document in the house using XP home?

mpjbrennan
11-24-2004, 04:59 PM
DTD and XML documents are text, so you can view them in any text editor. With regard to DTD's - if you are a novice I wouldn't worry about them too much at the beginning. As far as I know none of the major browsers are validating parsers* so you can put as many restrictions as you like in the DTD and they will still render the page.

patrick

* or am I out of date?