带有元素和属性的XSD扩展
我需要创建一个XSD来验证以下类型的XML:带有元素和属性的XSD扩展,xsd,complextype,Xsd,Complextype,我需要创建一个XSD来验证以下类型的XML: <dbengine stylesheet="file:transformation.xslt"> <queries> <query name="update" inputtype="file">file:/src/test.sql</query> <query name="update" inputtype="sql">select * from test<
<dbengine stylesheet="file:transformation.xslt">
<queries>
<query name="update" inputtype="file">file:/src/test.sql</query>
<query name="update" inputtype="sql">select * from test</query>
</queries>
</dbengine>
这可以通过制定以下模式来实现:
<xsd:element name="dbengine">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="queries" type="queries" minOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="stylesheet" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
此外,我需要这个标签,以便通过扩展inputOutputEndpointType从接收和发送来自/到通道的消息。所以理想情况下,我应该有这样的东西:
<xsd:element name="dbengine">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="int:inputOutputEndpointType" >
<xsd:sequence>
<xsd:element name="queries" type="queries" minOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="stylesheet" type="xsd:string" use="optional"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
但是,这会导致eclipse编辑器中出现错误:
cos ct扩展了.1.4.3.2.2.1.a:派生类型的内容类型和
它的基础必须是混合的,或者两者都是元素。类型
“AnonType_dbengine3”仅是元素,但其基类型不是
添加mixed=true属性没有帮助,到目前为止,解决此问题的每一次尝试都失败了 我在XMLSchema编辑器中尝试了您的模式,但您的代码片段没有出现任何错误,我必须将其放在xsd:schema中,并为查询复杂类型添加一个虚拟定义 我认为您只是遇到了Eclipse编辑器的问题。活生生的证据在同一个文件中,请查看innerEndpointDefinitionAware complexType 使用Eclipse应该尝试的一件事是在同一个文件夹中实际下载spring-integration-1.0.xsd、spring-beans-2.0.xsd和sprint-tool-2.0.xsd。编辑集成文件以确保对于xsd:imports,您可以手动将schemaLocation添加到已下载的文件中。再试一次,看看会发生什么。如果可行,那么这个问题与几乎所有使用xsd:import而不使用schemaLocation的Spring模式所使用的悬空方法有关。对于悬空定义,由Eclipse提供的模式处理器来解析这些名称空间
在我将编辑器配置为将悬而未决的定义解析到适当版本的bean和工具之后,我的编辑器甚至可以在不下载的情况下工作——也许Eclipse支持相同的版本?我找不到实现它的方法,这里是我的解决方法。我刚刚创建了一个新的complexType来替代spring inputOutputEndpointType
<xsd:complexType name="workaround">
<xsd:attribute name="output-channel" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.core.MessageChannel" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="input-channel" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.core.MessageChannel" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:string">
</xsd:attribute>
<xsd:attribute name="auto-startup" type="xsd:string" />
</xsd:complexType>
在dbengine标记中,我扩展了这个complexType:
<xsd:extension base="workaround" >