Element serializeDocumentation()

in src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java [967:1009]


    Element serializeDocumentation(Document doc, XmlSchemaDocumentation documentationObj, XmlSchema schema) {

        Element documentationEl = createNewElement(doc, "documentation", schema.getSchemaNamespacePrefix(),
                                                   XmlSchema.SCHEMA_NS);
        if (documentationObj.source != null) {
            documentationEl.setAttribute("source", documentationObj.source);
        }
        if (documentationObj.language != null) {
            documentationEl.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang",
                                           documentationObj.language);
        }

        if (documentationObj.markup != null) {
            int markupLength = documentationObj.markup.getLength();
            for (int j = 0; j < markupLength; j++) {
                Node n = (Node)documentationObj.markup.item(j);

                switch (n.getNodeType()) {
                case Node.ELEMENT_NODE:
                    appendElement(doc, documentationEl, n, schema);
                    break;
                case Node.TEXT_NODE:
                    Text t = doc.createTextNode(n.getNodeValue());
                    documentationEl.appendChild(t);
                    break;
                case Node.CDATA_SECTION_NODE:
                    CDATASection s = doc.createCDATASection(n.getNodeValue());
                    documentationEl.appendChild(s);
                    break;
                case Node.COMMENT_NODE:
                    Comment c = doc.createComment(n.getNodeValue());
                    documentationEl.appendChild(c);
                    break;
                default:
                    break;
                }
            }
        }
        // process extension
        processExtensibilityComponents(documentationObj, documentationEl);

        return documentationEl;
    }