模块化XML模式-我应该怎么做



我对xml和xml模式非常陌生。我想编写一些模块化的代码,但我很难实现这种模块化。

我的问题如下:我想要验证以下xml文件的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命名空间模式:

<?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模式中添加一个进程,该进程从默认模式扩展而来。这也不是我想要的,因为我希望能够从不同的名称空间扩展流程。所以它可能看起来像我前面提到的那个。

我怎样才能做到这一点?

干杯,托马斯

您是否尝试过使用多种可用的模式生成工具之一从该实例自动生成模式?考虑到这种投入的简单性,我认为他们会做得很好。

在XSD中,每个目标命名空间必须至少有一个架构文档。由于您的名称空间中没有一个元素超过两个,因此对于您的目的来说,这似乎是足够模块化的。如果它不够模块化,你需要解释你试图实现的目标。

相关内容

最新更新