16 May 16:43
Re: [groovy-user] XML processing with Groovy's different APIs
From: Jean-Noël Rivasseau <elvanor@...>
Subject: Re: [groovy-user] XML processing with Groovy's different APIs
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-05-16 14:43:54 GMT
Subject: Re: [groovy-user] XML processing with Groovy's different APIs
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-05-16 14:43:54 GMT
My document looks like: <?xml version="1.0" encoding="UTF-8"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/cs02/xliff-core-1.2-strict.xsd"> I think this is correct. I am using DOMBuilder right now, how can I pass a parser having the validation property set to true? I have tried: def reader = new FileReader(file) def document = DOMBuilder.parse(reader, true false) but it does not work (From the errors it looks like it is trying to validate against a DTD, which is not present). Jean-Noel On Fri, May 16, 2008 at 3:43 PM, tugwilson <tug <at> wilson.co.uk> wrote: > > > > Jean-Noël Rivasseau-3 wrote: >> >> My question is : is it possible to do schema validation (not DTD) >> directly in DOMBuilder, XmlParser or XmlSlurper? According to the >> docs, it seems that validation with these objects works only with a >> DTD. I am using a schema, I tried to use validation but it failed. >> Does that mean I have to turn validation off and use the method >> described (involving creating a validator object)? >> > > > If your XML document contains xsi:noNamespaceSchemaLocation or > xsi:schemaLocation attributes and the parser's > http://xml.org/sax/features/validation property is true then the parser will > validate against the schema. If not you need to set the parser's > http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation > and/or http://apache.org/xml/properties/schema/external-schemaLocation > properties. See http://xerces.apache.org/xerces-j/schema.html > > With XmlSlurper you can instantiate and configure the parser and then pass > the configured parser to the constructor. > > John Wilson > -- > View this message in context: http://www.nabble.com/XML-processing-with-Groovy%27s-different-APIs-tp17274414p17275063.html > Sent from the groovy - user mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >
RSS Feed