<commit_before>var XML3DDataAdapterFactory = require("../data/adapter/factory.js");
var RenderAdapterFactory = require("../renderer/renderer/adapter/factory.js");
var config = require("../interface/elements.js").config;

/**
 *
 * @constructor
 * @extends FormatHandler
 */
var XML3DFormatHandler = function () {
    XML3D.resource.FormatHandler.call(this);
    this.renderAdapterFactories = {};
    this.dataAdapterFactory = new XML3DDataAdapterFactory();
};
XML3D.createClass(XML3DFormatHandler, XML3D.resource.FormatHandler);

XML3DFormatHandler.prototype.isFormatSupported = function (response) {
    if (response.headers.has("Content-Type")) {
        return response.headers.get("Content-Type") === "application/xml";
    }
    if (response.url.match(/\.xml/)) {
        return true;
    }
};

XML3DFormatHandler.prototype.getFormatData = function (response) {
    return response.text().then(function(responseText) {
        var parser = new DOMParser();
        var doc = parser.parseFromString(responseText, "text/xml");

        var xml3dElements = doc.querySelectorAll("xml3d");
        for (var i = 0; i < xml3dElements.length; ++i) {
            config.element(xml3dElements[i]);
        }
        return doc;
    });<commit_msg>XML3DFormatHandler: Allow (deprecated) text/xml content type for XML resources.<commit_after>var XML3DDataAdapterFactory = require("../data/adapter/factory.js");
var RenderAdapterFactory = require("../renderer/renderer/adapter/factory.js");
var config = require("../interface/elements.js").config;

/**
 *
 * @constructor
 * @extends FormatHandler
 */
var XML3DFormatHandler = function () {
    XML3D.resource.FormatHandler.call(this);
    this.renderAdapterFactories = {};
    this.dataAdapterFactory = new XML3DDataAdapterFactory();
};
XML3D.createClass(XML3DFormatHandler, XML3D.resource.FormatHandler);

XML3DFormatHandler.prototype.isFormatSupported = function (response) {
    if (response.headers.has("Content-Type")) {
        var contentType = response.headers.get("Content-Type");
        return contentType === "application/xml" || contentType === "text/xml";
    }
    if (response.url.match(/\.xml/)) {
        return true;
    }
};

XML3DFormatHandler.prototype.getFormatData = function (response) {
    return response.text().then(function(responseText) {
        var parser = new DOMParser();
        var doc = parser.parseFromString(responseText, "text/xml");

        var xml3dElements = doc.querySelectorAll("xml3d");
        for (var i = 0; i < xml3dElements.length; ++i) {
            config.element(xml3dElements[i]);
        }
        return doc;
    });
{'fraction_non_alphanumeric': 0.143184421534937, 'fraction_numerical': 0.011072928598701794, 'mean_word_length': 3.6785714285714284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2213038', 'n_tokens_mistral': 769, 'n_tokens_neox': 767, 'n_words': 133}