cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graaf, Edgar de (fin)" <Edgar.de.Gr...@ordina.nl>
Subject RE: Newbie Question
Date Fri, 19 Apr 2002 09:55:08 GMT
You could do it with a parser like Xerces. (xml.apache.org)

public void parseXml(String xml) throws SAXException, IOException{
		 try {
			XMLReader parser = XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser");
			parser.setContentHandler(this.xmlConsumer);
			parser.setErrorHandler(this);
			try {
					//if (validate && parser instanceof
XMLReader)
					if ( parser instanceof XMLReader ){
	
((XMLReader)parser).setFeature( "http://xml.org/sax/features/validation",
true
	
((XMLReader)parser).setFeature( "http://xml.org/sax/features/namespaces",
true
	
((XMLReader)parser).setFeature("http://apache.org/xml/features/validation/sc
hema",true );
	
((XMLReader)parser).setFeature(
"http://apache.org/xml/features/nonvalidating/load-external-dtd",
	
true );
	
((XMLReader)parser).setFeature(
"http://apache.org/xml/features/validation/schema-full-checking",
	
true );

					}
			} catch (Exception ex) {
			}
			parser.parse(new InputSource( new StringReader(xml))
);
			} catch (org.xml.sax.SAXParseException spe) {
				spe.printStackTrace(System.err);
      }

	}

You have to do the right import etc..

regards,

Edgar
-----Oorspronkelijk bericht-----
Van: Sorin Marti [mailto:mas@semafor.ch]
Verzonden: vrijdag 19 april 2002 11:23
Aan: cocoon-users@xml.apache.org
Onderwerp: Newbie Question


Hello toghether

I'm a XML newbie and a Cocoon newbie, too...

I wrote an example XML File and the appropriate XML schema.
How to validate the XML File? (I guess I have to validate it because
there are rules that you can't fill in this or that in a certain element...

every advice would be helpful...

thanks in advance mas


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message