Danh mục

Creating Applications with Mozilla-Chapter 10. RDF, RDF Tools, and the Content Model-P3

Số trang: 17      Loại file: pdf      Dung lượng: 46.35 KB      Lượt xem: 1      Lượt tải: 0    
Hoai.2512

Hỗ trợ phí lưu trữ khi tải xuống: 13,000 VND Tải xuống file đầy đủ (17 trang) 0

Báo xấu

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu creating applications with mozilla-chapter 10. rdf, rdf tools, and the content model-p3, công nghệ thông tin, quản trị web phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Creating Applications with Mozilla-Chapter 10. RDF, RDF Tools, and the Content Model-P3 Chapter 10. RDF, RDF Tools, and the Content Model-P310.3.1. What Is an RDF Component?An RDF component may implement any number of the general RDFinterfaces described here, in addition to special interfaces for accessing andcontrolling the data the datasource represents. For example,@mozilla.org/rdf/datasource;1?name=internetsearch isan RDF component used to control Mozillas internet searching facility. InMozilla, a component can act as a library of code specific to a given set ofdata or domain. The internetsearch component is instantiated andused to recall text entered in a previous search:var searchDS =Components.classes[@mozilla.org/rdf/datasource;1?name=internetsearch].getService(Components.interfaces.nsIInternetSearchService);searchDS.RememberLastSearchText(escapedSearchStr);This RDF component implements an interface callednsIInternetSearchService, which is selected from the component and used tocall the RememberLastSearchText method. Although you can also usethe getService method to get one of a components RDF interfaces (e.g.,by usinggetService(Components.interfaces.nsIRDFDataSource)),doing so is seldom necessary in practice. RDF components are tailored to thedatasources they represent and usually provide all the access you need toaccess that data directly. Example 10-6 lists RDF components in Mozilla.Example 10-6. RDF-specific components built into Mozilla@mozilla.org/rdf/container;1@mozilla.org/rdf/content-sink;1@mozilla.org/rdf/datasource;1?name=addresscard@mozilla.org/rdf/datasource;1?name=addressdirectory@mozilla.org/rdf/datasource;1?name=bookmarks@mozilla.org/rdf/datasource;1?name=charset-menu@mozilla.org/rdf/datasource;1?name=composite-datasource@mozilla.org/rdf/datasource;1?name=files@mozilla.org/rdf/datasource;1?name=history@mozilla.org/rdf/datasource;1?name=httpindex@mozilla.org/rdf/datasource;1?name=in-memory-datasource@mozilla.org/rdf/datasource;1?name=internetsearch@mozilla.org/rdf/datasource;1?name=ispdefaults@mozilla.org/rdf/datasource;1?name=local-store@mozilla.org/rdf/datasource;1?name=localsearch@mozilla.org/rdf/datasource;1?name=mailnewsfolders@mozilla.org/rdf/datasource;1?name=msgaccountmanager@mozilla.org/rdf/datasource;1?name=msgfilters@mozilla.org/rdf/datasource;1?name=msgnotifications@mozilla.org/rdf/datasource;1?name=smtp@mozilla.org/rdf/datasource;1?name=subscribe@mozilla.org/rdf/datasource;1?name=window-mediator@mozilla.org/rdf/datasource;1?name=xml-datasource@mozilla.org/rdf/delegate-factory;1?key=filter&scheme=imap@mozilla.org/rdf/delegate-factory;1?key=filter&scheme=mailbox@mozilla.org/rdf/delegate-factory;1?key=filter&scheme=news@mozilla.org/rdf/delegate-factory;1?key=smtpserver&scheme=smtp@mozilla.org/rdf/rdf-service;1@mozilla.org/rdf/resource-factory;1@mozilla.org/rdf/resource-factory;1?name=abdirectory@mozilla.org/rdf/resource-factory;1?name=abmdbcard@mozilla.org/rdf/resource-factory;1?name=abmdbdirectory@mozilla.org/rdf/resource-factory;1?name=imap@mozilla.org/rdf/resource-factory;1?name=mailbox@mozilla.org/rdf/resource-factory;1?name=news@mozilla.org/rdf/xml-parser;1@mozilla.org/rdf/xml-serializer;1From this list, components used often in the Mozilla source code includebookmarks, history, mail and news folders, and address books.Special URIsMozillas built-in datasource components have special URIs for access. Hereis the format used to determine the URI from the component reference:Component:@mozilla.org/rdf/datasource;1?name=SomeNameDatasource URI:rdf:SomeNameThe URI, such as rdf:someName, is also accessible as a datasource property:foo-ds.URI10.3.2. What Are RDF Interfaces?RDF interfaces are interfaces in Mozilla designed to manipulate RDFstructures and data. They typically deal with RDF generally, rather thanspecific sets of data (as in the case of components). A common use for anRDF interface in JavaScript, shown in Example 10-7, is to usensIRDFService to retrieve or assert the root node of an RDF datasource.Example 10-7. Creating a root node// get the nsIRDFService interface and assign it toRDFRDF = Components.classes[`@mozilla.org/rdf/rdf-service;1].getService(Components.interfaces.nsIRDFService);// call the GetResource method from the interfacerootResource = RDF.GetResource(urn:root);Like all Mozilla interfaces, RDF interfaces (shown in Table 10-3) aredefined in IDL and can be accessed through XPCOM. The examples in thissection use JavaScript and XPConnect to access the components forsimplicity, but you can also use these interfaces with C++, as they are oftenin the actual Mozilla source code. Most interfaces deal with datasources,which drive the use of RDF in Mozilla.Table 10-3. Mozillas built-in RDF interfacesRDF interface Description Mostly used for retrieving datasources, resources, and literals. ItnsIRDFService also registers and unregisters datasources and resources. Allows the addition and removal of ansIRDFCompositeDataSource datasource from a compositeRDF interface Description datasource (which may be empty). Mostly used for adding, removing,nsIRDFDataSource, and changing triples in a datasource.nsIRDFPurgeableDataSource, It provides the means to change thensIRDFRemoteDataSource graph. Provide an equality function. ValuesnsIRDFNode, nsIRDFResource, for resources and lit ...

Tài liệu được xem nhiều: