0

I am very new to xml and xml schema. I want do code something quite modular and I have difficulties achieving this modularity.

My problem is the following: I want xml-schemas which validate the following xml file:

<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>

Why did I create such a XML-File?

Well I need a default structure, where there are artifacts (e.g. process elements). These artifacts should be able to store module-specific properties (e.g. from my bpel or bpmn module). The default schema of course doesn't know of these modules and the modules don't know of one another (just the default schema). How will my schema look which supports this xml-file?

All of my attempts (e.g. with extension of an abstract property type) don't work out.

Edit: When I try to generate the schema it isn't what I am looking for.

<?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>

And the bpmn-namespace schema:

<?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>

Well now what is the problem with that? Well the default schema needs to know that the bpmn namespace has processProperties. That's now what I want. Now you will probably suggest to add a process to the bpmn schema which extends the process from the default schema. That's also not what I want because I want to be able to extend the process from different namespaces. So it could look like the one I mentioned earlier.

How can I achieve this?

Cheers, Thomas

4

1 回答 1

0

您是否尝试过使用众多可用的模式生成工具之一从此实例自动生成模式?鉴于此输入的简单性,我认为他们会做得很合理。

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

于 2012-07-20T14:44:23.550 回答