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.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--