问题描述
我创建了一个file.xml和一个file.xsd。我在notepad ++中安装了XML工具。打开仅file.xml文件之后,然后单击Plugin-> XML Tools-> Validate。出现以下窗口:
这很奇怪,因为我没有指定XML模式(file.xsd)。如果我更改元素的名称,那么xml工具仍会说未检测到错误,但实际上有错误。
如何将file.xml引用到file.xsd?
编辑file.xml的内容如下:
df1 = spark.read.option("header","true").csv("Sales_records-1.csv")
df2 = spark.read.option("header","true").csv("Sales_records-2.csv")
#Finding the rows which are not present in second dataframe
df3 = df2.exceptAll(df1)
EDIT2:file.xsd
<?xml version="1.0"?>
<note
xmlns="https://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.w3schools.com/xml note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
解决方法
Notepad ++不会引发错误,因为a)您的XML文档包含对XML模式文件的引用,并且b)XML文档对该模式有效。
这引用了一个模式文件:
<section class="fullscreen">
<div class="background">
<img src="https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293__340.jpg" />
</div>
</section>
Notepad ++将假定与XML文档本身位于同一文件夹中的本地文件xsi:schemaLocation="https://www.w3schools.com/xml note.xsd"
。
如何将file.xml引用到file.xsd?
如果您的XML文档定义了一个名称空间,那么note.xsd
应该包括该名称空间。您的XML文档位于名称空间xsi:schemaLocation
中。引用XML模式,如下所示:
https://www.w3schools.com