public IXmlWriter attribute()

in apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/impl/base/XmlWriter.java [476:501]


    public IXmlWriter attribute(CharSequence name, CharSequence value) throws IOException {
        if (elementNames.isEmpty()) {
            if (elementsWritten) {
                throw new OperationNotAllowedException("Root element has already been closed.");
            } else {
                throw new OperationNotAllowedException("Close called before an element has been opened.");
            }
        }
        if (isInvalidName(name)) {
            throw new InvalidXmlException("'" + name + "' is not a valid attribute name.");
        }
        if (!inElement) {
            throw new InvalidXmlException("Attributes can only be written in elements");
        }
        if (currentAttributes.contains(name)) {
            throw new InvalidXmlException("Each attribute can only be written once");
        }
        writer.write(' ');
        rawWrite(name);
        writer.write('=');
        writer.write('\'');
        writeAttributeContent(value);
        writer.write('\'');
        currentAttributes.add(name);
        return this;
    }