XML Only allow certain input in an element using a DTD

freevoka

New Member
Alright, I'm trying to allow only the following inputs (electronics, groceries, household) to be allowed in the category element, however I cannot figure out the correct way to do this. I'm using an internal DTD and have two full examples of how I want it to handle documents. Here is the code:\[code\]<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE manufacturer[ <!ELEMENT manufacturer (companyName, address, phone, contactPerson?, products)> <!ATTLIST manufacturer identifier CDATA #REQUIRED> <!ELEMENT companyName (#PCDATA)> <!ELEMENT address (#PCDATA)> <!ELEMENT phone (#PCDATA)> <!ELEMENT contactPerson (#PCDATA)> <!ELEMENT products (product+)> <!ELEMENT product (model, price, description, category)> <!ATTLIST product code CDATA #REQUIRED> <!ELEMENT model (#PCDATA)> <!ELEMENT price (#PCDATA)> <!ELEMENT description (#PCDATA)> <!ELEMENT category (household|groceries|electronics) ]><manufacturer identifier = "m1"> <companyName>Kitchen Manufacturers International</companyName> <address>1256 Factory Lane, Cleveland, OH 44111</address> <phone>216-333-4444</phone> <contactPerson>Fred Smith</contactPerson> <products> <product code = "X345"> <model>Sun Beam Mixer</model> <price>14.75</price> <description>Popular handheld mixer</description> <category>household</category> </product> <product code = "MW30"> <model>GE30 Microwave</model> <price>99.95</price> <description>A popular model</description> <category>household</category> </product> </products></manufacturer><manufacturer identifier = "m3"> <companyName>Kraft Foods Incorporated</companyName> <address>1515 Kraft Avenue, Chicago, IL 37897</address> <phone>222-333-4444</phone> <products> <product code = "345DR"> <model>Jiffy Peanut Butter</model> <price>4.95</price> <description>America
 
Back
Top