Home  >  Article  >  Backend Development  >  XML Schema-vCard structure detailed explanation

XML Schema-vCard structure detailed explanation

黄舟
黄舟Original
2017-03-14 16:19:311714browse

Recording contact information is important to all business applications, and capturing this information through an efficient XML structure can simplify the processing of this data. Contact information can vary widely, so XML should be chosen. For example, some companies and individuals may have multiple addresses, phone numbers, and email accounts. It is easy to declare multiple pieces of this information in an XML structure. vCar
Recording contact information is important to all business applications, and capturing this information through an efficient XML structure can simplify the processing of this data.
Contact information can vary widely, so XML should be chosen. For example, some companies and individuals may have multiple addresses, phone numbers, and email accounts. It is easy to declare multiple pieces of this information in an XML structure.
The vCard structure, often used on the Internet to represent contact information, is platform independent and can be easily generated and imported into different applications. It supports some of the flexibility of XML structure, but is actually a simple text-based format that uses declarative fields and extensions to provide information. Unlike XML, the vCard format is flat text, which means that you cannot directly add information to various elements. A good example is a phone number that is not necessarily associated with an address but simply acts as another phone number on the record. The
W3 Alliance proposes a vCard format for XML that adopts the RDF XML standard to facilitate the formatting and exchange of contact information. Using RDF Framework can preserve some structured information during the declaration process. For example, the RDF standard supports the use of packages, sequences, and substitutions to describe data. Packages support multiple declarations of an object (such as multiple roles), and packages can be used when the sequence is not important. Sequences are used to define the order of objects, such as a hierarchy of roles for people in an organization. Overrides allow selecting an item from a list, such as multiple email addresses.
Listing 6 shows the vCard for the fictional character Charles Perston.
Listing 6. Charles Perston's vCard

BEGIN:VCARD
VERSION:3.0
N:Perston;Charles;;;
FN:Charles Perston
ORG:Perston Technology;
EMAIL;type=INTERNET;type=WORK;type=pref:null@perston.co.uk
TEL;type=WORK;type=pref:01234 567890
item1.ADR;type=WORK;type=pref:;;Perston House;Perston;Perstonshire;P1 0NS;UK
item1.X-ABADR:gb
X-ABUID:5AE47BB6-4E0F-4558-980C-BD3066FA6154\:ABPerson
END:VCARD

Adopting the vCard XML standard, the same information can be represented by the structure in Listing 7.
Listing 7. Representing Charles Perston using the vCard XML standard

<vCard:vCard xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
 xmlns:foaf="http://xmlns.com/foaf/0.1/" vCard:version="3.0"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" vCard:class="PUBLIC"
 xmlns:vCard="x-urn:cpan:ascope:xml-generator-vcard#">
 <vCard:fn>Charles Perston</vCard:fn>
 <vCard:n>
 <vCard:family>Perston</vCard:family>
 <vCard:given>Charles</vCard:given>
 </vCard:n>
 <vCard:adr vCard:del.type="pref;work">
 <vCard:street>Perston House</vCard:street>
 <vCard:locality>Perston</vCard:locality>
 <vCard:region>Perstonshire</vCard:region>
 <vCard:pcode>P1 0NS</vCard:pcode>
 <vCard:country>UK</vCard:country>
 </vCard:adr>
 <vCard:email vCard:email.type="internet;pref;work">null@perston.co.uk
 </vCard:email>
 <vCard:org>
 <vCard:orgnam>Perston Technology</vCard:orgnam>
 </vCard:org>
</vCard:vCard>

The XML format is longer, but easy to understand what you are looking at and how the parts are related. This format allows for more detailed information and details. For example, it is easy to find the required country in the address, which is relatively implicit in the standard vCard output.
As another example, it is easy to use XPath or SAX Events to extract a list of countries in order to understand the number of contacts located in different regions.                                                                                              

The above is the detailed content of XML Schema-vCard structure detailed explanation. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn