找不到元素声明 'xtce:SpaceSystem'

Cannot Find The Declaration Of Element 'xtce:SpaceSystem'

我创建了以下基于 XTCE 标准的 XML 文件。但是,当我尝试验证它时,我看到一条错误消息,

Cannot Find The Declaration Of Element 'xtce:SpaceSystem'., Line '3', Column '81'

我不明白为什么,因为 SpaceSystem 元素作为根元素是 XSD 模式文件和 XTCE 文档的一部分。元素的头部或link到XSD方案是否有问题?以及如何更新文件以使其有效?

<?xml version="1.0" encoding="UTF-8"?>
<xtce:SpaceSystem xmlns:xtce="http://www.omg.org/space/xtce"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="XTCE_V12_UT"
    xsi:schemaLocation="https://www.omg.org/spec/XTCE/20180204/SpaceSystem.xsd">
  <xtce:CommandMetaData>
    <ParameterTypeSet>
      <xtce:IntegerParameterType name="1ByteInteger" sizeInBits="8" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="14BitInteger" sizeInBits="14" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="11BitInteger" sizeInBits="11" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="10BitInteger" sizeInBits="10" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="6BitInteger" sizeInBits="6" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="5BitInteger" sizeInBits="5" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="4BitInteger" sizeInBits="4" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="3BitInteger" sizeInBits="3" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="2BitInteger" sizeInBits="2" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
      <xtce:IntegerParameterType name="1BitInteger" sizeInBits="1" signed="false">
        <xtce:UnitSet />
      </xtce:IntegerParameterType>
    </ParameterTypeSet>
    <xtce:ParameterSet>
      <xtce:Parameter parameterTypeRef="2BitInteger" name="CSP_PR" />
      <xtce:Parameter parameterTypeRef="5BitInteger" name="CSP_SRC" />
      <xtce:Parameter parameterTypeRef="5BitInteger" name="CSP_DEST" />
      <xtce:Parameter parameterTypeRef="6BitInteger" name="CSP_SRC_P" />
      <xtce:Parameter parameterTypeRef="6BitInteger" name="CSP_DEST_P" />
      <xtce:Parameter parameterTypeRef="4BitInteger" name="CSP_RES" />
      <xtce:Parameter parameterTypeRef="1BitInteger" name="CSP_HMAC" />
      <xtce:Parameter parameterTypeRef="1BitInteger" name="CSP_XTEA" />
      <xtce:Parameter parameterTypeRef="1BitInteger" name="CSP_RDP" />
      <xtce:Parametera parameterTypeRef="1BitInteger" name="CSP_CRC" />
    </xtce:ParameterSet>
    <xtce:ArgumentTypeSet>
      <xtce:EnumeratedArgumentType name="TimerStartStopType" sizeInBits="32">
        <xtce:UnitSet />
        <xtce:EnumerationList>
          <xtce:Enumeration label="TIMER_STOP" value="0" />
          <xtce:Enumeration label="TIMER_START" value="1" />
        </xtce:EnumerationList>
      </xtce:EnumeratedArgumentType>
    </xtce:ArgumentTypeSet>
    <xtce:CommandContainerSet>
      <xtce:CommandContainer name="CSPPacket" shortDescription="CSP Packet">
        <xtce:EntryList>
          <xtce:ContainerRefEntry containerRef="CSPPacketHeader" />
        </xtce:EntryList>
      </xtce:CommandContainer>
      <xtce:CommandContainer name="CSPPacketHeader" shortDescription="CCSDS TC Frame Header" abstract="true">
        <xtce:EntryList>
          <xtce:ParameterRefEntry parameterRef="CSP_PR" />
          <xtce:ParameterRefEntry parameterRef="CSP_SRC" />
          <xtce:ParameterRefEntry parameterRef="CSP_DEST" />
          <xtce:ParameterRefEntry parameterRef="CSP_SRC_P" />
          <xtce:ParameterRefEntry parameterRef="CSP_DEST_P" />
          <xtce:ParameterRefEntry parameterRef="CSP_RES" />
          <xtce:ParameterRefEntry parameterRef="CSP_XTEA" />
          <xtce:ParameterRefEntry parameterRef="CSP_RDP" />
          <xtce:ParameterRefEntry parameterRef="CSP_CRC" />
        </xtce:EntryList>
      </xtce:CommandContainer>
    </xtce:CommandContainerSet>
    <xtce:MetaCommandSet>
      <xtce:MetaCommand name="TimerStartStopCommand" shortDescription="Timer Start Stop Command">
        <xtce:ArgumentList>
          <xtce:Argument argumentTypeRef="TimerStartStopType" name="TimerStartStop" />
        </xtce:ArgumentList>
        <xtce:CommandContainer name="TimerStartStopCommand" shortDescription="Command TimerStartStopCommand Packet">
          <xtce:EntryList>
            <xtce:ArgumentRefEntry argumentRef="TimerStartStopType">
              <xtce:LocationInContainerInBits referenceLocation="containerStart">
                <xtce:FixedValue>0</xtce:FixedValue>
              </xtce:LocationInContainerInBits>
            </xtce:ArgumentRefEntry>
          </xtce:EntryList>
        </xtce:CommandContainer>
        <xtce:DefaultSignificance consequenceLevel="none" />
        <xtce:VerifierSet />
      </xtce:MetaCommand>
    </xtce:MetaCommandSet>
  </xtce:CommandMetaData>
</xtce:SpaceSystem>

两个问题1 正在阻止 XML 与 XSD 相关联:

  1. xsi:schemaLocation 的值应该是 space-separated 对 XML 命名空间及其关联的 XSD URI,

  2. 您的 XML 根元素的命名空间必须与管理 XSD.

    的目标命名空间相匹配

所以改变

xsi:schemaLocation="https://www.omg.org/spec/XTCE/20180204/SpaceSystem.xsd">

xsi:schemaLocation="http://www.omg.org/spec/XTCE/20180204
                    https://www.omg.org/spec/XTCE/20180204/SpaceSystem.xsd">

提示验证器在 https://www.omg.org/spec/XTCE/20180204/SpaceSystem.xsd 中查找 http://www.omg.org/spec/XTCE/20180204 命名空间中的组件。

并改变

xmlns:xtce="http://www.omg.org/space/xtce"

xmlns:xtce="http://www.omg.org/spec/XTCE/20180204"

将根元素放置在管理 XSD 的目标命名空间中。

另见

  • How to link XML to XSD using schemaLocation or noNamespaceSchemaLocation?

1 信用:第二个问题是第一个 – 支持他的回答!

正如@kjhughes 正确指出的那样,命名空间处理不正确。

我调整了你的 XML 命名空间声明。

它仍然有一些错误。但现在您可以轻松修复它们。

XML

<?xml version="1.0" encoding="UTF-8"?>
<xtce:SpaceSystem xmlns:xtce="http://www.omg.org/spec/XTCE/20180204"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  name="XTCE_V12_UT"
                  xsi:schemaLocation="http://www.omg.org/spec/XTCE/20180204 https://www.omg.org/spec/XTCE/20180204/SpaceSystem.xsd">
    <xtce:CommandMetaData>
        <xtce:ParameterTypeSet>
            <xtce:IntegerParameterType name="1ByteInteger" sizeInBits="8"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="14BitInteger" sizeInBits="14"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="11BitInteger" sizeInBits="11"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="10BitInteger" sizeInBits="10"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="6BitInteger" sizeInBits="6"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="5BitInteger" sizeInBits="5"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="4BitInteger" sizeInBits="4"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="3BitInteger" sizeInBits="3"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="2BitInteger" sizeInBits="2"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
            <xtce:IntegerParameterType name="1BitInteger" sizeInBits="1"
                                       signed="false">
                <xtce:UnitSet/>
            </xtce:IntegerParameterType>
        </xtce:ParameterTypeSet>
        <xtce:ParameterSet>
            <xtce:Parameter parameterTypeRef="2BitInteger" name="CSP_PR"/>
            <xtce:Parameter parameterTypeRef="5BitInteger" name="CSP_SRC"/>
            <xtce:Parameter parameterTypeRef="5BitInteger" name="CSP_DEST"/>
            <xtce:Parameter parameterTypeRef="6BitInteger" name="CSP_SRC_P"/>
            <xtce:Parameter parameterTypeRef="6BitInteger" name="CSP_DEST_P"/>
            <xtce:Parameter parameterTypeRef="4BitInteger" name="CSP_RES"/>
            <xtce:Parameter parameterTypeRef="1BitInteger" name="CSP_HMAC"/>
            <xtce:Parameter parameterTypeRef="1BitInteger" name="CSP_XTEA"/>
            <xtce:Parameter parameterTypeRef="1BitInteger" name="CSP_RDP"/>
            <xtce:Parameter parameterTypeRef="1BitInteger" name="CSP_CRC"/>
        </xtce:ParameterSet>
        <xtce:ArgumentTypeSet>
            <xtce:EnumeratedArgumentType name="TimerStartStopType"
                                         sizeInBits="32">
                <xtce:UnitSet/>
                <xtce:EnumerationList>
                    <xtce:Enumeration label="TIMER_STOP" value="0"/>
                    <xtce:Enumeration label="TIMER_START" value="1"/>
                </xtce:EnumerationList>
            </xtce:EnumeratedArgumentType>
        </xtce:ArgumentTypeSet>
        <xtce:CommandContainerSet>
            <xtce:CommandContainer name="CSPPacket"
                                   shortDescription="CSP Packet">
                <xtce:EntryList>
                    <xtce:ContainerRefEntry containerRef="CSPPacketHeader"/>
                </xtce:EntryList>
            </xtce:CommandContainer>
            <xtce:CommandContainer name="CSPPacketHeader"
                                   shortDescription="CCSDS TC Frame Header"
                                   abstract="true">
                <xtce:EntryList>
                    <xtce:ParameterRefEntry parameterRef="CSP_PR"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_SRC"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_DEST"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_SRC_P"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_DEST_P"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_RES"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_XTEA"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_RDP"/>
                    <xtce:ParameterRefEntry parameterRef="CSP_CRC"/>
                </xtce:EntryList>
            </xtce:CommandContainer>
        </xtce:CommandContainerSet>
        <xtce:MetaCommandSet>
            <xtce:MetaCommand name="TimerStartStopCommand"
                              shortDescription="Timer Start Stop Command">
                <xtce:ArgumentList>
                    <xtce:Argument argumentTypeRef="TimerStartStopType"
                                   name="TimerStartStop"/>
                </xtce:ArgumentList>
                <xtce:CommandContainer name="TimerStartStopCommand"
                                       shortDescription="Command TimerStartStopCommand Packet">
                    <xtce:EntryList>
                        <xtce:ArgumentRefEntry argumentRef="TimerStartStopType">
                            <xtce:LocationInContainerInBits referenceLocation="containerStart">
                                <xtce:FixedValue>0</xtce:FixedValue>
                            </xtce:LocationInContainerInBits>
                        </xtce:ArgumentRefEntry>
                    </xtce:EntryList>
                </xtce:CommandContainer>
                <xtce:DefaultSignificance consequenceLevel="none"/>
                <xtce:VerifierSet/>
            </xtce:MetaCommand>
        </xtce:MetaCommandSet>
    </xtce:CommandMetaData>
</xtce:SpaceSystem>