Writing an XML DTD for an XML documentIf you know the different components and the syntax of a DTD statement you can easily write it. before writing a DTD you should also know how your XML file elements should be present. To start with let us consider an example XML file where you need the root node to be <books>. This node can have one or more <book> node. For this you will be writing the DTD statement as, <!ELEMENT books (book+) > The plus sign indicates that the book node can be one or more. If the book node is to have two other child nodes named title and author. The author for a title can be more than one and at least one. So the DTD statement for that would be, <!ELEMENT book (title, author+) > The data that is present within the title tags and the author tags are text that is parsed by the parser. Hence they are written as #PCDATA. If you have tools like XMLSpy you can generate a DTD from the XML document easily with the inbuilt tool for that purpose.
|
|
|||
|
||||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.