xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Arjan Huijzer <huijzer AT gmail.com>
- To: XOM-interest AT lists.ibiblio.org
- Cc:
- Subject: Re: [XOM-interest] Validate questions
- Date: Thu, 27 Jan 2005 13:03:57 +0100
Just in case someone is curious, I have attached my modified code that
now allows me to validate against an external XML schema. Note that I
have included the Xerces 2.6.2. parser.
----------------------------------------------------------------------
XMLReader xerces =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
xerces.setFeature("http://apache.org/xml/features/validation/schema",
true);
xerces.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
"file:///c:/xomtest/books.xsd");
Builder parser = new Builder(xerces, true);
Document doc = parser.build( new File("c:/xomtest/books.xml") );
----------------------------------------------------------------------
Gr. Arjan
On Thu, 27 Jan 2005 12:39:36 +0100, Arjan Huijzer <huijzer AT gmail.com> wrote:
> Thanks for all the valuable answers. I am trying out the different
> solutions as we speak. Looking good so far :-)
>
>
> On Thu, 27 Jan 2005 11:23:01 +0000, Steve Loughran
> <steve.loughran AT gmail.com> wrote:
> > On Thu, 27 Jan 2005 10:51:31 +0100, Arjan Huijzer <huijzer AT gmail.com>
> > wrote:
> > > Hi all,
> > >
> > > I have been adding a validity check to my XML documents and have a
> > > couple of questions:
> > >
> > > 1. Does XOM support validation against an XML schema? So far, I have
> > > only been able to validate againt a DTD
> >
> > Turn it on in the parser. This is my option set for validating docs
> > incoming from somewhat trusted sources where I dont want to enable a
> > couple of security risks (entity expansion, doctype redeclaration)
> >
> > xerces.setFeature(
> > "http://apache.org/xml/features/validation/schema",
> > validate);
> > xerces.setFeature(
> >
> > "http://apache.org/xml/features/validation/schema-full-checking",
> > validate);
> > xerces.setFeature(
> >
> > "http://apache.org/xml/features/standard-uri-conformant",
> > true);
> > xerces.setFeature(
> >
> > "http://apache.org/xml/features/disallow-doctype-decl",
> > true);
> > xerces.setFeature(,
> >
> > "http://xml.org/sax/features/external-general-entities",
> > false);
> >
> > I also set up my own catalog, for DTD resolution, and get schema res
> > by telling xerces the local location of things like this:-
> >
> > parser.setProperty(
> > "http://apache.org/xml/properties/schema/external-schemaLocation",
> > "http: //domain.com/mynamespace mySchema.xsd");
> >
> > > 2. Do I have to include a doctype declaration to my XML document or
> > > can I also declare in my java code against which DTD the document
> > > should be validated.
> >
> > -dont know
> >
> >
> > >
> > > Furthermore, I noticed some odd behaviour. My code to parse an XML
> > > document used to be:
> > >
> > > Document doc = parser.build("c:/xomtest/books.xml");
> > >
> > > This worked fine until I switched to Xerces, which bow trows an
> > > IOException. I had to modify my code to read:
> > >
> > > Document doc = parser.build("file:///c:/xomtest/books.xml");
> >
> > well, that is a proper URI at that point. Maybe xerces is fussy.
> >
> > If you use Builder.build(File) then everything works.
> >
> > I would point you to the LGPL source where I do all this, which is in
> > smartfrog CVS on sourceforge (
> > http://sourceforge.net/projects/smartfrog ), with the caveat that I
> > reserve the right to be incompetent (this was my first use of Xom)
> >
> > Look at the files in
> > http://cvs.sourceforge.net/viewcvs.py/smartfrog/core/components/cddlm/src/org/smartfrog/services/cddlm/cdl/
> >
> > There is something there that may be of broader interest: something to
> > extract a XOM document from bits of an incoming Axis SOAP message. Its
> > an inefficient process, which shows how badly designed JAXRPC is for
> > anyone who wants to work with the XML itself, but it does at least
> > give you XML you can use.
> >
> > -steve
> > _______________________________________________
> > XOM-interest mailing list
> > XOM-interest AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/xom-interest
> >
>
-
[XOM-interest] Validate questions,
Arjan Huijzer, 01/27/2005
- RE: [XOM-interest] Validate questions, Michael Kay, 01/27/2005
-
Re: [XOM-interest] Validate questions,
Steve Loughran, 01/27/2005
-
Re: [XOM-interest] Validate questions,
Arjan Huijzer, 01/27/2005
-
Re: [XOM-interest] Validate questions,
Arjan Huijzer, 01/27/2005
- Re: [XOM-interest] Validate questions, Wolfgang Hoschek, 01/27/2005
-
Re: [XOM-interest] Validate questions,
Arjan Huijzer, 01/27/2005
-
Re: [XOM-interest] Validate questions,
Arjan Huijzer, 01/27/2005
Archive powered by MHonArc 2.6.24.