简体   繁体   English

Azure 数据工厂中的 XML 验证

[英]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.

相关问题 在Azure数据工厂中针对Azure SQL Server进行XML文件验证 - XML File Validation Against Azure SQL Server in Azure Data Factory XML 文件使用 Azure 数据工厂 - XML File Using Azure Data Factory Azure 数据工厂将数据从 XML 复制到 SQL 突触池 - Azure Data Factory copy data from XML to SQL Synapse pool 使用 azure 数据工厂将多个 xml 文件合并到 csv 文件 - Merging multiple xml files to a csv file using azure Data Factory 如何使用 Azure 数据工厂将 XML 元素读入变量 - How to read an XML element into a variable with Azure Data Factory Azure Data Factory是否可以提取存储在Azure Data Lake Store中的XML文件? - Can Azure Data Factory ingest an XML file stored in Azure Data Lake Store? 通过 Azure 数据工厂 V2 将 XML 数据加载到 SQL 表(Azure)中 - Load XML Data Into SQL Table (Azure) via Azure Data Factory V2 如何在 Azure 数据工厂中使用复制数据活动将 xml 解析为 json 时删除转义字符? - How to remove escaped character when parsing xml to json with copy data activity in Azure Data Factory? XML中的异常数据验证 - Abnormal data validation in XML Azure 数据工厂 (ADF) - 解析/展平 XML 文件 - 获取所有元素的内容匹配通配符标准并位于层次结构中的不同段 - Azure Data Factory (ADF) - Parse/Flatten XML file - Get content of all elements match wildcard criteria and sitting in different segments in Hierarchy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM