简体   繁体   English

xml模式和vb.net

[英]xml schema and vb.net

I have a xml schema file that was supplied by a vendor. 我有一个由供应商提供的xml模式文件。 At the root, the file has three main elements: Customer, ShipDate, and Items. 在根目录下,文件具有三个主要元素:客户,发货日期和项目。 Once I have added the XSD file to my project, I am not able to access the ShipDate attribute. 将XSD文件添加到项目后,将无法访问ShipDate属性。 I am not sure how to handle this. 我不确定如何处理。 I tried creating a new element for the ShipDate similar to the other elements, but I don't think I did it correctly, so I put everything back like it was. 我尝试为ShipDate创建一个与其他元素类似的新元素,但是我认为我做得不正确,因此我将所有内容恢复原样。 Take a look at the XSD file below, and let me know what I am doing wrong. 看看下面的XSD文件,让我知道我在做什么错。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema id="PricingRequest" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:annotation>
    <xs:documentation>
      Request Prices Schema for Power Net
      Copyright 2009 Retalix. All rights reserved.
    </xs:documentation>
  </xs:annotation>

  <xs:element name="PricingRequest" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="1" minOccurs="1" ref="Customer"/>
        <xs:element maxOccurs="1" minOccurs="1" name="ShipDate" type="xs:date"/>
        <xs:element maxOccurs="1" minOccurs="1" ref="Items"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Customer" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Company" type="companyType"/>
        <xs:element name="Division" type="companyType"/>
        <xs:element name="Department" type="companyType"/>
        <xs:element name="Number" type="customerType"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Items" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" minOccurs="1" ref="Item"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Item" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:attribute name="number" type="itemNumberType" use="required"/>
    </xs:complexType>
  </xs:element>

  <!-- Power Net Specific data types -->
  <xs:simpleType name="companyType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z0-9\s]{3}"/>
      <xs:whiteSpace value="preserve"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="customerType">
    <xs:restriction base="xs:string">
      <xs:pattern value="([A-Z0-9\-])*"/>
      <xs:minLength value="1"/>
      <xs:maxLength value="10"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="itemNumberType">
    <xs:restriction base="xs:string">
      <xs:pattern value="([A-Z0-9\-])*"/>
      <xs:minLength value="1"/>
      <xs:maxLength value="10"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

I would suspect that the data type xs:date is not supported when the element is specified to be a DataSet - you can only use xs:dateTime there. 我怀疑当元素被指定为DataSet时不支持数据类型xs:date date-您只能在那里使用xs:dateTime。

If you do not intend to use the schema as a DataSet you can remove the according attribute msdata:IsDataSet="true" (and the whole namespace msdata altogether). 如果您不想将架构用作数据集,则可以删除相应的属性msdata:IsDataSet="true" (以及整个命名空间msdata)。

If you want the schema to stay a DataSet replace the data type of ShipDate with xs:dateTime. 如果要让架构保留数据集,请使用xs:dateTime替换ShipDate的数据类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM