[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xml validation


parser.setproperty
Yes, this can be done by Xerces 2.  See the XML Schema how-to page in its
documentation and the code snippet below. The extSchemaLocations string is
of the form
"namespace-uri-1 schema-1 ... namespace-uri-n schema-n "
(note that the schemas can be local copies of the 'definitive' ones on the
Web).

The org.apache.xerces.parsers.DomParser.parse() function takes an
org.xml.sax.InputSource.

Jeff

            DomParser parser = new DomParser();
            String propId
                =
"http://apache.org/xml/properties/dom/document-class-name";
            Object propVal = "org.apache.xerces.dom.PSVIDocumentImpl";
            parser.setProperty(propId, propVal);
// you may not want all these validation features
            if ((noNsXsdFilePath != null)
                || (extSchemaLocationsString != null)) {
                parser.setFeature("http://xml.org/sax/features/validation",
                                  true);
                parser.setFeature("http://apache.org/xml/features/"
                                  + "validation/schema", true);
                parser.setFeature("http://apache.org/xml/features/"
                                  + "validation/schema-full-checking",
true);

                parser.setFeature("http://apache.org/xml/features/"
                                  + "dom/include-ignorable-whitespace",
false);
            }

            //parser.setFeature("http://xml.org/sax/features/"
            // + "namespace-prefixes",
            //                true);

            parser.setErrorHandler(new InnerErrorHandler());

            if (noNsXsdFilePath != null) {
                propId = "http://apache.org/xml/properties"
                    + "/schema/external-noNamespaceSchemaLocation";
                parser.setProperty(propId, noNsXsdFilePath);
            }

            if (extSchemaLocationsString != null) {
                propId = "http://apache.org/xml/properties"
                    + "/schema/external-schemaLocation";
                parser.setProperty(propId, extSchemaLocationsString);
            }

            parser.parse(xmlInputSource);

            Document rv = parser.getDocument();


----- Original Message -----
From: Brian Shields
To: Gerben Rampaart (Casnet Brussel) ; xml-dev@l...
Sent: Wednesday, October 09, 2002 6:27 AM
Subject: RE:  xml validation


but is there not a parser out there that i can use that will do something
like:
Parser p = new Parser();
p.setSchemaLocation(schemaFile.xsd);
p.parse(xmlFile.xml);


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.