xml - XSL 转换 - 使用来自在线资源的 XML
问题描述
我正在尝试使用来自在线 XML 资源的数据更新现有 XML 文件的 XSL 文件。
原始 XML 文件和 XSL 位于 localhost(使用 http)上,而我的在线资源(另一个包含新内容的 XML 文件)位于https://example.com/xml/update.xml
XSL 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
http://schemas.opengis.net/iso/19139/20060504/srv/srv.xsd">
<xsl:output method="xml" indent="yes"/>
<!-- Identity template, copies everything as is -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Override for target element -->
<xsl:template match="gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation">
<!-- Copy the element -->
<xsl:copy>
<!-- And everything inside it -->
<xsl:apply-templates select="@*|node()"/>
<xsl:for-each select="document('https://example.com/xml/update.xml')/newData">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
在 localhost 上查看 XML 文件时出现以下错误:
Unsafe attempt to load URL https://example.com/xml/update.xml from frame with URL http://localhost/tutorial/metadata/ENVI_Natura2000.xml. Domains, protocols and ports must match.
有什么办法可以修改我的 XSL 文档来绕过它?
解决方案
推荐阅读
- angular-material - 在Angular中使用自定义模板时占位符和标签重叠
- swift - 截断文本的最大行高
- python - 如何使用 matplotlib 和 seaborn 在绘图值上显示轴刻度标签?
- css - 如何在离子选择中显示多个选定的值?
- node.js - TypeError:无法读取未定义节点js的属性“名称”
- javascript - 如何在node.js中更改函数内的全局变量
- angular - 如何在 Typescript 中获取选中的复选框值
- ios - 在 API 调用中使用 Codable 和 Decodable
- google-sheets - ImportXML Google Sheets 从网站挑选价格
- python - 添加每个用户的评分数列,熊猫