@Override protected void handleControlEnd( String uri, String localname, String qName, Attributes attributes, String staticId, String effectiveId, XFormsControl control) throws SAXException { handlerContext.popCaseContext(); final ElementHandlerController controller = handlerContext.getController(); if (!handlerContext.isNoScript()) { currentOutputInterceptor.flushCharacters(true, true); // Restore output controller.setOutput(currentSavedOutput); final boolean isMustGenerateBeginEndDelimiters = !handlerContext.isFullUpdateTopLevelControl(effectiveId); if (isMustGenerateBeginEndDelimiters) { if (currentOutputInterceptor.getDelimiterNamespaceURI() != null) { // Output end delimiter currentOutputInterceptor.outputDelimiter( currentSavedOutput, currentOutputInterceptor.getDelimiterNamespaceURI(), currentOutputInterceptor.getDelimiterPrefix(), currentOutputInterceptor.getDelimiterLocalName(), "xforms-case-begin-end", "xforms-case-end-" + XFormsUtils.namespaceId(containingDocument, effectiveId)); } else { // Output start and end delimiter using xhtml:span final String xhtmlPrefix = handlerContext.findXHTMLPrefix(); currentOutputInterceptor.outputDelimiter( currentSavedOutput, XMLConstants.XHTML_NAMESPACE_URI, xhtmlPrefix, "span", "xforms-case-begin-end", "xforms-case-begin-" + XFormsUtils.namespaceId(containingDocument, effectiveId)); currentOutputInterceptor.outputDelimiter( currentSavedOutput, XMLConstants.XHTML_NAMESPACE_URI, xhtmlPrefix, "span", "xforms-case-begin-end", "xforms-case-end-" + XFormsUtils.namespaceId(containingDocument, effectiveId)); } } } else if (!isVisible) { // Case not visible, restore output controller.setOutput(currentSavedOutput); } }