users@jaxb.java.net

Re: Detect errors in xml files

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Fri, 9 Jan 2009 13:14:25 +0100

sure:

JAXB provides a mechanism to inspect the XML parsing - by events.. so,
after reading each xml element you have a Java method to check its
contents.. then you proceed the business rules on each value..

the format of the XML is validated automatically by the schema..

please checkout Footprint code:

svn checkout https://footprint.dev.java.net/svn/footprint/trunk/footprint-core
footprint-core --username guest
* blank password is ok

and then run ant in its root folder

then you please check the package: net.java.dev.footprint.xml

it contains all examples you need..

sorry, I don't have time to google for tutorials or examples, but the
keywords are: JAXB Unmarshaller event handler


On Fri, Jan 9, 2009 at 1:01 PM, mimoune <lhafi_at_yahoo.fr> wrote:
>
> thank you for your answer..
>
> by only validating i can't treat the error to indicate where exactly has
> occured, and about the listner i have no idea how it works, if you can give
> an example..
>
>
>
> Felipe Gaucho wrote:
>>
>> use the xsd schema to validate the xml ..
>>
>> that solves the types and ranges problems...
>> f you need also business validation on the xml data, use a listener of
>> the JAXB parser to validate these cases...
>>
>> if this solution fits your requirements, ask for an example
>>
>> On Fri, Jan 9, 2009 at 12:37 PM, mimoune <lhafi_at_yahoo.fr> wrote:
>>>
>>> Hi,
>>>
>>> i need to get data from xml, my problem is that i need to know the xml
>>> file
>>> errors (like elements missing or data type) to report the errors to other
>>> users..
>>>
>>> what i was trying to do is unmarshal the xml file and with get methods to
>>> check if i have errors with try catch, bt i don't get any errors..
>>>
>>> example
>>>
>>> try{
>>> double valor = getInvoiceSeriesCode();
>>> } catch(Exception e){
>>> error = true;
>>> e.printStackTrace();
>>> }
>>>
>>> but that way i have no message erros..
>>>
>>> some help? and sorry for my english
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Detect-errors-in-xml-files-tp21370693p21370693.html
>>> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Detect-errors-in-xml-files-tp21370693p21370979.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>