* @return The rule-set.
*/
public RuleSet read(InputSource in) throws SAXException,
IOException
{
SAXParser localParser = null;
if ( this.parser == null )
{
SAXParserFactory factory = SAXParserFactory.newInstance( );
factory.setNamespaceAware( true );
String isValidatingString = System.getProperty( "drools.schema.validating" );
if ( System.getProperty( "drools.schema.validating" ) != null )
{
this.isValidating = Boolean.getBoolean( "drools.schema.validating" );
}
if ( this.isValidating == true )
{
factory.setValidating( true );
try
{
localParser = factory.newSAXParser( );
}
catch ( ParserConfigurationException e )
{
throw new RuntimeException( e.getMessage( ) );
}
try
{
localParser.setProperty( JAXP_SCHEMA_LANGUAGE,
W3C_XML_SCHEMA );
}
catch ( SAXNotRecognizedException e )
{
boolean hideWarnings = Boolean.getBoolean( "drools.schema.hidewarnings" );
if ( !hideWarnings )
{
System.err.println( "Your SAX parser is not JAXP 1.2 compliant - turning off validation." );
}
localParser = null;
}
}
if ( localParser == null )
{
// not jaxp1.2 compliant so turn off validation
try
{
this.isValidating = false;
factory.setValidating( this.isValidating );
localParser = factory.newSAXParser( );
}
catch ( ParserConfigurationException e )
{
throw new RuntimeException( e.getMessage( ) );
}
}
}
else
{
localParser = this.parser;
}
if ( !localParser.isNamespaceAware( ) )
{
throw new RuntimeException( "parser must be namespace-aware" );
}
if ( this.repo == null )
{
try
{
this.repo = DefaultSemanticsRepository.getInstance( );
}
catch ( Exception e )
{
throw new SAXException( "Unable to reference a Semantics Repository:\n" + e.getMessage() );
}
}
localParser.parse( in,
this );
return this.ruleSet;
}