I'm trying to build en XML Editor supporing XML Schema.
I'v tried to parse XML Schema with some classes comming form Xercess
2.0.0_beta3, but i can't find working example how to do it.
In ...impl.xs.traversers.XSDHandler is main method, this method does'nt
work and it's the only simple example.
The second example is XMLSchemaValidator class, I'v spend 15 hours to
analyse this class and to get my example working but all what I'v got was
the same error message like by XSDHandler.main() method.
I understand, its not a standard way to use Xercess, but i don't want to
build my own XML Schema Parser.
If You halp me and my efforts give some effects, i can port this editor to
Java Xercess projekt as additional tool.
It was:
[Error] :-1:-1:
http://www.w3.org/TR/xml-schema-1#src-resolve?xsd:string&type de
finition
Source is in attachment.
Radek Wisniewski
www.datenknecht.de
package org.apache.xerces.parsers;
import org.apache.xerces.impl.xs.traversers.XSDHandler;
import org.apache.xerces.impl.xs.SubstitutionGroupHandler;
import org.apache.xerces.impl.xs.XSGrammarResolver;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.XSMessageFormatter;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.XMLEntityManager;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.parsers.StandardParserConfiguration;
import org.apache.xerces.util.EntityResolverWrapper;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.DefaultErrorHandler;
public class SchemaParser {
protected XMLErrorReporter fErrorReporter;
protected XMLEntityResolver fEntityResolver;
protected SymbolTable fSymbolTable;
String XMLNS;
String URI_XSI;
String XSI_SCHEMALOCATION;
String XSI_NONAMESPACESCHEMALOCATION;
String XSI_TYPE;
String XSI_NIL;
String URI_SCHEMAFORSCHEMA;
public SchemaGrammar parseSchema(String namespace, String path){
XMLErrorHandler errorHandler = new DefaultErrorHandler();
fSymbolTable = new SymbolTable();
fErrorReporter = new XMLErrorReporter();
XMLEntityManager fEntityResolver = new XMLEntityManager();
StandardParserConfiguration config = new
StandardParserConfiguration(fSymbolTable);
//config.setEntityResolver(fEntityResolver);
//fEntityResolver.reset(config);
config.setErrorHandler(errorHandler);
config.setEntityResolver(fEntityResolver);
config.reset();
//fErrorReporter =
(XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
//fEntityResolver =
(XMLEntityResolver)componentManager.getProperty(ENTITY_MANAGER);
XMLNS = fSymbolTable.addSymbol(SchemaSymbols.O_XMLNS);
URI_XSI = fSymbolTable.addSymbol(SchemaSymbols.URI_XSI);
XSI_SCHEMALOCATION =
fSymbolTable.addSymbol(SchemaSymbols.OXSI_SCHEMALOCATION);
XSI_NONAMESPACESCHEMALOCATION =
fSymbolTable.addSymbol(SchemaSymbols.OXSI_NONAMESPACESCHEMALOCATION);
XSI_TYPE = fSymbolTable.addSymbol(SchemaSymbols.OXSI_TYPE);
XSI_NIL = fSymbolTable.addSymbol(SchemaSymbols.OXSI_NIL);
URI_SCHEMAFORSCHEMA =
fSymbolTable.addSymbol(SchemaSymbols.OURI_SCHEMAFORSCHEMA);
XSGrammarResolver fGrammarResolver = new XSGrammarResolver();
SubstitutionGroupHandler fSubGroupHandler = new
SubstitutionGroupHandler(fGrammarResolver);
XSDHandler fSchemaHandler = new XSDHandler(fGrammarResolver,
fSubGroupHandler);
//me.reset(rep, new EntityResolverWrapper(new
org.apache.xerces.impl.xs.traversers.XSDHandler.DummyResolver()), new SymbolTable());
fSchemaHandler.reset(fErrorReporter, new EntityResolverWrapper(new
org.apache.xerces.impl.xs.traversers.XSDHandler.DummyResolver()), fSymbolTable);
return fSchemaHandler.parseSchema(namespace, path);
}
}
package editor;
import org.apache.xerces.parsers.SchemaParser;
public class Test {
public static void main(String [] args ){
SchemaParser schemaParser = new SchemaParser();
schemaParser.parseSchema(args[0], args[1]);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]