Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


substitutionGroup across namespaces

From: Mark Proctor <mproctor@--------.--->
To: xmlschema-dev@--.---
Date: 10/25/2004 12:44:00 PM
In the http://drools.org project we have a base name space:
http://drools.org/rules
And three semantic namespaces:
http://drools.org/semantic/java
http://drools.org/semantic/groovy
http://drools.org/semantic/python

Each namespace xsd is in its own file.

A rule is made up of classes, conditions, consequences and at the moment 
in the rule.xsd we use the choice feature to allow a user to specify 
which one they want:
       <xs:choice>
         <xs:element ref="java:consequence"/>
         <xs:element ref="groovy:consequence"/>
         <xs:element ref="python:consequence"/>
       </xs:choice>
However this has the side affect of coupling the rule.xsd to the 
semantic xsds, and as a user only has the semantic xsds in the classpath 
that they wish to use they receive errors about the other namespaces, 
plus it makes it difficult for users wishing to add more semantic 
implementations as they need to alter rules.xsd.

To try and remove this coupling we wanted to use some sort of abstract 
class in rules.xsd to specify a type, which the semantics would then 
extend. It seems the only way to do this is with substitutionalGroup, 
however it refuses to work when the elements are in different files and 
namespaces.

I have included some sample code, any help would be greatly appreciated.

Regards

Mark

-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
          targetNamespace="http://drools.org/rules"
          elementFormDefault="qualified"
          xmlns:rules="http://drools.org/rules">

 <xs:element name="rule-set">
   <xs:complexType>
     <xs:sequence>
       <xs:element minOccurs="0" maxOccurs="unbounded" ref="rules:rule"/>
     </xs:sequence>
     <xs:attribute name="name" use="required" type="xs:string"/>
     <xs:attribute name="description" type="xs:string"/>
   </xs:complexType>
 </xs:element>

 <xs:element name="rule">
   <xs:complexType>
     <xs:sequence>

       <xs:element name="parameter" maxOccurs="unbounded" >
         <xs:complexType>
           <xs:sequence>
             <xs:element ref="rules:class"/>
           </xs:sequence>
           <xs:attribute name="identifier" use="required" 
type="xs:string"/>
         </xs:complexType>
       </xs:element>

       <xs:element ref="rules:condition" maxOccurs="unbounded" />

       <xs:element ref="rules:consequence"/>

     </xs:sequence>
     <xs:attribute name="name" use="required" type="xs:string"/>
     <xs:attribute name="salience" type="xs:integer"/>
     <xs:attribute name="no-loop" type="xs:boolean"/>
     <xs:attribute name="description" type="xs:string"/>
   </xs:complexType>
   </xs:element>

 <xs:element name="class"       type="xs:string" abstract="true"/>
 <xs:element name="condition"   type="xs:string" abstract="true"/>
 <xs:element name="consequence" type="xs:string" abstract="true"/>

</xs:schema>
-------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 targetNamespace="http://drools.org/semantics/java"
 elementFormDefault="qualified"
 xmlns:java="http://drools.org/semantics/java"
 xmlns:rules="http://drools.org/rules">

 <xs:import namespace="http://drools.org/rules"/>

 <xs:element name="class"       type="xs:string" 
substitutionGroup="rules:class"/>
 <xs:element name="condition"   type="xs:string" 
substitutionGroup="rules:condition"/>
 <xs:element name="consequence" type="xs:string" 
substitutionGroup="rules:consequence"/>

</xs:schema>






transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent