Hi there
> So, anyways, I'm creating a DTD for an XML document and have a few
> questions...
>
> I have a vendor that has an address. The address consists of various elements
> such as street, city, etc. Now then, the address element itself has no
> attributes or data directly in it. Is it worth having an address element?
>
> e.g.
>
> <address>
> <street>123 any street</street>
> <city>calgary</city>
> </address>
While not necessary, the address element is probably a good idea: it helps
to define the child elements and might make it easier for you to get at
various bits of your document later on (using XPath functions in DOM or XSLT
manipulation). It also makes your document more human-readable, which is
often a good thing. Finally, 'branchy' documents generally allow for better
parser performance than flat ones - it's quicker for an XML processor to
find 'vendor/address/city' than to scan all the nodes for 'city' elements.
> Also, when creating the XML document, if there is no street, should I do
> <street></street> or just omit the attribute altogether? Do parsers get angry
> when there are elements that are empty?
Parsers generally cope with empty elements pretty well. My opinion is that
it's better to have an empty element than to omit it altogether (unless
keeping your document compact is a crucial consideration), since it's
usually easier to edit the contents of an element than to check whether or
not it exists and then create a new one with the relevant data. And again,
it makes the structure of the document more obvious to human readers.
We've set up a CF / XML mailing list where this question wouldn't be quite
so OT! If you're interested, you can join up at
http://torchbox.com/xml/
Best wishes
Tom
-----------------+
tom dyson
t: +44 (0)1608 811870
m: +44 (0)7958 752657
[EMAIL PROTECTED]
http://torchbox.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists