Closed oliverjam closed 1 year ago
Will be supported by #22
Tbh I'm not super familiar with xml-stylesheet and I can't find how this is supposed to be handled within the XML spec (https://www.w3.org/TR/xml/#sec-well-formed), maybe they're supposed to be within the processing instructions (https://www.w3.org/TR/xml/#NT-PI) but looks likes the -xml is a suffix instead in them.
Anyways I tested with the sample you provided and it yields something like this:
{
xml: { "@version": 1, "@encoding": "utf-8" },
"$stylesheets": [ { "@href": "/rss.xsl", "@type": "text/xsl" } ],
feed: {
"@xmlns": "http://www.w3.org/2005/Atom",
title: "oli's rss feed",
link: [
{ "@href": "https://oliverjam.es/feed.xml", "@rel": "self", "#text": null },
{ "@href": "https://oliverjam.es", "#text": null }
],
updated: "2023-01-17T00:00:00.000Z",
id: "https://oliverjam.es",
author: { name: "oli" }
}
}
Lmk if this looks ok, if yes I'll issue a new version with this patch 👍
Looks good to me, thank you!
XSLT is kind of a mystery to me as well tbh, no idea how they're supposed to be handled.
As far as I can tell this XML using XSLT is valid:
but parsing it throws with
SyntaxError: Multiple prolog declaration found
. Removing the<?xml-stylesheet?>
fixes the error.It looks like this is because the prolog token is defined to start with just
"<?xml"
, which matches both.https://github.com/lowlighter/xml/blob/448b77319701201654c8dc3f5a6ea7451fdf9f90/utils/types.ts#L130