Here is the code for Android's SAXParserFactoryImpl.java:
@Override
public SAXParser newSAXParser() throws
ParserConfigurationException {
if (isValidating()) {
throw new ParserConfigurationException(
"No validating SAXParser implementation
available");
}
try {
return new SAXParserImpl(features);
} catch (Exception ex) {
throw new ParserConfigurationException(ex.toString());
}
}
The Android DOM parser DocumentBuilderFactory has something very
similar. Neither supports validation. You have to find a 3rd party
parser of you want to validate.
On Apr 4, 8:36 am, RedBullet <[email protected]> wrote:
> That's sort of what I am doing now. Seems kind of unsatisfying ;-)
>
> Just wanted to know what my options were...
>
> It is confusing because the docs seem to imply that one can do validation...
>
>
>
>
>
>
>
> On Wednesday, April 4, 2012 9:39:07 AM UTC-4, Streets Of Boston wrote:
>
> > What about not validating the incoming XML?
> > Since i don't know what type of app you need the validating SAX parser
> > for, but if your app just needs to read bits and pieces of incoming XML,
> > you really don't need a validating XML. Just read the data and present it
> > to the user. If the incoming data is not what you expect, i.e. after
> > reading the XML you are still missing pieces of data and such, let your app
> > handle this situation by itself.
>
> > On Wednesday, April 4, 2012 9:10:37 AM UTC-4, RedBullet wrote:
>
> >> Any more ideas on this? I must be doing something obviously wrong, but
> >> perhaps there just isn't a validating SAX parser for Android? (though I
> >> would have expected someone on this list to say so)...
>
> >> On Monday, April 2, 2012 12:40:13 PM UTC-4, RedBullet wrote:
>
> >>> I just tried that and got the same error. No validaing SAX parser
> >>> implementaion available.
>
> >>> On Monday, April 2, 2012 12:14:33 PM UTC-4, Daniel Drozdzewski wrote:
>
> >>>> ...so did you tell your parser the following:
>
> >>>> static final String GARMIN_SCHEMA_LANGUAGE =
> >>>> "http://www.w3.org/2001/XMLSchema-instance";
>
> >>>> static final String W3C_XML_SCHEMA =
> >>>> "http://www.w3.org/2001/XMLSchema";
>
> >>>> SAXParserFactory factory = SAXParserFactory.newInstance();
> >>>> factory.setNamespaceAware(true);
> >>>> factory.setValidating(true);
> >>>> saxParser.setProperty(GARMIN_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
>
> >>>> ??
>
> >>>> On 2 April 2012 17:10, RedBullet <> wrote:
> >>>> > Yea, I read that. My XML contains the following so I thought that
> >>>> would be
> >>>> > sifficient:
> >>>> > <?xml version="1.0" encoding="UTF-8"?>
> >>>> > <TrainingCenterDatabase
> >>>> > xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"
> >>>> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >>>> > xsi:schemaLocation="
> >>>>http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2
> >>>> >http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd">
>
> >>>> > Isn't that how it is supposed to work??
>
> >>>> > On Monday, April 2, 2012 12:01:42 PM UTC-4, Daniel Drozdzewski wrote:
>
> >>>> >> Did you tell your parser which schema will it be validating against?
> >>>> >> Setting validation flag to true is not enough...
>
> >>>> >> Have a look here at a quick validating example using SAXParser:
> >>>> >>http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXPSAX9.html
>
> >>>> >> Daniel
>
> >>>> >> On 2 April 2012 16:34, RedBullet <> wrote:
> >>>> >> > I am parsing some XML with SAX, and I noticed that there was some
> >>>> XSD in
> >>>> >> > the
> >>>> >> > files I am parsing.
>
> >>>> >> > So, I figured to would turn validation on the factory before I get
> >>>> the
> >>>> >> > parse, but when I do I get an error saying there is no validating
> >>>> parser
> >>>> >> > available.
>
> >>>> >> > So... How does one validate XML on the Android??
>
> >>>> >> > --
>
> >>>> >> --
> >>>> >> Daniel Drozdzewski
>
> >>>> > --
>
> >>>> --
> >>>> Daniel Drozdzewski
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en