簡體   English   中英

Azure 數據工廠中的 XML 驗證

[英]XML validation in Azure Data Factory

我正在嘗試在 Azure 數據工廠復制活動中使用 XSD 驗證(以 XML 作為源)。 我有一個外部 XSD 文件。 我還試圖了解如何在 Azure 數據工廠中使用它。 在復制活動中,在驗證類型部分下有兩個選項 XSD 和 DTD。 但是,它無法將任何外部文件指定為 XSD。 文檔對此也不清楚。 https://docs.microsoft.com/en-us/azure/data-factory/format-xml )。 這是官方文檔所說的:

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

我對這里的第二點感到困惑。

“必須在 XML 文件中引用 XML”是什么意思?

我認為它說,我們應該在源 xml 文件中引用 XSD 文件(使用相對路徑)。

例如:
在 ADF 中,我設置了一個 Copy 活動: 在此處輸入圖片說明 這里我的 xml 文件和 xsd 文件在同一個文件夾中,如下所示:
在此處輸入圖片說明

在 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>  

訂單.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> 

就我而言,當 order.xml 不符合我的驗證規則時,它將失敗: 在此處輸入圖片說明

希望我的回答對你有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM