現在、InをUnityに使用するために、Javaライブラリの一部をC#ライブラリに翻訳しようとしています。このJavaライブラリでは、いくつかのクラスはXMLファイルから生成されます。そのXMLファイルは.xmlファイルですが、これはJavaやC#のようなものではありません。C#コードを生成するためのXML構文
私はいくつかの調査を行っていますが、この.xmlファイルを.csクラスに変換するさまざまな方法がありますが、.xmlに含める構文に関するドキュメントは見つかりません。
私はツールXsd.exeではを使用しようと、私は1つのXMLファイルからファイルを作成し、XSDするために管理が、私は.csファイルを生成しようとしたときには、私はこのエラーをproptedたファイル:Error: Can only generate one of classes or datasets.
私は、いくつかを作りました研究と別のツール、Xsd2Codeを見つけたので、私はする.csファイルを取得するために同じ.xmlファイルとそれを使用しようとしましたが、それは構造文句エラーを促さ:
C:\Program Files (x86)\Xsd2Code>Xsd2Code.exe Vehicle.xml Vehicle.cs
Xsd2Code Version 3.4.0.32990
Code generation utility from XML schema files.
Error: Declaración XML inesperada. La declaración XML debe ser el primer nodo del documento y no pueden aparecer espacios en blanco delante. Línea 2, posición 3.
SubType: Unspecified
Rule:
私はそれを翻訳し、それ以来、スペイン語です: エラー:予期しないXML宣言。 XML宣言は最初のノードでなければならず、前に空白を入れてはいけません。 2行目、3位
これは、特定のファイルの最初の行です:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty" targetNamespace="http://www.w3.org/2001/XMLSchema" blockDefault="#all" elementFormDefault="qualified" version="1.0" xml:lang="EN">
<?xml version="1.0" encoding="UTF-8"?>
<traciClass>
<name>Vehicle</name>
EDIT:最初のコメントが言うように、私はそれを修正し、今私は
Error: Schema validation failed:
El elemento 'traciClass' no es compatible en este contexto.
SubType: Unspecified
Rule:
The element traciClass is not compatible in this context.
を受け取ります
オリジナルポスト続行:
これは、XML for Javaでさまざまなオブジェクトを定義する方法のテンプレートですが、C#でこの構造が異なるかどうかは疑問です。
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file is used to generate a Java class with the same name for a
TraCI object. This saves manually writing a lot of boilerplate code. -->
<traciClass>
<!-- The name of the object. It will be used as the class name. First letter
is capital. Must be equal to this document's file name. -->
<name>ExampleTraciObject</name>
<!-- The javadoc of the class that will be generated. -->
<javadoc>
Put your object description here.
</javadoc>
<!-- Lists all the other repositories that are needed by the queries -->
<repos>
<repo>Repository1</repo>
<repo>Repository2</repo>
</repos>
<command>it.polito.appeal.traci.protocol.Constants.CMD_GET_VEHICLE_VARIABLE</command>
<!-- List of all "read" queries, i.e. those that don't change the state
of the object and return a value -->
<readQueries>
<readQuery>
<!-- The name of the query. If the name is XXX, the Java class will contain
a method named queryXXX() -->
<name>ReadSomeValueQuery</name>
<!-- The enum name of the query. It will appear as an enum entry
in the inner Variable enum, and can be used with the getReadQuery() method -->
<enum>SOME_VALUE</enum>
<!-- A numeric value or a constant of type int that tells the variable
ID -->
<const>it.polito.appeal.traci.protocol.Constants.SOME_VARIABLE</const>
<!-- The Java class name that can make the query. It must be a subclass
of ReadObjectVarQuery. If the class is on the package
it.polito.appeal.traci, the package name can be omitted-->
<query>ReadObjectVarQuery.IntegerQ</query>
<!-- The return type of the query. It must be the same type (or a supertype)
of the type parameter V specified in the above class.
Leave it empty to use the query class as the return type. -->
<returnType>java.lang.Integer</returnType>
<!-- If true, it means that this value may change at every simulation
step. -->
<dynamic>true</dynamic>
</readQuery>
<!-- add other read queries here -->
</readQueries>
<!-- List of all "change state" queries, i.e. those that change the state
of the object and don't return a value -->
<changeStateQueries>
<!-- The syntax of a changeStateQuery is similar to readQuery, differences
are listed below. -->
<changeStateQuery>
<name>DoSomething</name>
<query>DoSomethingQuery</query>
<!-- Lists the read queries that may be changed by the execution of this
query, identified by their name. Calling this query will clear the caches
of the queries contained here. -->
<affects>
<affect>ReadSomeValueQuery</affect>
</affects>
</changeStateQuery>
<!-- add other change state queries here -->
</changeStateQueries>
</traciClass>
XML構文の問題ですか?
'<?xml version =" 1.0 "encoding =" UTF-8 "?>'はファイルの最初の行でなければなりません。それはまさに "XML宣言が最初のノードでなければならず、空白を含んではいけません。"あなたに伝えようとします: – Fildor
私は自分の投稿を編集します。私はそれを変更し、今では "traciClassはこの文脈では互換性がありません"と言います。 – Biurrun
あなたはC#コードジェネレータが期待しているフォーマットに変換しなければならないでしょう。たとえば、 "javadoc"は、C#では役に立たないタグの明白なケースですが、おそらくちょうど名前を変更する必要があります。 – Fildor