[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Validating XML file externally
hi, I wrote a small swing app a while ago that does this. The validation itself is specified like thi8s: -------- some definitions 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"; static String schemaSource = "/kk/artf/files/raport.xsd"; static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; ---------- the validating method private void validateFile() throws ParserConfigurationException, SAXException, IOException { String filePath; filePath = jPath.getText(); f = new File(filePath); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); factory.setAttribute(JAXP_SCHEMA_SOURCE,new File(schemaSource)); DocumentBuilder bld=null; bld = factory.newDocumentBuilder(); bld.setErrorHandler(this); doc = bld.parse(f); } --------------- I'll send you privately the whole class just in case you want to try it out regards Kaarle Hi Team, I wrote XSD for an XML file. Is it possible to validate this XML file by using the XSD without modifying the XML file. I mean to say, is there any way to validate the XML file externally using XSD (without specifying in XML file). Thanks, Sundeep.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|