Hi, I'm creating a program that parses a text file and uses its data to create an xml file. The xml file is defined by an XML schema.
Using a sample I've found in Internet, I've decided to develop the following solution: I've created a text parser that generates SAX events; the SAX events are received by a transformer that generates an XML file. I've got a couple of problems I'm not able to fix, so I ask you for some help. FIRST PROBLEM -------------------------- I generate a xml file that defines a DTD for validation instead of an XML schema. How can I define an XML Schema? I include a snippet of mi code. SAXTransformerFactory fact = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); TransformerHandler hd = fact.newTransformerHandler(); Transformer serializer = hd.getTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "ProvaSli.xsd"); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult streamResult = new StreamResult(outputFile); hd.setResult(streamResult); SECOND PROBLEM ------------------------------ The XML I generate is not validated against the XML schema. I would like to validate the resulting XML file while I'm generating it, that is, I don't want to validate it after the generation. How can I do it? Please, ask me if you need further information or code (or you do not understand my foreigner's English). Thanks in advance Lluis Barbal i Rubio *************************************************************************** DISCLAIMER: Este mensaje contiene información propietaria de la cual parte o toda puede contener información confidencial o protegida legalmente. Esta exclusivamente destinado al usuario de destino. Si, por un error de envio o transmisión, ha recibido este mensaje y usted no es el destinatario del mismo, por favor, notifique de este hecho al remitente. Si no es el destinatario final de este mensaje no debe usar, informar, distribuir, imprimir, copiar o difundir este mensaje bajo ningún medio. --------- DISCLAIMER: This e-mail contains propietary information some or all of which may be legally privileged. It is for the intended recipient only. If an addressing or transmission error has misdirected this e-mail, please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print or rely on this e-mail. *************************************************************************** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]