[Cosmo-dev] VCard Parsing in Cosmo

Vinubalaji Gopal vinu at osafoundation.org
Tue Jul 18 11:17:18 PDT 2006


Hi all,
   I have been working with the vcard parser (vcard4j) for parsing the
VCards and storing the key/value pairs in the repository. I have a few
questions about the parsing and want to share/discuss about vcard
parsing.

Question: Each vcf file may contain many vcard elements: I am not sure
if this is allowed in the RFC but this is how the parser is designed and
most of the parsers around have this kind of implementation. That being
the case how do I handle the parsing and storing of the key value pairs
- store them as a single resource (in which case I need to differentiate
the two or more cards) or store them as multiple resource?

If we decide on not allowing multiple vcards (in a same file) in a
single PUT, I can throw an Exception and return and error code in the
CardDAV implementation :).

   vcard4j does not provide any simple means to get the key/value pair -
the only way to access the different key-value pair is to create
different java objects. Example: if you want to get the FN and its value
from the vcard file - you need to create a FN object and get the value
by calling get() method of FN. 

  Since I wanted a flat view of the entire vcard, I am directly working
on the DOM created by vcard4j. I almost got all the fields by custom
XPath queries on the DOM structure and I am now tweaking to get the
other fields working!
  

--
Vinu



More information about the cosmo-dev mailing list