Mark, For validation read: http://xml.apache.org/xerces-j/faq-general.html#faq-7
As for the example, I can't get it working either :( I was trying to use templates with an XMLFilter, but I couldnt get it to work. This is my working code (using saxon btw): SAXTransformerFactory saxFactory = (SAXTransformerFactory)factory; ajwFilter xmlFilter = new ajwFilter(); //ajwFilter is my custom sax parsing code xmlFilter.setParent(new com.icl.saxon.aelfred.SAXDriver()); XMLFilter styleSheet = saxFactory.newXMLFilter(new StreamSource(style)); styleSheet.setParent(xmlFilter); TransformerHandler serializer = saxFactory.newTransformerHandler(); serializer.setResult(new StreamResult(System.out)); styleSheet.setContentHandler(serializer); styleSheet.parse(source.getSystemId()); This should help you with using SAXTransformerFactory - you have 4 items in the pipeline 1. Saxdriver of parser 2. XMLFilter 1 - my custom sax code to extract info 3. XMLFilter 2 - the stylesheet 4. TransformerHandler ajwFilter entends XMLFilterImpl. I hope this helps (if you manage to get this code working with templates please post it back for me - that would be great) cheers andrew -----Original Message----- From: Mark Woon [mailto:[EMAIL PROTECTED] Sent: 25 July 2002 04:11 To: Andrew Welch Cc: [EMAIL PROTECTED] Subject: Re: Validating xml before transformation Andrew Welch wrote: >>I'd like to validate an XML file before >>transforming it, and am wondering >>if there's an easy way to do it? >> >> > >try: > >parser.setFeature ( > "http://xml.org/sax/features/validation", > true); > > Hmm... How do I get a handle on the parser? I assume by parser you mean an XMLReader? Also, does anyone know if the code fragment under "Explicitly working with SAX" at http://xml.apache.org/xalan-j/usagepatterns.html#sax is correct? After cutting and pasting that bit of code, cleaning it up and compiling it, I cannot seem to get it to work. I keep getting an error along the lines of "Warning: unrecognized element foo" where foo is my root element. The XSL and XML files I'm testing this with works perfectly fine with org.apache.xalan.xslt.Process. Thanks, -Mark --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.373 / Virus Database: 208 - Release Date: 01/07/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.373 / Virus Database: 208 - Release Date: 01/07/2002
