Skip to content

xml stylesheets do not properly support html features #10166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
solonovamax opened this issue May 20, 2025 · 1 comment
Open

xml stylesheets do not properly support html features #10166

solonovamax opened this issue May 20, 2025 · 1 comment

Comments

@solonovamax
Copy link
Contributor

🐛 bug report

*.xslt files included via <?xml-stylesheet ...?> do not properly support all html features, such as:

  • dependencies
  • inline scripts/styles
  • posthtml minification
  • etc.

Also somewhat related, but .xsl and .xslt files cannot be processed directly by parcel. Right now they can only be referenced via <?xml-stylesheet ...?>.
It would be super nice if they could just be processed directly, eg. parcel build file.xslt.
My usecase for this is that my rss feeds are dynamically generated, and I just want to insert a reference to the stylesheet at the top of them.

Sample stylesheet:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom">
    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <html>
            <head>
                <meta name="viewport" content="width=device-width, initial-scale=1"/>
                <meta name="referrer" content="unsafe-url"/>
                <title>
                    <xsl:value-of select="/atom:feed/atom:title"/>
                </title>
                <link rel="stylesheet" href="/src/assets/scss/water/core.scss"/>
            </head>
        </html>
    </xsl:template>
</xsl:stylesheet>

🤔 Expected Behavior

html is properly processed.

Expected output:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom">
    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <html>
            <head>
                <meta name="viewport" content="width=device-width, initial-scale=1"/>
                <meta name="referrer" content="unsafe-url"/>
                <title>
                    <xsl:value-of select="/atom:feed/atom:title"/>
                </title>
                <link rel="stylesheet" href="file.[hash].css"/>
            </head>
        </html>
    </xsl:template>
</xsl:stylesheet>

😯 Current Behavior

html is not properly processed.

Actual output:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom">
    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <html>
            <head>
                <meta name="viewport" content="width=device-width, initial-scale=1"/>
                <meta name="referrer" content="unsafe-url"/>
                <title>
                    <xsl:value-of select="/atom:feed/atom:title"/>
                </title>
                <link rel="stylesheet" href="/src/assets/scss/water/core.scss"/>
            </head>
        </html>
    </xsl:template>
</xsl:stylesheet>

💁 Possible Solution

A solution to this is probably somewhat complicated.

I tried hacking something together myself, however the main issue I ran into was that if I processed the file as if it were html, then all of the xsl-prefixed tags get removed.

🔦 Context

I'm trying to include a stylesheet in rss & atom feeds.
For example, see: https://www.rss.style/

Example feed: https://www.rss.style/example.xml?feedurl=https%3A%2F%2Fnews.ycombinator.com%2Frss

💻 Code Sample

I don't have a full code sample atm, as I'm working in a project with a lot of stuff and it's very late.
I'll provide a full code sample later (remind me if I forget)

🌍 Your Environment

Software Version(s)
Parcel 2.15.1
Node 22.15.0
npm/Yarn 4.8.1
Operating System Arch Linux 6.14.4-arch1-2 x86_64
@devongovett
Copy link
Member

You could probably write a custom transformer plugin for this. Take a look at the XML transformer (which supports rss/atom feeds at the moment) for inspiration: https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/xml/src/XMLTransformer.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants