Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XSD模式抽象类型问题_Xsd - Fatal编程技术网

XSD模式抽象类型问题

XSD模式抽象类型问题,xsd,Xsd,我对xsd模式文件有问题 我的模式中有一个抽象复杂类型: <complexType name="Action" abstract="true"> <sequence> <element name="actionType"> <complexType> <choice> <element name="ALARMAC

我对xsd模式文件有问题

我的模式中有一个抽象复杂类型:

<complexType name="Action" abstract="true">
    <sequence>
        <element name="actionType">
            <complexType>
                <choice>
                    <element name="ALARMACTION"/>
                    <element name="REPORTDATAACTION"/>
                    <element name="ENABLEOBSERVATIONACTION"/>
                    <element name="DISABLEOBSERVATIONACTION"/>
                    <element name="SETOBSERVATIONSCHEDULEACTION"/>
            <element name="VERIFYOVERTIMEACTION"/>
                </choice>
            </complexType>
        </element>
    </sequence>
</complexType>

这是Action抽象元素的具体实现:

<complexType name="AlarmAction">
    <complexContent>
        <extension base="ref:Action">
            <sequence>
                <element name="alarmCode" type="integer"/>
                <element name="report" type="string"/>
            </sequence>
        </extension>
    </complexContent>
</complexType>

此元素引用抽象操作元素:

<complexType name="Conclusion">
    <sequence>
        <element minOccurs="0" name="observationSet" type="ref:ObservationSet"/>
        <element name="action" type="ref:Action"/>
    </sequence>
</complexType>

我在这个xml实例中遇到了一个错误:

            <Conclusion>
                <observationSet>
                    <observationPhenomenum>HIGH_HEARTBEAT</observationPhenomenum>
                </observationSet>
                <action>
                    <actionType>
                        <ENABLEOBSERVATIONACTION></ENABLEOBSERVATIONACTION>
                    </actionType>
                <observationId>1</observationId>
                <observationId>2</observationId>
                </action>
        </Conclusion>

高心跳
1.
2.
netbeans上的错误是:cvc类型。2:对于元素操作,类型定义不能是抽象的。[104]


有人能帮我吗?

我假设模式是有效的;您确实在某个地方有一个全局元素的定义,该元素的局部名称为“结论”,以及一个源自动作的非抽象复杂类型,其中包含重复的observationId元素(例如XYZAction

如果将xsi:type=“XYZAction”作为属性添加到操作元素中,则问题将得到解决。同样,属性值必须与派生自抽象操作的非抽象类型的名称匹配


我给您的建议是,如果有疑问,请使用工具为您想到的场景生成一个示例XML。我正在使用,因为它允许我使用简单的XML模式元素拖放轻松构建任何可以想象的场景。

您可以使用抽象complexType作为元素类型,但是使用此模式编写XML实例文档的用户必须声明元素的类型

对于您的示例,这意味着您必须按照以下方式编写:

<Conclusion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="conclusion.xsd">
  <observationSet>
    <observationPhenomenum>HIGH_HEARTBEAT</observationPhenomenum>
  </observationSet>
  <action xsi:type="AlarmAction">
    <actionType>
      <ENABLEOBSERVATIONACTION></ENABLEOBSERVATIONACTION>
    </actionType>
    <alarmCode>10</alarmCode>
    <report>Whatever</report>
  </action>
</Conclusion>

高心跳

根据wsdl验证请求xml时,必须包括以下属性

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" use this in the root element 

on abstract type element 

<abstractElement name="XYZ" xsi:type="Name of your instance" > </abstractElement>
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“在根元素中使用它
关于抽象类型元素