Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: substitutionGroup across namespaces

From: George Cristian Bina <george@----.-->
To: Mark Proctor <mproctor@--------.--->
Date: 10/25/2004 3:17:00 PM
Hi Mark,

I tried your files and they work without any problems. I saved the first 
schema as rules.xsd, the second as java.xsd and added a schemaLocation 
to the import element, then the following sample:

<?xml version="1.0" encoding="UTF-8"?>
<rule-set xmlns="http://drools.org/rules" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://drools.org/semantics/java java.xsd 
http://drools.org/rules rules.xsd" name="test">
     <rule name="r1">
         <parameter identifier="test">
             <class xmlns="http://drools.org/semantics/java"/>
         </parameter>
         <condition xmlns="http://drools.org/semantics/java"/>
         <consequence xmlns="http://drools.org/semantics/java"/>
     </rule>
</rule-set>

is valid according with Xerces 2.6.2 (from your similar post on the 
xerces-j-dev list I guess you are using Xerces).

Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com


Mark Proctor wrote:
> 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>
> 
> 
> 
> 

From ht@i... Mon Oct 25 10:18:12 2004
Received: from lisa.w3.org ([128.30.52.41])
	by frink.w3.org with esmtp (Exim 4.34)
	id 1CM1vY-0005gQ-M3
	for xmlschema-d


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