我已经上传了一个 ZIP 文件,其中包含我正在尝试读取的 XML 文件和相应的 XSD 文件到http://www.bonnland.de/FIBEX.zip
我正在尝试使用 XmlSerializer 反序列化以下 XML(片段)。这样做时我得到了错误:(对不起,它是德语,我会用斜体给出粗略的翻译)
System.InvalidOperationException==>Fehler im XML-Dokument (90,7)。 System.InvalidOperationException==>Der angegebene Typ wurde nicht erkannt: Name='CONTROLLER-TYPE', Namespace='http://www.asam.net/xml/fbx/can', bei。
这可以翻译为:
System.InvalidOperationException==>XML 文档中的错误 (90,7)。 System.InvalidOperationException==>找不到给定类型:Name='CONTROLLER-TYPE', Namespace='http://www.asam.net/xml/fbx/can', at
这是源文件:
<fx:ECU ID="ecuSpeedControl">
<ho:SHORT-NAME>SpeedControl</ho:SHORT-NAME>
<ho:DESC>ECU controlling drive speed</ho:DESC>
<fx:CONTROLLERS>
<fx:CONTROLLER xsi:type="can:CONTROLLER-TYPE" ID="ctrlSpeedControl">
<ho:SHORT-NAME>ctrlSpeedControl</ho:SHORT-NAME>
<ho:DESC>CAN controller of ECU</ho:DESC>
<fx:CHIP-NAME>SJA1000</fx:CHIP-NAME>
<can:TIME-SEG0>11</can:TIME-SEG0>
<can:TIME-SEG1>4</can:TIME-SEG1>
<can:SYNC-JUMP-WIDTH>2</can:SYNC-JUMP-WIDTH>
<can:NUMBER-OF-SAMPLES>1</can:NUMBER-OF-SAMPLES>
</fx:CONTROLLER>
</fx:CONTROLLERS>
</fx:ECU>
根元素是:
<fx:FIBEX xmlns:fx="http://www.asam.net/xml/fbx" xmlns:ho="http://www.asam.net/xml"
xmlns:can="http://www.asam.net/xml/fbx/can" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="fibex4can.xsd" VERSION="3.1.0">
这个片段的类定义是:
public ref class FIBEXECU : AbstractFIBEXNode, IGenericContainable
{
public:
ref class ControllersContainer : FIBEXGenericContainer<FIBEXController^>{
public:
[XmlElement("CONTROLLER")]
property array<FIBEXController^>^ ControllerObjs {
array<FIBEXController^>^ get() { return Children;}
void set(array<FIBEXController^>^ value) { Children = value;}
}
};
[XmlAttribute("ID")]
virtual property String^ ID;
[XmlElement("SHORT-NAME", Namespace="http://www.asam.net/xml")]
property String^ ShortName;
[XmlElement("CONTROLLERS")]
property ControllersContainer^ Controllers;
};
我希望(再次)有人可以帮助我,因为我没有在谷歌或这里找到解决方案。