You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by 최원석 <ei...@shventure.seoul.kr> on 2002/03/20 07:57:44 UTC

Help!!! How to use 'XMLGrammarCachingConfiguration'?

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();
        }
    }
}

Re: Help!!! How to use 'XMLGrammarCachingConfiguration'?

Posted by Xuemin Guan <xu...@appresso.com>.
I think 'Schema caching' is not supported yet, thought the code is there.
----- Original Message -----
送信者 : "최원석" <ei...@shventure.seoul.kr>
宛先 : <xe...@xml.apache.org>
送信日時 : 2002年3月20日 15:57
件名 : Help!!! How to use 'XMLGrammarCachingConfiguration'?


> 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/d
om/Element;)Lorg/w3c/dom/Document;) Incompatible object argument for
function call
> at
org.apache.xerces.parsers.XMLGrammarCachingConfiguration.parseGrammar(Unknow
n 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();
>         }
>     }
> }


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org