Sorry, I 'snipped' a line accidentally (the 
'external-noNamespaceSchemaLocation' property setting line)...The code 
below is correct as I have it now--with the same error...:

> -----Original Message-----
> From: John.J.Roets [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 07, 2002 1:39 PM
> To: xerces-j-user
> Subject: RE: Re: AW: Not an FAQ: still unable to validate against XSD
> 
> 
> I'm having a bit of the same, yet _not_ resolved...even when I added 
> the setFeature() methods as within your email.
> Am I possibly using the wrong base class?
> 
> I'm using:
> Xerces 2.2.0
> Java2 SDK 1.3.1
> 
> I keep getting the Exception: java.lang.ExceptionInInitializerError
> Code and output follows...
> 
> Here's my code:
> 
> import org.xml.sax.*;
> import org.xml.sax.helpers.*;
> ...
> import javax.xml.parsers.*;
> import org.apache.xerces.jaxp.*;
> 
> public abstract class TypeHandler extends DefaultHandler
> {
> ...
>     private static final String FLAG_VALIDATE = 
> "http://xml.org/sax/features/validation";;
>     private static final String FLAG_SCHEMA = 
> "http://apache.org/xml/features/validation/schema";;
>     
>     static final String JAXP_SCHEMA_LANGUAGE = 
> "http://java.sun.com/xml/jaxp/properties/schemaLanguage";;
>     static final String W3C_XML_SCHEMA = 
> "http://www.w3.org/2001/XMLSchema";;
>     protected static String schemaSource;
>     static final String JAXP_SCHEMA_SOURCE = 
> "http://java.sun.com/xml/jaxp/properties/schemaSource";;
> 
> 
>     public void parse( String filename ) throws java.io.IOException, 
> org.xml.sax.SAXException, org.xml.sax.SAXParseException
>     {
>         try
>         {
>             log.debug( "file:" + filename );
>             InputStream in = new BufferedInputStream(new 
> FileInputStream( filename ));
>             InputSource source = new InputSource( in );
>             
>             SAXParserFactory spf = SAXParserFactory.newInstance();
>             spf.setNamespaceAware( true );
>             spf.setValidating( true );
>             
>             SAXParser sp = spf.newSAXParser();
>             sp.getXMLReader().setFeature(FLAG_VALIDATE, true);
>             sp.getXMLReader().setFeature(FLAG_SCHEMA, true);

            sp.setProperty( 
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocat
ion", "file://c:/!dev/omni/xsd/IesVendor.xsd");

>             
>             //sp.setProperty( 
> org.apache.xerces.jaxp.JAXPConstants.JAXP_SCHEMA_LANGUAGE, 
> org.apache.xerces.jaxp.JAXPConstants.W3C_XML_SCHEMA );
>             //sp.setProperty( 
> org.apache.xerces.jaxp.JAXPConstants.JAXP_SCHEMA_SOURCE, 
> "file://c:/!dev/omni/xsd/IesVendor.xsd" );
>             
>             log.info( "parse started." );
>             sp.parse( source, this );
>             log.info( "parse complete." );
>         }
>         catch( Throwable t )
>         {
>             log.warn( t.toString() );
>             t.printStackTrace();
>         }
>     }
> 
> }
> 
> Here's the output:
> ...
> 4216  INFO [main] (TypeHandler.java:95) - parse started.
> 7741  WARN [main] (TypeHandler.java:107) - 
> java.lang.ExceptionInInitializerError
> java.lang.ExceptionInInitializerError: java.lang.RuntimeException: 
> internal error
>         at 
> org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.applyFacets1(XSS
> impleTypeD
> ecl.java:554)
>         at 
> org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.createBuiltIn
> Types(Sche
> maDVFactoryImpl.java:334)
>         at 
> org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.<clinit>(Sche
> maDVFactor
> yImpl.java:80)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:120)
>         at 
> org.apache.xerces.impl.dv.SchemaDVFactory.getInstance(SchemaDV
> Factory.ja
> va:106)
>         at 
> org.apache.xerces.impl.dv.SchemaDVFactory.getInstance(SchemaDV
> Factory.ja
> va:90)
>         at 
> org.apache.xerces.impl.xs.SchemaGrammar$BuiltinSchemaGrammar.<
> init>(Sche
> maGrammar.java:155)
>         at 
> org.apache.xerces.impl.xs.SchemaGrammar.<clinit>(SchemaGrammar
> .java:629)
>         at 
> org.apache.xerces.impl.xs.XMLSchemaValidator.<init>(XMLSchemaV
> alidator.j
> ava:1062)
>         at 
> org.apache.xerces.parsers.StandardParserConfiguration.configur
> ePipeline(
> StandardParserConfiguration.java:225)
>         at 
> org.apache.xerces.parsers.DTDConfiguration.reset(DTDConfigurat
> ion.java:6
> 23)
>         at 
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfigurat
> ion.java:4
> 98)
>         at 
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfigurat
> ion.java:5
> 81)
>         at 
> org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
>         at 
> org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXP
> arser.java
> :1175)
>         at javax.xml.parsers.SAXParser.parse(Unknown Source)
>         at javax.xml.parsers.SAXParser.parse(Unknown Source)
>         at 
> com.sprint.ltd.nida.omni.types.TypeHandler.parse(TypeHandler.java:96)
>         at 
> com.sprint.ltd.nida.omni.OmniLoader.main(OmniLoader.java:113)
> 
> 
> Thank you in advance.
> Thank you.
> 
> > -----Original Message-----
> > From: lane [mailto:[EMAIL PROTECTED]
> > Sent: Monday, October 07, 2002 10:37 AM
> > To: xerces-j-user
> > Cc: lane
> > Subject: Re: AW: Not an FAQ: still unable to validate against XSD
> > 
> > 
> > I apologize if my previous message ends up making it, since it's 
> > essentially the same.  My SMTP has no record of sending it.
> > 
> > I am having basically the same problem, with the exception 
> that I am 
> > using the DocumentBuilder so I can create DOM trees.  As 
> far as I can 
> > tell, there is no setProperty method, so I cannot use this 
> fix to at 
> > least get *somewhere*.
> > 
> > Regardless if this hack clears up the symptoms or not, I do 
> > not accept 
> > this as a valid fix.  The fact remains that referencing an 
> > namespace-using schema in a normal document-based manor causes the 
> > schema not to be processed correctly.  My test example that 
> does not 
> > work is as follows:
> > 
> > Schema:
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsd:schema 
> > targetNamespace="http://schemas.gridforum.org/gridServices/rsl";
> >              xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> >              
> xmlns:rsl="http://schemas.gridforum.org/gridServices/rsl";
> >              xmlns="http://schemas.gridforum.org/gridServices/rsl";
> >              version="0.2">
> > 
> >      <xsd:element name="rsl" type="rslType"/>
> > 
> >      <xsd:complexType name="rslType">
> >          <xsd:sequence>
> >              <xsd:element name="job" type="xsd:string" 
> minOccurs="0"/>
> >          </xsd:sequence>
> >      </xsd:complexType>
> > 
> > </xsd:schema>
> > 
> > 
> > Document:
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <rsl
> >              
> xmlns:rsl="http://schemas.gridforum.org/gridServices/rsl";
> >              xmlns="http://schemas.gridforum.org/gridServices/rsl";
> >              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >              xsi:schemaLocation="
> >                  http://schemas.gridforum.org/gridServices/rsl
> >                  schema/test.xsd">
> >      <job> Jobby Job Job </job>
> > </rsl>
> > 
> > 
> > Xerces code:
> > 
> >     DocumentBuilder xmlParser = null;
> >          try {
> >              parserFactory = DocumentBuilderFactory.newInstance();
> >              parserFactory.setNamespaceAware(true);
> >              parserFactory.setValidating(true);
> >              xmlParser = parserFactory.newDocumentBuilder();
> >              xmlParser.setErrorHandler(this);
> >          } catch 
> > (javax.xml.parsers.ParserConfigurationException pce) {
> >              logger.error("problem getting parser factory 
> > instance", pce);
> >              return null;
> >          }
> > 
> >     BufferedReader bufferedReader = new BufferedReader(xmlReader);
> >          return xmlParser.parse(new InputSource(bufferedReader));
> > 
> > I would really appreciate any help on this since my project is 
> > essentially stalled until I get this working.
> > 
> > Thanks,
> > Peter
> > 
> > 
> > 
> > 
> > 
> > Amthauer, Heiner wrote:
> > > Hi!
> > > 
> > > Finally, I found a way to get it work. By setting the 
> > namespace-feature to
> > > true and setting the XSD definition with the
> > > 
> > http://apache.org/xml/properties/schema/external-noNamespaceSc
> > hemaLocation
> > > property, the parser actually validates using my schema defintion.
> > > 
> > > Thanx for your efforts.
> > > 
> > > greetings
> > > Heiner
> > > 
> > > 
> > > -----Urspr�ngliche Nachricht-----
> > > Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > > Gesendet am: Montag, 7. Oktober 2002 16:32
> > > An: [EMAIL PROTECTED]
> > > Betreff: Re: Not an FAQ: still unable to validate against XSD
> > > 
> > > Have you tried turning on namespace? 
> > (SAXParserFactory#setNamespaceAware)
> > > 
> > > Sandy Gao
> > > Software Developer, IBM Canada
> > > (1-905) 413-3255
> > > [EMAIL PROTECTED]
> > > 
> > > 
> > > 
> > >  
> > > 
> > >                       "Amthauer, Heiner"
> > > 
> > >                       <[EMAIL PROTECTED]        To:       
> > "'Xerces'"
> > > <[EMAIL PROTECTED]>                            
>          
> > >                       ystems.com>                 cc:
> > > 
> > >                                                   Subject:  
> > Not an FAQ:
> > > still unable to validate against XSD                              
> > >                       10/07/2002 06:04 AM
> > > 
> > >                       Please respond to
> > > 
> > >                       xerces-j-user
> > > 
> > >  
> > > 
> > >  
> > > 
> > > 
> > > 
> > > 
> > > Hi there!
> > > 
> > > I'm still unable to validate my xml file against an XSD. 
> > Here ist the code,
> > > I use to load the file via SAX, using XERCES 2.0 (JRE1.3.1):
> > > 
> > >     private static final String FLAG_VALIDATE =
> > > "http://xml.org/sax/features/validation";;
> > >     private static final String FLAG_SCHEMA =
> > > "http://apache.org/xml/features/validation/schema";;
> > > 
> > >     private SAXParserFactory factory = null;
> > >     private org.xml.sax.SAXParser saxParser = null;
> > > 
> > >              ...
> > >         factory = SAXParserFactory.newInstance();
> > >              ...
> > >         saxParser = factory.newSAXParser();
> > >              ...
> > >              
> > saxParser.getXMLReader().setFeature(FLAG_VALIDATE, true);
> > >              
> saxParser.getXMLReader().setFeature(FLAG_SCHEMA, true);
> > >              saxParser.parse(new File(file), this);
> > >              ...
> > > 
> > > This always gives me an error saying "cvc-elt.1: Cannot find the
> > > declaration
> > > of element 'whatever'".
> > > 
> > > Since then, I've tried to use an EntityResolver for loading 
> > the XSD. I've
> > > started with writing a little test code for the 
> > EntryResolver like this:
> > > 
> > > public class SAXEntityResolver implements EntityResolver {
> > > 
> > >         public InputSource resolveEntity(String publicID, 
> > String systemID)
> > > throws SAXException, IOException {
> > >             System.out.println(publicID+", "+systemID);
> > >             return null;
> > >         }
> > > 
> > > }
> > > 
> > > ...
> > > 
> > >     private static final String FLAG_VALIDATE =
> > > "http://xml.org/sax/features/validation";;
> > >     private static final String FLAG_SCHEMA =
> > > "http://apache.org/xml/features/validation/schema";;
> > > 
> > >     private SAXParserFactory factory = null;
> > >     private SAXParser saxParser = null;
> > > 
> > >              ...
> > >         factory = SAXParserFactory.newInstance();
> > >              ...
> > >         saxParser = factory.newSAXParser();
> > >              ...
> > >              
> > saxParser.getXMLReader().setFeature(FLAG_VALIDATE, true);
> > >              
> saxParser.getXMLReader().setFeature(FLAG_SCHEMA, true);
> > >              saxParser.getXMLReader().setEntityResolver(new
> > > SAXEntityResolver());
> > >              saxParser.parse(new File(file), this);
> > >              ...
> > > 
> > > In result, my programm still reads the xml file with the 
> > same error as
> > > before. The println() in the EntityResolver is never reached.
> > > 
> > > I woulde really appreciate any help on this. Next on 
> > schedule is testing
> > > and
> > > I'm still unable to validate the xml file. Btw., loading 
> > the file with any
> > > other XML/XSD aware application works fine.
> > > 
> > > regards
> > > Heiner
> > > 
> > > 
> > > ---------------------------------------------------------------
> > > Dipl. Ing. Heiner Amthauer
> > > 
> > > T-Systems GEI GmbH
> > > 
> > > Hausanschrift: Magirusstr. 39/1, 89077 Ulm
> > > Postanschrift: Postfach 20 64, 89010 Ulm
> > > Telefon: +49 ( 731) 9344-4422
> > > Telefax: +49 (731) 9344-4409
> > > Mobil: +49 (1 78) 4269335
> > > E-Mail: [EMAIL PROTECTED]
> > > Internet: http://www.t-systems.com
> > > 
> > > 
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to