Hi Ernst,
> Example:
>
> startTag("html");
> attribute("lang", "en");
> pcdata("");
> endTag();
>
> Currently (xmlenc 0.21) this would produce the following XML:
>
> <html lang="en"></html>
>
> But when VOID_WITHIN_ELEMENT is fully supported, then this would
> produce:
>
> <html lang="en"/>
>
> Reconsidering this, I think I should not pursue this any further and
> remove all evidence I ever did. It's just getting away from simplicity.
I disagree. I think the <tag attr="value"/> pattern is a real plus. It
shortens the length of the XML file considerably, especially if you use
this form a lot (I do) and if the "tag"s you use it with are long (many
of mine are). Keep in mind that most people will use XMLOutputter to
write to disk, and the time involved in disk writes will far outweigh
the time spent doing some logic to see what type of closing tag is
necessary. You'll have a more efficient outputter if you output shorter
XML, and I know efficiency is a primary design goal here.
> The same applies to the short-circuiting when an empty string is
> printed.
> For example, currently (xmlenc 0.21) the following code:
>
> startTag("head");
> comment("");
> startTag("title");
>
> produces the following XML:
>
> <head><title>
>
> instead of the (perhaps expected):
>
> <head><!----><title>
>
> I see no good reason to _keep_ the old behaviour. It's again
> conflicting with the principle of simplicity.
Here I'm fine. If some clown wants to output an empty comment, why not
let him? In the past Henri and I have discussed an XML writing mode
where empty elements are not written at all. I even put in a few kludge
methods in my personal copy of XmlWriter like
writeEmptyElementWithText(String tag, String text) and if text is null
or "" then nothing is written. This is helpful in conserving file space
for things like an optional second line of an address.
Anyway, I think that at the level of XMLOutputter you should just output
whatever is sent. Omitting comments or elements if empty should probably
be handled at a higher level (the classes Henri is working on).
I hope I understood your original note, and that this made some sense.
Gratefully,
Pete Cassetta
pe...@fi...
-------------------------------------------
Fingertip Software
433 Kitty Hawk Rd., Suite 216
P.O. Box 2487
Universal City, TX 78148
Orders: (800) 209-4063 -or- (210) 659-6832
Support: (210) 659-2532
Fax: (210) 659-8870
http://www.fingertipsoft.com
-------------------------------------------
|