W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2004

Re: substitutionGroup across namespaces

From: Mark Proctor <mproctor@codehaus.org>
Date: Mon, 25 Oct 2004 14:10:00 +0200
Message-ID: <417CED18.80106@codehaus.org>
To: George Cristian Bina <george@sync.ro>
CC: xmlschema-dev@w3.org

I currently use:
    private static final String JAXP_SCHEMA_LANGUAGE = 
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    private static final String W3C_XML_SCHEMA       = 
"http://www.w3.org/2001/XMLSchema";
    private static final String SCHEMA_SOURCE        = 
"http://java.sun.com/xml/jaxp/properties/schemaSource";
As detailed in the following IBM article:
http://www-106.ibm.com/developerworks/xml/library/x-tipvalschm/
I do know that our original xsds worked with that property, but that was 
where we imported the java namespace into rules.xsd and used choice.

I'm looking at xerces and see that it has its own properties as well.
http://xml.apache.org/xerces-j/properties.html
However using this property I can no longer specify the xsds as an 
InputStream, how would I specify urls for  files that are in jars, which 
themselves are in the classpath?

Regards

Mark
George Cristian Bina wrote:

> 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 12:10:35 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:11 UTC