在XSD中共享定义的技术?

时间:2016-01-28 06:49:14

标签: xml dictionary xsd xml-validation

我们正在构建企业级XML Schema。在不同的团队构建的模式之间存在共同的元素,我们希望它们对于相同的数据元素具有相同的名称,因此有一种方法可以使用相同的数据字典。

我们会加班添加元素到数据字典,因为我们构建了模式,但希望所有元素都使用相同的名称 例如,customerfirstname在所有不同的模式中应该是相同的,我们如何实现这一点?

1 个答案:

答案 0 :(得分:0)

通过 命名空间 实现XSD中共享和非共享词汇控制的分离。

第1组(和其他组)可以在他们控制的命名空间中定义XSD,

$objForm = New-Object System.Windows.Forms.Form
$objForm.StartPosition = 1
$objForm.ClientSize = New-Object System.Drawing.Size(300,50)
$objForm.Name = "Form1"
$objForm.Text = "Example ProgressBar"
$objForm.Label = for ($i = 1; $i -le 100; $i++)
                    {Write-Progress -Activity "Testing" -Status "$i% Complete:" -PercentComplete $i;}

$ProgressBar = New-Object System.Windows.Forms.ProgressBar
$ProgressBar.Location = New-Object System.Drawing.Size(10,10)
$ProgressBar.Size = New-Object System.Drawing.Size(280,10)
$ProgressBar.Name = "ProgressBar"
$objForm.Controls.Add($ProgressBar)

$objForm.ShowDialog() | out-Null

并在公共共享控件下的命名空间中导入XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:g1="http://example.com/group1"
           xmlns:c1="http://example.com/common"
           targetNamespace="http://example.com/group1">

  <xs:import namespace="http://example.com/common" schemaLocation="common.xsd"/>

  <xs:element name="Group1X">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="g1:Group1Y"/>
        <xs:element ref="c1:Common1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Group1Y" type="xs:string"/>

</xs:schema>

以便两者都可以在同一个XML文档中使用

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://example.com/common">

  <xs:element name="Common1" type="xs:string"/>

</xs:schema>
根据要求,

没有冲突。