以下内容将检测并报告 HTTP 404(和 HTTP 200)。 但它不处理 CORS 错误,而且我仍然不确定如何捕获这些错误。
要查看三个结果(有效(希望如此)、404 和 CORS) - 手动编辑下面的标签,分别将 URL 索引从 1 更改为 3。
<xf:resource value="urls/url[1]"/>
<?xml
version="1.0"
encoding="UTF-8"?>
<?xml-stylesheet
href="declarative4all/build/xsl/xsltforms.xsl"
type="text/xsl"?>
<?xsltforms-options
debug="yes"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ht="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
lang="en">
<head>
<meta
charset="utf-8"/>
<meta
name="viewport"
content="width=device-width, initial-scale=1"/>
<xf:model id="model">
<xf:instance>
<data xmlns="">
<urls>
<url>https://podcasts.files.bbci.co.uk/b05qqhqp.rss</url>
<url>https://httpbin.org/status/404</url>
<url>https://feeds.acast.com/public/shows/125ef5a6-6c61-4024-b70e-3487a971a26c</url>
</urls>
<res>initial</res>
</data>
</xf:instance>
<xf:instance id="feed">
<channel xmlns="">
<title/>
<description/>
<image>
<url/>
</image>
<item/>
</channel>
</xf:instance>
<xf:submission id="s_load" replace="instance" instance="feed" method="get" serialization="none">
<xf:resource value="urls/url[1]"/>
<xf:action ev:event="xforms-submit-error">
<xf:setvalue ref="res" value="event('response-status-code')"/>
</xf:action>
<xf:action ev:event="xforms-submit-done">
<xf:setvalue ref="res" value="event('response-status-code')"/>
</xf:action>
</xf:submission>
<xf:action ev:event="xforms-ready">
<xf:send submission="s_load"/>
</xf:action>
</xf:model>
</head>
<body>
<xf:output value="res">
<xf:label>Response-Status-Code: </xf:label>
</xf:output>
<xf:group ref="instance('feed')/channel">
<xf:repeat ref="item">
<details>
<summary><xf:output value="title"/></summary>
<xf:output value="description"/>
</details>
</xf:repeat>
</xf:group>
</body>
</html>