Re: substitutionGroup across namespaces

Hi Mark,

Well, the following schemas plus instance are valid(Xerces 2.6.2). I do 
not know what SCHEMA_SOURCE contains in your code line:

parser.setProperty(SCHEMA_SOURCE,( InputStream[] ) schemaList.toArray( 
new InputStream[0] ) );

You may try setting a value similar with the one from schemaLocation 
attribute to the 
http://apache.org/xml/properties/schema/external-schemaLocation property.

rules.xsd
=========

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

java.xsd
========

<?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" 
schemaLocation="rules.xsd"/>
     <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>

sample.xml
==========

<?xml version="1.0" encoding="UTF-8"?>
<rule-set name="fibonacci" xmlns="http://drools.org/rules"
     xmlns:java="http://drools.org/semantics/java"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://drools.org/semantics/java java.xsd 
http://drools.org/rules rules.xsd">
     <rule name="Recurse" salience="10">
         <parameter identifier="f">
 
<java:class>org.drools.examples.fibonacci.Fibonacci</java:class>
         </parameter>
         <java:condition>f.getValue() == -1</java:condition>
         <java:consequence> System.err.println( "recurse for " + 
f.getSequence() );
             drools.assertObject( new Fibonacci( f.getSequence() - 1 ) 
); </java:consequence>
     </rule>
</rule-set>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Received on Monday, 25 October 2004 11:39:25 UTC