xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Smith, Doug" <Doug.Sm...@fmr.com>
Subject RE: Having trouble validating with Schema's
Date Wed, 04 Oct 2000 17:40:24 GMT
Hello,

I tried validating the files with Eric's changes (after copying grammar.xsd
to my localhost and changing userprof.xml to point to the schema on my host)
and got an error as shown below. I verified I can retrieve the grammer via
http (i.e. schemaLocation = http://localhost/grammar.xsd ) so I don't think
it's a config problem.

I've included my test program below (minus my error handler, which simply
throws the exceptions passed to it).

I'm using Xerces-J 1.2. Do I need to get the latest CVS snapshot for this to
work?

Thanks.

--Doug

org.xml.sax.SAXParseException: General Schema Error: Grammar with uri :
http://www.outblaze.com/ , can not found.
	java.lang.Throwable(java.lang.String)
	java.lang.Exception(java.lang.String)
	org.xml.sax.SAXException(java.lang.String)
	org.xml.sax.SAXParseException(java.lang.String, org.xml.sax.Locator)
	void
org.apache.xerces.framework.XMLParser.reportError(org.xml.sax.Locator,
java.lang.String, int, int, java.lang.Object [], int)
	void
org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(i
nt, int, java.lang.String)
	void
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttribute
s(org.apache.xerces.utils.QName, org.apache.xerces.framework.XMLAttrList)
	void
org.apache.xerces.validators.common.XMLValidator.callStartElement(org.apache
.xerces.utils.QName)
	boolean
org.apache.xerces.framework.XMLDocumentScanner.scanElement(org.apache.xerces
.utils.QName)
	boolean
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(bo
olean)
	boolean
org.apache.xerces.framework.XMLDocumentScanner.parseSome(boolean)
	void
org.apache.xerces.framework.XMLParser.parse(org.xml.sax.InputSource)
	void test.CacheTest.main(java.lang.String [])

public static void main(java.lang.String[] args) 
{
	try
	{
		if( args.length != 2 )
		{
			throw new Exception( "Usage: java Test.CacheTest
<file1> <file2>" );
		}
		
		for( int i = 0; i < 2; i++ )
		{
			//Read input XML from file
			File inputFile = new File( args[i] );

			FileReader fileReader = new FileReader( inputFile );
			BufferedReader in = new BufferedReader( fileReader
);

			StringBuffer iBuf = new StringBuffer();
			String line;

			while ( (line = in.readLine()) != null )
			{
				iBuf.append(line.trim());
				iBuf.append( '\n' );
			}

			

			fileReader.close();
			in.close();

			System.out.println( iBuf.toString() );

			//Parse & validate - well, mostly validate.
			InputSource is = new InputSource( new
ByteArrayInputStream( iBuf.toString().getBytes() ) );
			XMLReader parser = new SAXParser();
			parser.setContentHandler( new DefaultHandler() );

			parser.setFeature(
"http://xml.org/sax/features/validation", true );
			parser.setFeature(
"http://apache.org/xml/features/validation/schema", true );
			parser.setErrorHandler( new TestErrorHandler() );

			parser.parse( is );
		}

		System.out.println( "Both processed successfully" );

	}
	catch( Throwable t )
	{
		t.printStackTrace();
	}
}

> -----Original Message-----
> From: Eric Ye [mailto:ericye@locus.apache.org]
> Sent: Tuesday, October 03, 2000 12:26 PM
> To: general@xml.apache.org
> Cc: yusufg@outblaze.com
> Subject: Re: Having trouble validating with Schema's
> 
> 
> There are some small nits in your .xml and .xsd file that 
> cause the trouble.
> one of the example is in your .xml file, you bind the "xsi" 
> prefix to a out
> of date uri: http://www.w3.org/1999/XMLSchema/instance  , 
> instead, it should
> be : http://www.w3.org/1999/XMLSchema-instance .
> 
> I attached the 2 fixed files with this email. you can do a 
> diff against your
> originals to see the changes.
> _____
> 
> 
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
> 
> ----- Original Message -----
> From: "Yusuf Goolamabbas" <yusufg@outblaze.com>
> To: <general@xml.apache.org>
> Sent: Tuesday, October 03, 2000 12:34 AM
> Subject: Having trouble validating with Schema's
> 
> 
> > Hi, I modified some example code from Elliote Rusty's site 
> to validate
> > using XML-Schema. Attached please find the XML code, Schema 
> file and the
> > Java code. No matter what I play around with namespaces [haven't
> > achieved Zen with them :-(], I get the following error's
> >
> > General Schema Error: Grammar with uri : 
http://www.outblaze.com/ , can
> not found.
>  at line 10, column 2
>  Element type "userprofile" must be declared.
>   at line 10, column 2
>   userprof.xml is well formed.
>
> Any pointers to how to solve this would be appreciated
>
> --
> Yusuf Goolamabbas
> yusufg@outblaze.com
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org

Mime
View raw message