[英]XML validation in Azure Data Factory
I am trying to use XSD validation in Azure Data Factory copy activity (with XML as source).我正在尝试在 Azure 数据工厂复制活动中使用 XSD 验证(以 XML 作为源)。 I have an external XSD file.
我有一个外部 XSD 文件。 I am also trying to understand how it can be used in Azure Data Factory.
我还试图了解如何在 Azure 数据工厂中使用它。 In the copy activity, under the Validation type section there are two options XSD and DTD.
在复制活动中,在验证类型部分下有两个选项 XSD 和 DTD。 But, it does not have any way to specify any external file as XSD.
但是,它无法将任何外部文件指定为 XSD。 The documentation is also not clear about this.
文档对此也不清楚。 ( https://docs.microsoft.com/en-us/azure/data-factory/format-xml ).
( https://docs.microsoft.com/en-us/azure/data-factory/format-xml )。 This is what the official doc says:
这是官方文档所说的:
XML schema validation:
You can choose to not validate schema, or validate schema using XSD or DTD.
When using XSD or DTD to validate XML files, the XSD/DTD must be referred inside the XML
files through relative path
I am confused about the second point here.我对这里的第二点感到困惑。
What do they mean by "XML must be referred inside the XML files"? “必须在 XML 文件中引用 XML”是什么意思?
I think it says, we should reference the XSD file(use relative path) in the source xml file.我认为它说,我们应该在源 xml 文件中引用 XSD 文件(使用相对路径)。
For example:例如:
In the ADF I set a Copy activity:在 ADF 中,我设置了一个 Copy 活动:
Here my xml file and xsd file are in the same folder and as follow:
这里我的 xml 文件和 xsd 文件在同一个文件夹中,如下所示:
In the order.xml, use xsi:noNamespaceSchemaLocation="order.xsd"
to specify the xsd file:在 order.xml 中,使用
xsi:noNamespaceSchemaLocation="order.xsd"
指定 xsd 文件:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="order.xsd">
<orderItem>43546533</orderItem>
<orderItem>53546533</orderItem>
<orderItem>73546533</orderItem>
<orderItem>93546533</orderItem>
<orderItem>43546533</orderItem>
<orderItem>73546533</orderItem>
<orderItem>03546533</orderItem>
<orderItem>33546533</orderItem>
<orderItem>43216533</orderItem>
<orderItem>1246533</orderItem>
<orderItem>4466533</orderItem>
</order>
order.xsd:订单.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xsd:element name="order">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="orderItem" type="xsd:string" maxOccurs="10"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
In my case, when the order.xml doesn't meet my verification rules, it will fails:就我而言,当 order.xml 不符合我的验证规则时,它将失败:
Hope my answer is helpful to you!希望我的回答对你有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.