*/
public void setEmptyXmlTag (boolean emptyXmlTag)
{
Vector attributes;
int size;
Attribute attribute;
String name;
String value;
int length;
attributes = getAttributesEx ();
size = attributes.size ();
if (0 < size)
{
attribute = (Attribute)attributes.elementAt (size - 1);
name = attribute.getName ();
if (null != name)
{
length = name.length ();
value = attribute.getValue ();
if (null == value)
if (name.charAt (length - 1) == '/')
{
// already exists, remove if requested
if (!emptyXmlTag)
if (1 == length)
attributes.removeElementAt (size - 1);
else
{
// this shouldn't happen, but covers the case
// where no whitespace separates the slash
// from the previous attribute
name = name.substring (0, length - 1);
attribute = new Attribute (name, null);
attributes.removeElementAt (size - 1);
attributes.addElement (attribute);
}
}
else
{
// ends with attribute, add whitespace + slash if requested
if (emptyXmlTag)
{
attribute = new Attribute (" ");
attributes.addElement (attribute);
attribute = new Attribute ("/", null);
attributes.addElement (attribute);
}
}
else
{
// some valued attribute, add whitespace + slash if requested
if (emptyXmlTag)
{
attribute = new Attribute (" ");
attributes.addElement (attribute);
attribute = new Attribute ("/", null);
attributes.addElement (attribute);
}
}
}
else
{
// ends with whitespace, add if requested
if (emptyXmlTag)
{
attribute = new Attribute ("/", null);
attributes.addElement (attribute);
}
}
}
else
// nothing there, add if requested
if (emptyXmlTag)
{
attribute = new Attribute ("/", null);
attributes.addElement (attribute);
}
}