Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

Node.js node-xml package add xsl stylesheet to xml header

I'm using node-xml to construct my sitemaps. Now I want to add a XSL stylesheet.

My code:

xml(
    {
      "?xml-stylesheet": [{ _attr: { type: "text/xsl", href: "sitemap.xsl" } }],
      sitemapindex: [
        { _attr: { xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" } },
        { sitemap: [
          { loc: "https://nextjs.marcofranssen.nl/blog-sitemap.xml" }, 
          { lastmod: new Date().toISOString() },
        ]
      ],
    },
    { declaration: true }
)

Result:

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"></?xml-stylesheet>

Expected:

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://nextjs.marcofranssen.nl/blog-sitemap.xml</loc>
    <lastmod>2021-01-24T12:55:02.245Z</lastmod>
  </sitemap>
</sitemapindex>

Does anyone know how I can get the XSL stylesheet properly working with node-xml?

Cross posted here as well. https://github.com/dylang/node-xml/issues/44

question from:https://stackoverflow.com/questions/65871455/node-js-node-xml-package-add-xsl-stylesheet-to-xml-header

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...