PWA как посредник для обработки XML

Настройка среды разработки

PWA требует установки определённых HTTP-заголовков для корректной работы. Для этого необходимо настроить сервер, который будет их формировать. Да и в целом для разработки PWA удобно иметь такой сервер, чтобы симулировать полноценную работу приложения. В качестве предварительного варианта можно посмотреть на связку VSCode с расширением ms-vscode.live-server.

Регистрация Service Worker

https://github.com/mdn/dom-examples/tree/main/service-worker/simple-service-worker

Наброски работы с XML/XSLT

const parser = new DOMParser();

// Создание XML документа
const xml = document.implementation.createDocument(null, "root", null)

// Создание XSL-документа
const style = parser.parseFromString(`
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>

    <xsl:template match="/root">
        <html>
            <head>
                <title>XSLT transformation sample</title>
            </head>
            <body>
                Root transformed
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
`,"text/xml")

//TODO:XMLHttpRequest

const xslt = new XSLTProcessor();
xslt.importStylesheet(style);
const result = xslt.transformToDocument(xml);

document.documentElement.replaceWith(result.documentElement);