Java 保存时删除XML架构节
我是第一次创建XML模式。我正在与eclipse一起为一个项目验证XML。在修复eclipse上的问题时,ellipse将自动删除我的项目中的一大块内容。我已经为此工作了数小时,但无法解决此问题,这是我的原创作品:Java 保存时删除XML架构节,java,xml,eclipse,xsd,Java,Xml,Eclipse,Xsd,我是第一次创建XML模式。我正在与eclipse一起为一个项目验证XML。在修复eclipse上的问题时,ellipse将自动删除我的项目中的一大块内容。我已经为此工作了数小时,但无法解决此问题,这是我的原创作品: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sample="http://www.example" ta
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sample="http://www.example"
targetNamespace="http://www.example.com"
elementFormDefault="qualified">
<!-- define nodeName -->
<xsd:element name="nodeName" >
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="struct">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="attribute" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="field" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="interface">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="attribute" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="channel" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="direction" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="component">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="attribute" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="field" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="value" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="constructor">
</xsd:element>
<xsd:element name="behaviour">
<xsd:complexType>
<xsd:sequence>
<xsd:element name=send minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="identifier" type="xsd:string" />
<xsd:attribute name="on" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name=receive minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="identifier" type="xsd:string" />
<xsd:attribute name="from" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name=variable minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="allocation" type="xsd:string" />
<xsd:attribute name="bindingTo" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name=print minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="variable" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="instance">
<xsd:complexType>
<xsd:attribute name="component" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="connect">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from minOccurs=" 1 maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="on" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="on minOccurs=" 1 maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="on" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="interNodeConnect">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from minOccurs=" 1 maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="on" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="on minOccurs=" 1 maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="on" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="direction" type="xsd:string" />
<xsd:attribute name="otherNode" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd.schema>
简单地说,每一部分都在解释某种形式的无线传感器网络。我需要使用这些类型中的一种来验证我的系统,但是,当我尝试保存此文件时,接口后的所有内容都将被删除。您的架构中有几个语法错误。我能够通过NetBeans的Validate XML功能识别它们,也许eclipse也有类似的功能: 根元素的结束标记应为而不是 多个属性值不包含在s中,例如,在组件/行为中: 必须被替换为
<xsd:element name="send" minOccurs="0" maxOccurs="unbounded">
<xsd:element name="from" minOccurs="1" maxOccurs="1">
当然,修复功能可以修复一些错误,但不能修复所有错误
PS:Tipp:你有几个匿名复杂类型,看起来都一样。您也可以为复杂类型命名。您还可以扩展它们。请看,这将是减少您必须编写的代码量的一个好方法 您使用哪个编辑器编辑此内容?您需要修改此文件吗?
<xsd:element name="from minOccurs=" 1 maxOccurs="1">
<xsd:element name="from" minOccurs="1" maxOccurs="1">