2011-02-04 7 views
1

以下のように私はXSDを持っている: XSD /クラス/言語:私はVS 2008のコマンドプロンプトでコマンド以下とXSDツールを実行したときVisual Studio XSDツールエラー?

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema id="Test" 
    targetNamespace="http://tempuri.org/Test.xsd" 
    elementFormDefault="qualified" 
    xmlns="http://tempuri.org/Test.xsd" 
    xmlns:mstns="http://tempuri.org/Test.xsd" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> 
    <xs:complexType name="TestCurrency"> 
     <xs:sequence> 
      <xs:element name="CurrencyRef" minOccurs="1" maxOccurs="1" type="xs:int"/> 
      <xs:element name="CurrentRefSpecified" minOccurs="1" maxOccurs="1" type="xs:int"/> 
     </xs:sequence> 
    </xs:complexType> 

    <xs:element name="Currency" type="TestCurrency"/> 

</xs:schema> 

VB test.xsd

私はコード

の下に取得します
'------------------------------------------------------------------------------ 
' <auto-generated> 
'  This code was generated by a tool. 
'  Runtime Version:2.0.50727.3615 
' 
'  Changes to this file may cause incorrect behavior and will be lost if 
'  the code is regenerated. 
' </auto-generated> 
'------------------------------------------------------------------------------ 

Option Strict Off 
Option Explicit On 

Imports System.Xml.Serialization 

' 
'This source code was auto-generated by xsd, Version=2.0.50727.3038. 
' 

'''<remarks/> 
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038"), _ 
System.SerializableAttribute(), _ 
System.Diagnostics.DebuggerStepThroughAttribute(), _ 
System.ComponentModel.DesignerCategoryAttribute("code"), _ 
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://tempuri.org/Test.xsd"), _ 
System.Xml.Serialization.XmlRootAttribute("Currency", [Namespace]:="http://tempuri.org/Test.xsd", IsNullable:=false)> _ 
Partial Public Class TestCurrency 

    Private currencyRefField As Integer 

    Private currentRefSpecified1Field As Integer 

    '''<remarks/> 
    Public Property CurrencyRef() As Integer 
     Get 
      Return Me.currencyRefField 
     End Get 
     Set 
      Me.currencyRefField = value 
     End Set 
    End Property 

    '''<remarks/> 
    <System.Xml.Serialization.XmlElementAttribute("CurrentRefSpecified")> _ 
    Public Property CurrentRefSpecified1() As Integer 
     Get 
      Return Me.currentRefSpecified1Field 
     End Get 
     Set 
      Me.currentRefSpecified1Field = value 
     End Set 
    End Property 
End Class 

私が指定した要素がCurrentRefSpecifiedである場合。なぜそれが生成されたクラスのCurrentRefSpecified1として表示されていますか? XSDや問題で問題はありますか?

誰でもすぐに回答できますか?

我々は要素名は...クラスファイル内のプロパティがxyzspecified1として設定されている「xyzspecified」と言っていたときに、この添付が自動的に起こっている...

答えて

1

私は確かに知らないが、ここに私の前提です。 XML内の特定のフィールドについて、それらを省略または指定することができる場合、xsd.exeは、潜在的にnillable/missing値が実際に指定されているかどうかを通知するために、対応するフィールド(yourfieldname)Specifiedを生成します。

これは現時点であなたのサンプルのどこにも当てはまりませんが、XSDを変更してCurrentRefのフィールドをnillableにするか、minOccurs=0にする必要があります.xsd.exeツールは、 CurrentRefSpecifiedヘルパーフィールドがあり、これはXSDの既存のフィールドと衝突します。

xsdツールがフィールドCurrentRefSpecifiedCurrentRefSpecified1に "名前変更"して、将来(将来)のクラッシュを避けることができると推測しています。

+0

お返事ありがとうございますmarc_s – Sathish