我是xml和xml架构的新手。我想做一些非常模块化的代码,我很难实现这种模块化。
我的问题如下:我想要xml-schemas验证以下xml文件:
<process xmlns="http://soa.lotterm.org/spec/test/default"
xmlns:bpmn="http://soa.lotterm.org/spec/test/bpmn" xmlns:bpel="http://soa.lotterm.org/spec/test/bpel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://soa.lotterm.org/spec/test/default http://soa.lotterm.org/spec/test/default.xsd http://soa.lotterm.org/spec/test/bpmn http://soa.lotterm.org/spec/test/bpmn.xsd http://soa.lotterm.org/spec/test/bpel http://soa.lotterm.org/spec/test/bpel.xsd">
<bpmn:processProperties>
<bpmn:uri>http://soa.lotterm.org/repository/stocktrade/stockmarket.bpmn</bpmn:uri>
</bpmn:processProperties>
<bpel:processProperties>
<bpel:uri>http://soa.lotterm.org/repository/stocktrade/stockmarket.bpmn</bpmn:uri>
</bpel:processProperties>
</process>
为什么我要创建这样的XML文件?
我需要一个默认结构,其中有工件(例如流程元素)。这些工件应该能够存储特定于模块的属性(例如,来自我的bpel或bpmn模块)。默认架构当然不知道这些模块,并且模块彼此不知道(只是默认架构)。我的架构将如何支持此xml文件?
我的所有尝试(例如,扩展了抽象属性类型)都无法解决。
编辑:当我尝试生成架构时,它不是我想要的。
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://soa.lotterm.org/spec/test/default" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="process" type="def:processType" xmlns:def="http://soa.lotterm.org/spec/test/default"/>
<xs:complexType name="processType">
<xs:sequence>
<xs:element ref="bpmn:processProperties" xmlns:bpmn="http://soa.lotterm.org/spec/test/bpmn"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
bpmn-namespace模式:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://soa.lotterm.org/spec/test/bpmn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="processProperties" type="bpmn:processPropertiesType" xmlns:bpmn="http://soa.lotterm.org/spec/test/bpmn"/>
<xs:complexType name="processPropertiesType">
<xs:sequence>
<xs:element type="xs:anyURI" name="uri"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
那么现在有什么问题呢?那么默认架构需要知道bpmn命名空间有processProperties。那就是我想要的。现在,您可能会建议向bpmn模式添加一个进程,该进程从默认模式扩展进程。这也不是我想要的,因为我希望能够从不同的命名空间扩展进程。所以它看起来就像我之前提到的那样。
我怎样才能做到这一点?
干杯,托马斯
答案 0 :(得分:0)
您是否尝试过使用众多架构生成工具之一从此实例自动生成架构?鉴于这种输入的简单性,我认为他们会做一个合理的工作。
在XSD中,每个目标命名空间必须至少有一个架构文档。由于您的命名空间中没有任何一个包含两个以上的元素,因此对于您的目的而言,这似乎非常模块化。如果它不够模块化,你需要解释你想要实现的目标。