Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: substitutionGroup across namespaces

From: Mark Proctor <mproctor@--------.--->
To: George Cristian Bina <george@----.-->
Date: 10/25/2004 4:35:00 PM
I just tried it doing getResource and toExternalForm which produces the 
following string:
jar:file:/D:/java/workspaces/drools/target/drools-java-2.0-beta-18.jar!/META-INF/java.xsd 
jar:file:/D:/java/workspaces/drools/target/drools-python-2.0-beta-18.jar!/META-INF/python.xsd 
jar:file:/D:/java/workspaces/drools/target/drools-groovy-2.0-beta-18.jar!/META-INF/groovy.xsd 
jar:file:/D:/java/workspaces/drools/target/drools-base-2.0-beta-18.jar!/META-INF/rules.xsd

I do this using the following code:
URL java = cl.getResource( "META-INF/java.xsd" );
URL python = cl.getResource( "META-INF/python.xsd" );
URL groovy = cl.getResource( "META-INF/groovy.xsd" );
URL rules = cl.getResource( "META-INF/rules.xsd" );
String url = "";

if ( java != null ) url = url + java.toExternalForm() + " ";
if ( python != null ) url = url + python.toExternalForm() + " ";
if ( groovy != null ) url = url + groovy.toExternalForm() + " ";
if ( rules != null ) url = url + rules.toExternalForm();

parser.setProperty( JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA );
parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", 
url);

But now I get the following error, like its not finding the xsds at all:
 (jar:file:/D:/java/workspaces/drools/drools-examples/target/drools-examples-2.0-beta-18.jar!/org/drools/examples/fibonacci/fibonacci.java.drl:5,57) 
: cvc-elt.1: Cannot find the declaration of element 'rule-set'.

Mark
Mark Proctor wrote:

> 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
>> www.---.com
>>
>>
>
>


From mproctor@c... Mon Oct 25 12:52:53 2004
Received: from b


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