简体   繁体   中英

xml schema and vb.net

I have a xml schema file that was supplied by a vendor. 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. 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. Take a look at the XSD file below, and let me know what I am doing wrong.

<?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.

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).

If you want the schema to stay a DataSet replace the data type of ShipDate with xs:dateTime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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