Judy,
"O'Dell, Judy" wrote:
>
> Just curious - Does using the setNeedClosingTag(false); change (for example)
> <start></start> into <start /> or just <start>?
It changes <start></start> to <start/> (no space before "/").
As I understand things now, when you're creating your XML you have to "stop"
the chaining process and call setNeedClosingTag(false); in order to get this
behavior, which I find quite clumsy.
For example:
XMLDocument doc = new XMLDocument()
.addElement(new XML("root")
.addElement(new XML("start")
.addXMLAttribute("attr", "value")));
System.out.println(doc.toString());
This produces:
<?xml version="1.0" standalone="yes"?>
<root>
<start attr="value"></start>
</root>
The code gets considerably more cumbersome (see the first two lines) when you
want to eliminate the </start>:
XML start = new XML("start");
start.setNeedClosingTag(false);
XMLDocument doc = new XMLDocument()
.addElement(new XML("root")
.addElement(start
.addXMLAttribute("attr", "value")));
System.out.println(doc.toString());
This produces:
<?xml version="1.0" standalone="yes"?>
<root>
<start attr="value"/>
</root>
While this is still quite workable, it seems inelegant because it is entirely
trivial to eliminate the </start> automatically when an element renders
itself. All it has to do is check whether it has any content, and if not, use
the <start/> style of termination. All other XML writing software I've used
(JDOM, XMLWriter, javax.xml.transform) will do this automatically by default.
Why put this burden on the user of ECS when ECS itself can handle it easily?
Pete Cassetta
> -----Original Message-----
> From: Stephan Nagy [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 08, 2002 7:35 PM
> To: ECS Users List
> Subject: Re: Closing empty elements with /> on the Start tag
>
> just call setNeedClosingTag(false);
>
> -stephan
>
> ----- Original Message -----
> From: "Peter A. Cassetta" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 08, 2002 11:30 AM
> Subject: Closing empty elements with /> on the Start tag
>
> > The XML being generated by ECS is quite bulky due to many unnecessary
> closing
> > tags.
> >
> > My file uses a lot of attribute-only tags:
> >
> > 1. <start attr1="value" attr2="value"/>
> >
> > When I output via ECS I get:
> >
> > 2. <start attr1="value" attr2="value"></start>
> >
> > Is there an easy way to have empty elements automatically closed by just
> > prepending "/" before closing the opening tag (as in "1" above)?
> >
> > Thanks.
> >
> > Pete Cassetta
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>