Hi, there.
I want to use 'Schema caching', so I worte some test code below. I used
'XMLGrammarCachingConfiguration' class.
But it generate exception that I can't understand. What's wrong? And is there
another way using 'schema caching'?
Thank you.
--System------------------------------------------------
OS: RedHat 7.3
JDK: 1.3.1
Xerces: 2.0.1
--exception----------------------------------------------
Exception in thread "main" java.lang.VerifyError: (class:
org/apache/xerces/impl/xs/traversers/XSDHandler, method: getSchema signature:
(Ljava/lang/String;Lorg/apache/xerces/xni/parser/XMLInputSource;ZSLorg/w3c/dom/Element;)Lorg/w3c/dom/Document;)
Incompatible object argument for function call
at
org.apache.xerces.parsers.XMLGrammarCachingConfiguration.parseGrammar(Unknown
Source)
at ParserTest.main(ParserTest.java:58)
--code----------------------------------------------------
import java.lang.System;
import java.util.Properties;
import java.io.*;
import org.apache.xerces.parsers.StandardParserConfiguration;
import org.apache.xerces.parsers.DOMParser;
import org.apache.xerces.parsers.XMLGrammarCachingConfiguration;
import org.apache.xerces.xni.grammars.XMLGrammarDescription;
import org.apache.xerces.xni.parser.XMLInputSource;
public class ParserTest
{
public static void main(String argv[])
{
if (argv.length != 2)
{
System.err.println("usage: java ParserTest XML-FileName
XSD-FileName");
System.err.println();
System.exit(1);
}
String strPath = System.getProperties().getProperty("user.dir") + "/";
XMLInputSource xIs = new XMLInputSource(null, argv[1], strPath);
System.out.println(xIs.getSystemId()); // for test
System.out.println(xIs.getBaseSystemId()); //// for test
try
{
xIs.setByteStream(new FileInputStream(strPath + argv[0]));
}
catch(FileNotFoundException fe)
{
fe.printStackTrace();
}
catch(IOException ie)
{
ie.printStackTrace();
}
try
{
InputStream is = xIs.getByteStream();
byte[] bs = new byte[is.available()];
is.read(bs, 0, is.available());
String strDoc = new String(bs);
System.out.println(strDoc); // for test
}
catch(IOException ie)
{
ie.printStackTrace();
}
XMLGrammarCachingConfiguration parser = null;
parser = new XMLGrammarCachingConfiguration();
try
{
parser.parseGrammar(XMLGrammarDescription.XML_SCHEMA, xIs);
}
catch(org.apache.xerces.xni.XNIException xniE)
{
xniE.printStackTrace();
}
catch(java.io.IOException ioE)
{
ioE.printStackTrace();
}
}
}