Write needed attributes before the starting element will be closed by adding a trailing '>' character when calling e.g.
{@link ResponseWriter#writeText}.
See {@link ResponseWriter#startElement(String, UIComponent)}
170184
private void listenOnEndAttribute() throws IOException {

        if (lastElement == null) {
            return;
        }

        // no nonce written -> do it
        if ("script".equalsIgnoreCase(lastElement) && LangUtils.isValueBlank(lastNonce)) {
            getWrapped().writeAttribute("nonce", cspState.getNonce(), null);
        }

        if (lastEvents != null && !lastEvents.isEmpty()) {
            String id = lastId;

            // no id written -> generate a new one and write it
            // otherwise we can't identify the element for our scripts
            if (LangUtils.isValueBlank(id)) {
                id = lastElement.toLowerCase() + "-" + UUID.randomUUID().toString();
                getWrapped().writeAttribute("id", id, null);
            }

            // add current collected events to our state
            cspState.getEventHandlers().put(id, lastEvents);
        }

        reset();
    }
128970
def startElement(self, name, attrs):
        
        self.stack.append((self.current, self.chardata))
        self.current = {}
        self.chardata = []
600109
private String appendXmlStartTag(String value)  {
        StringBuilder sb = new StringBuilder();
        sb.append("<").append(value).append(">");

        return sb.toString();
    }
842609
public void writeAfterHTML(PrintWriter out, HttpServletRequest req, Properties properties)
	{
		String strDefault = properties.getProperty(DESTINATION, "");
		out.write("<input type=\"hidden\" value=\"" + strDefault + "\" name=\"" + DESTINATION + "\" />" + RETURN);
	}
747128
private void writeStartElement(final String qName, final Attributes atts) throws IOException {
        final int attsLen = atts.getLength();
        output.write(LESS_THAN + qName);
        for (int i = 0; i < attsLen; i++) {
            final String attQName = atts.getQName(i);
            final String attValue = escapeXML(atts.getValue(i));
            output.write(STRING_BLANK + attQName + EQUAL + QUOTATION + attValue + QUOTATION);
        }
        output.write(GREATER_THAN);
    }
193947
private static void writeParagraphs(final String text, final XmlStringBuilder xml) {
		if (!Util.empty(text)) {
			int start = 0;
			int end = text.length() - 1;

			// Set the start index to the first non-linebreak, so we don't emit leading ui:nl tags
			for (; start < end; start++) {
				char c = text.charAt(start);

				if (c != '\n' && c != '\r') {
					break;
				}
			}

			// Set the end index to the last non-linebreak, so we don't emit trailing ui:nl tags
			for (; start < end; end--) {
				char c = text.charAt(end);

				if (c != '\n' && c != '\r') {
					break;
				}
			}

			char lastChar = 0;

			for (int i = start; i <= end; i++) {
				char c = text.charAt(i);

				if (c == '\n' || c == '\r') {
					if (lastChar != 0) {
						xml.write("<ui:nl/>");
					}

					lastChar = 0;
				} else {
					xml.write(c);
					lastChar = c;
				}
			}
		}
	}
993740
public void beginElement(String elementName) throws IOException {		
		addElementName(elementName);
		indent();
		writer.write("<");
		writer.write(elementName);
	}
340375
@Override
	public void startElement( String uri , String localName , String qName , Attributes attributes ) throws SAXException
    {
        super.startElement(uri,localName,qName,attributes);
        valueBuffer.setLength(0); // Clear value buffer
        nameStack.push(qName);
        String currentPath = StringTools.join(nameStack, "/");
        before(qName,currentPath,attributes);
    }
830912
public void writeElement( String name,
                              int type ) {
        StringBuilder nsdecl = new StringBuilder();

        if (isRootElement) {
            for (Iterator<String> iter = namespaces.keySet().iterator(); iter.hasNext();) {
                String fullName = iter.next();
                String abbrev = namespaces.get(fullName);
                nsdecl.append(" xmlns:").append(abbrev).append("=\"").append(fullName).append("\"");
            }
            isRootElement = false;
        }

        int pos = name.lastIndexOf(':');
        if (pos >= 0) {
            // lookup prefix for namespace
            String fullns = name.substring(0, pos);
            String prefix = namespaces.get(fullns);
            // check if instead of a full URI, the prefix is used
            if (prefix == null && namespaces.containsValue(fullns)) {
                prefix = fullns;
            }
            if (prefix == null) {
                // there is no prefix for this namespace
                name = name.substring(pos + 1);
                nsdecl.append(" xmlns=\"").append(fullns).append("\"");
            } else {
                // there is a prefix
                name = prefix + ":" + name.substring(pos + 1);
            }
        }

        switch (type) {
            case OPENING:
                buffer.append("<" + name + nsdecl + ">");
                break;
            case CLOSING:
                buffer.append("</" + name + ">\n");
                break;
            case NO_CONTENT:
            default:
                buffer.append("<" + name + nsdecl + "/>");
                break;
        }
    }
274972
public void writeElement(String name, Object text)
  {
    startElement(name);
    writeText(text);
    endElement(name);
  }
95129
protected void fireStartElem(String elemName)
        throws org.xml.sax.SAXException
    {        
        if (m_tracer != null)
        {
            flushMyWriter();
            m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_STARTELEMENT,
                elemName, m_attributes);     	 
        }       	
    }
626292
void writeStartElement(final Writer output, final String name, final Attributes atts) throws SAXException {
        try {
            output.write(LESS_THAN);
            output.write(name);
            for (int i = 0; i < atts.getLength(); i++) {
                output.write(STRING_BLANK);
                output.write(atts.getQName(i));
                output.write(EQUAL);
                output.write(QUOTATION);
                output.write(escapeXML(atts.getValue(i)));
                output.write(QUOTATION);
            }
            output.write(GREATER_THAN);
        } catch (IOException e) {
            throw new SAXException(e);
        }
    }
860162
public void writeStartElement(String tag) throws IOException {
		nameStack.push(tag);

		this.startTag(null, tag);
	}
1042934
public void closeElement(String elementName) throws IOException {
		assert(elementNames.size() > 0);
		assert(elementNames.get(elementNames.size() - 1).equals(elementName));
		if(indent || noTextElement)
		indent();		
		writer.write("</");		
		writer.write(elementName);
		writer.write(">\n");		
		removeElementName(elementName);
	}
133501
@Override
  public void startElement(String namespaceURI, String lName,
      String qName, Attributes attrs) throws SAXException {
    if (qName.equals(RULE)) {
      translations.clear();
      id = attrs.getValue("id");
      if (!(inRuleGroup && defaultOff)) {
        defaultOff = "off".equals(attrs.getValue("default"));
      }
      if (inRuleGroup && id == null) {
        id = ruleGroupId;
      }
      correctExamples = new ArrayList<>();
      incorrectExamples = new ArrayList<>();
    } else if (qName.equals(PATTERN)) {
      inPattern = true;
      String languageStr = attrs.getValue("lang");
      if (Languages.isLanguageSupported(languageStr)) {
        language = Languages.getLanguageForShortCode(languageStr);
      }
    } else if (qName.equals(TOKEN)) {
      setToken(attrs);
    } else if (qName.equals(TRANSLATION)) {
      inTranslation = true;
      String languageStr = attrs.getValue("lang");
      if (Languages.isLanguageSupported(languageStr)) {
        Language tmpLang = Languages.getLanguageForShortCode(languageStr);
        currentTranslationLanguage = tmpLang;
        if (tmpLang.equalsConsiderVariantsIfSpecified(motherTongue)) {
          translationLanguage = tmpLang;
        }
      }
    } else if (qName.equals(EXAMPLE)) {
      correctExample = new StringBuilder();
      incorrectExample = new StringBuilder();
      if (attrs.getValue(TYPE).equals("incorrect")) {
        inIncorrectExample = true;
      } else if (attrs.getValue(TYPE).equals("correct")) {
        inCorrectExample = true;
      } else if (attrs.getValue(TYPE).equals("triggers_error")) {
        throw new RuntimeException("'triggers_error' is not supported for false friend XML");
      }
    } else if (qName.equals(MESSAGE)) {
      inMessage = true;
      message = new StringBuilder();
    } else if (qName.equals(RULEGROUP)) {
      ruleGroupId = attrs.getValue("id");
      inRuleGroup = true;
      defaultOff = "off".equals(attrs.getValue(DEFAULT));
    }
  }
1074101
@Override
    public void writeStartTagStart(String localName)
        throws IOException, XMLStreamException
    {
        writeAscii(BYTE_LT);
        writeName(localName);
    }
819790
private final void handleStartElem(char c)
        throws XMLStreamException
    {
        mTokenState = TOKEN_FULL_COALESCED;
        boolean empty;

        if (mCfgNsEnabled) {
            String str = parseLocalName(c);
            c = (mInputPtr < mInputEnd) ?
                mInputBuffer[mInputPtr++] : getNextCharFromCurrent(SUFFIX_EOF_EXP_NAME);
            if (c == ':') { // Ok, got namespace and local name
                c = (mInputPtr < mInputEnd) ?
                    mInputBuffer[mInputPtr++] : getNextCharFromCurrent(SUFFIX_EOF_EXP_NAME);
                mElementStack.push(str, parseLocalName(c));
                c = (mInputPtr < mInputEnd) ?
                    mInputBuffer[mInputPtr++] : getNextCharFromCurrent(SUFFIX_IN_ELEMENT);
            } else {
                mElementStack.push(null, str);
                // c is fine as
            }
            /* Enough about element name itself; let's then parse attributes
             * and namespace declarations. Split into another method for clarity,
             * and so that maybe JIT has easier time to optimize it separately.
             */
             /* 04-Jul-2005, TSa: But hold up: we can easily check for a fairly
              *   common case of no attributes showing up, and us getting the
              *   closing '>' right away. Let's do that, since it can save
              *   a call to a rather long method.
              */
            empty = (c == '>') ? false : handleNsAttrs(c);
        } else { // Namespace handling not enabled:
            mElementStack.push(null, parseFullName(c));
            c = (mInputPtr < mInputEnd) ?
                mInputBuffer[mInputPtr++] : getNextCharFromCurrent(SUFFIX_IN_ELEMENT);
            empty = (c == '>') ? false : handleNonNsAttrs(c);
        }
        if (!empty) {
            ++mCurrDepth; // needed to match nesting with entity expansion
        }
        mStEmptyElem = empty;

        /* 27-Feb-2009, TSa: [WSTX-191]: We used to validate virtual
         *   end element here for empty elements, but it really should
         *   occur later on when actually returning that end element.
         */
        int vld = mElementStack.resolveAndValidateElement();
        mVldContent = vld;
        mValidateText = (vld == XMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT);
    }