Choosing the right design pattern for data conversion, validation
===

I have the below architecture.

 1. Get data from User
 2. Validate data
 3. Store data in db

To simplify, let us assume data is of type Invoice. I have defined Invoice as an interface
<pre>
Invoice () {
getInvoiceId ();
getInvoiceAmount();
...
....
}
</pre>
In one of my implementations, the input from user is xml and in another it is json
Similarly I have two databases, one stores the invoice as xml and another as json

So I implement the Invoice interface twice as
<pre>
InvoiceXml () {
xml _invoiceData;
getInvoiceId() {
return _invoiceData.id;
}

InvoiceJson () {
json _invoiceData;
getInvoiceId() {
return _invoiceData.id;
}
</pre>
Now my main class accepts an instance of Invoice interface.
<pre>
main(Validator validator, DAO db) 
{
   Invoice invoice = inputs.getInvoice();
   if (invoice instanceOf InvoiceXml {
    validator.validateXml(invoice);
    db.insertXml(invoice);
   }
   else //similar for Json
}
</pre>
Now the concern I have is that validator and db both actually need the json/xml representation of invoice but since I depend only on the Invoice interface I have to downcast Invoice before passing it to validate and db. 

I am not sure of how to design this in a better way. I was thinking of changing the Invoice interface to a POJO but there are many fields on the Invoice (getInvoiceId and getInvoiceAmount are the common ones used) so I have to internally store the invoice as an xml or json value only. 
