Format the given SARL behavior.

@param behavior the SARL component.
@param document the document.
178821
protected void _format(SarlBehavior behavior, IFormattableDocument document) {
		formatAnnotations(behavior, document, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
		formatModifiers(behavior, document);

		final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(behavior);
		document.append(regionFor.keyword(this.keywords.getBehaviorKeyword()), ONE_SPACE);

		document.surround(regionFor.keyword(this.keywords.getExtendsKeyword()), ONE_SPACE);
		document.format(behavior.getExtends());

		formatBody(behavior, document);
	}
1168977
private static org.w3c.dom.Document toDom(final Document doc) {
        try {
            val xmlOutputter = new XMLOutputter();
            val elemStrWriter = new StringWriter();
            xmlOutputter.output(doc, elemStrWriter);
            val xmlBytes = elemStrWriter.toString().getBytes(Charset.defaultCharset());
            val dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
            dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            dbf.setFeature("http://apache.org/xml/features/validation/schema/normalized-value", false);
            dbf.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);
            dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
            dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);

            return dbf.newDocumentBuilder().parse(new ByteArrayInputStream(xmlBytes));
        } catch (final Exception e) {
            LOGGER.trace(e.getMessage(), e);
            return null;
        }
    }
36284
public static ChangeEvent fromBsonDocument(final BsonDocument document) {
    keyPresent(Fields.ID_FIELD, document);
    keyPresent(Fields.OPERATION_TYPE_FIELD, document);
    keyPresent(Fields.NS_FIELD, document);
    keyPresent(Fields.DOCUMENT_KEY_FIELD, document);

    final BsonDocument nsDoc = document.getDocument(Fields.NS_FIELD);

    final UpdateDescription updateDescription;
    if (document.containsKey(Fields.UPDATE_DESCRIPTION_FIELD)) {
      updateDescription = UpdateDescription.fromBsonDocument(
          document.getDocument(Fields.UPDATE_DESCRIPTION_FIELD)
      );
    } else {
      updateDescription = null;
    }

    final BsonDocument fullDocument;
    if (document.containsKey(Fields.FULL_DOCUMENT_FIELD)) {
      final BsonValue fdVal = document.get(Fields.FULL_DOCUMENT_FIELD);
      if (fdVal.isDocument()) {
        fullDocument = fdVal.asDocument();
      } else {
        fullDocument = null;
      }
    } else {
      fullDocument = null;
    }

    return new ChangeEvent<>(
        document.getDocument(Fields.ID_FIELD),
        OperationType.fromRemote(document.getString(Fields.OPERATION_TYPE_FIELD).getValue()),
        fullDocument,
        new MongoNamespace(
            nsDoc.getString(Fields.NS_DB_FIELD).getValue(),
            nsDoc.getString(Fields.NS_COLL_FIELD).getValue()),
        document.getDocument(Fields.DOCUMENT_KEY_FIELD),
        updateDescription,
        document.getBoolean(Fields.WRITE_PENDING_FIELD, BsonBoolean.FALSE).getValue());
  }
172340
void add_document(Document doc)
    {
        doc.feature().normalize();
        documents_.add(doc);
        composite_.add_vector(doc.feature());
    }
244231
protected void appendFullDocumentHeader(StringBuilder sb, Document doc) {
        if (appendDocumentXmlDeclaration(sb, doc)) {
            sb.append("\n");
        }
        if (appendDocumentType(sb, doc.getDoctype())) {
            sb.append("\n");
        }
        appendOnlyElementStartTagWithAttributes(sb, doc.getDocumentElement());
    }
974660
function pushDocument(doc) {
    if (!(doc instanceof Document)) {
        console.warn('Cannot navigate to the document.', doc);
        return;
    }
    navigationDocument.pushDocument(doc);
}
236006
function(el, document) {
            var self    = this;

            self.callActions('beforeCacheDom', arguments);

            self.dom.document  = document;
            self.dom.body      = self.dom.document.querySelector('body');
            self.dom.container = el;
            self.dom.parent    = el;

            self.callActions('afterCacheDom', arguments);
        }
1220932
public function format(Document $document)
    {        
        $this->preFormat($document);
        foreach($this->getChildren() as $child)
        {
            $child->format($document);
        }
        $this->postFormat($document);
    }
584667
public static void displayAction(
        CmsContainerElementBean element,
        I_CmsFormatterBean formatter,
        PageContext context,
        ServletRequest request,
        ServletResponse response) {

        displayAction(element, formatter, false, false, false, null, null, context, request, response);
    }
877444
protected void addAttributes(final GedDocument<?> document) {
        for (final GedDocument<? extends GedObject> attribute : document
                .getAttributes()) {
            final DocumentToApiModelVisitor v = createVisitor();
            attribute.accept(v);
            baseObject.getAttributes()
                    .add(convertToAttribute(v.getBaseObject()));
        }
    }
198851
public void parse(Document document) {
        responsePayLoad = document.getDocumentElement();
        status = responsePayLoad.getAttribute("stat");
        if ("ok".equals(status)) {
            Element photoIdElement = (Element) responsePayLoad.getElementsByTagName("photoid").item(0);
            if (photoIdElement != null) {
                photoId = ((Text) photoIdElement.getFirstChild()).getData();
            } else {
                photoId = null;
            }
            Element ticketIdElement = (Element) responsePayLoad.getElementsByTagName("ticketid").item(0);
            if (ticketIdElement != null) {
                ticketId = ((Text) ticketIdElement.getFirstChild()).getData();
            } else {
                ticketId = null;
            }
        } else {
            Element errElement = (Element) responsePayLoad.getElementsByTagName("err").item(0);
            errorCode = errElement.getAttribute("code");
            errorMessage = errElement.getAttribute("msg");
        }
    }
962316
public function processDocument(Document $document)
    {
        /** @var TableOfContents[] $tocs */
        $tocs = [];

        $headings = [];

        $document->heading_ids = [];
        $walker = $document->walker();
        while ($event = $walker->next()) {
            $node = $event->getNode();

            if ($node instanceof TableOfContents && !$event->isEntering()) {
                $tocs[] = $node;
                continue;
            }

            if (!($node instanceof Heading) || !$event->isEntering()) {
                continue;
            }

            $this->ensureHeadingHasId($document, $node);
            $headings[] = new Entry($node);
        }

        if (count($headings) && (count($tocs) || $this->hasAutoTOC())) {
            $generated = $this->generate($headings);

            if (count($tocs)) {
                foreach ($tocs as $toc) {
                    $toc->appendChild($this->render($generated->getChildren()));
                }
            } else {
                $document->prependChild($this->render($generated->getChildren()));
            }
        }
    }
558552
public static void setDocumentElement(final Document document, final Element element) {
        Element documentElement = document.getDocumentElement();
        if (documentElement != null) {
            document.removeChild(documentElement);
        }
        if (element != null) {
            if (element.getOwnerDocument().equals(document)) {
                document.appendChild(element);
                return;
            }
            Node node = document.adoptNode(element);
            document.appendChild(node);
        }
    }
276258
static void serialize(final Document doc, final OutputStream os, final String encoding)
        throws TransformerFactoryConfigurationError, TransformerException, IOException
  {
    if (doc == null)
      throw new IllegalArgumentException("No document provided.");

    if (os == null)
      throw new IllegalArgumentException("No output stream provided");

    if (encoding == null || encoding.isEmpty())
      throw new IllegalArgumentException("No encoding provided.");

    final TransformerFactory transformerFactory = TransformerFactory.newInstance();
    transformerFactory.setAttribute("indent-number", Integer.valueOf(2));
    final Transformer t = transformerFactory.newTransformer();

    t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
    t.setOutputProperty(OutputKeys.METHOD, "xml");
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty(OutputKeys.ENCODING, encoding);

    final OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
    t.transform(new DOMSource(doc), new StreamResult(osw));
    osw.flush();
  }
240584
@Check(CheckType.FAST)
	public void checkBehaviorUnitEventType(SarlBehaviorUnit behaviorUnit) {
		final JvmTypeReference event = behaviorUnit.getName();
		final LightweightTypeReference ref = toLightweightTypeReference(event);
		if (ref == null || !this.inheritanceHelper.isSarlEvent(ref)) {
			error(MessageFormat.format(
					Messages.SARLValidator_75,
					event.getQualifiedName(),
					Messages.SARLValidator_62,
					this.grammarAccess.getOnKeyword()),
					event,
					null,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
					TYPE_BOUNDS_MISMATCH);
		}
	}
1180696
private void applyStyles(Document doc) {
        Elements allStyledElements = doc.getElementsByAttribute(CSS_STYLE);

        for (Element e : allStyledElements) {
            String newStyle = e.attr(CSS_STYLE);
            String oldStyle = e.attr(STYLE_ATTR);
            e.attr(STYLE_ATTR, (newStyle + "; " + oldStyle).replace(";;", ";"));
            e.removeAttr(CSS_STYLE);
        }
    }
636596
void writeTree() throws DocumentException {
		// MBeans pour la plateforme
		margin = 0;
		final MBeanNode platformNode = mbeans.get(0);
		writeTree(platformNode.getChildren());

		for (final MBeanNode node : mbeans) {
			if (node != platformNode) {
				newPage();
				addToDocument(new Chunk(node.getName(), boldFont));
				margin = 0;
				writeTree(node.getChildren());
			}
		}
	}