Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 38 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
38
Dung lượng
415,36 KB
Nội dung
However, REST is not a plug-in solution to everything. One common issue is that it requires you to rethink the application in terms of manipulations of addressable resources. The usual design approach today calls for method calls to a specified component. Server-side implementation is arbitrary and behind the scenes, to be sure, but the API you communicate to your clients should be in terms of HTTP manipulations on XML documents addressed by URIs, not in terms of method calls with parameters. Anyway, given any protocol for expressing messages, what shall the messages express? Expressing Assertions (RDF) To codify the meaning of Web content – in other words, do more than simply mark up syntactical content elements – the Resource Description Framework was devised as a way to mark up metadata. More to the point, RDF provided a means to exchange metadata, and the concept is fundamental to later constructs. The defining elements or rules are: Resource, which is anything that can be assigned a URI (for example as a Web-location URL). Property, which is a named Resource that can be used as a property. Assertion, which is a statement about some relationship, as a combination of a Resource, a Property, and a value. Quotation, which is making an Assertion about other Assertions. Expressibility, in that there is a straightforward method for expressing these abstract Properties in XML. Assertions are like simple sentence s in natural languages, the statement parts predictably denoted with the linguistic terms subject, predicate, and object – for example, ‘Resource x (URI) is/has Property y (URI) value z (opt ional URI)’. The com mon programming notion of key-value pairs (hash) can be recast as a triplet by understanding that the predicate is in this case implicit in the context. RDF triplets can occur in an arbitrary order – something that seems natural in the cont ext of metadata. By contrast, element order can be very significant in XML. Figure 5.5 provides a visual illustration of such three-part assertions. Figure 5.5 Example of simple RDF triplets applied to a typical case, asserting two properties for a book-type resource. A real-world example would have many properties, not just two. Libraries are big users of RDF Languages and Protocols 131 A concrete simple assertion using a resource variable might be ‘MyLanIP is 192.168.1.3’– or as URIs for each element of the triplet: <http://example.com/currentMachine> <http://www.commonverbs.org/terms/assignedldentity> <http://example.com/currentNodeIP> Figure 5.6 builds on the previous example to show how indirection results when a value is itself defined as a resource about which assertions can be made. Implied in the diagram is that the properties are defined in a common storage location given for the particular metadata application, but while common in practice, this assumption is not necessarily true. Each property (as resource) is associated with its own URI. RDF is carefully designed to have the following characteristics: Independence, where as a Resource, any independent organization (or person) can invent a Property which can be properly referenced and interpreted by others. Interchange, which is expedited by conversion into XML, the new lingua franca of Web exchange. Scalability, where simple, three-part RDF records (of Resource, Property, and value) are easy to handle and use as references to other objects. Properties are Resources, which means that they can have their own properties and can be found and manipulated like any other Resource. Values can be Resources, which means they can be referenced in the same way as Properties, have their own Properties, and so on. Statements can be Resources, which allows them to have Properties as well – essential if we are to be able to do lookups based on other peopl e’s metadata and properly evaluate the Assertions made. In passing, we might note that since properties and values can also be resources, they can be anything represented in a resource, not just words (although the latter is an understandable assumption made by most people). Figure 5.6 An example of a simple RDF triplet when a value is itself a resource about which an assertion can be made. Further indirection is also possible in that any value can be a resource 132 The Semantic Web Bit 5.10 RDF is a way of exchanging ‘objects’ rather than explicit elements Business applications in particular find advantage in RDF becau se of the way business data often have complex struct ure best described as objects and relations. The Containment Issue It has been argued that RDF-element order is not totally arbitrary, but rather that there is some significance in an order-related ‘containment’ concept. Perhaps so, but it turns out to be elusive to capture, despite the fact that containment seems significant to human readers. Why should ‘RDF containment’ be elusive? The answer is perhaps surprising, but RDF structures do not formally need the concept at all. A deeper analysis suggests that contain- ment is significant only for the ‘delete data’ operation, which in any case many purists eschew on principle. The ‘correct’ way to amend data is to annotate, introduce new pointers, but never remove. The containment concept turns out to seem relevant only because of the intuitive human understanding that deleting some object also deletes everything ‘contained in that object’. Aha! We find that it is ultimately an implied, human-semantic interpretation. RDF Application By itself, RDF is simply an outline model for metadata interchange, defining a basic syntax in which to express the assertion relationships that make up the metadata. In fact, it is such a simple model that initially it takes a considerable amount of work to implement anything usable. But once defined, the broad capability for reuse makes the effort worthwhile. Simplicity aside, an automated RDF Validation Service is provided by the W3C (found at www.w3.org/RDF/Validator/). Formal validation is always recommended whenever markup is involved – whether (X)HTML, XML, or RDF. Raw tagged text tends to be opaque even to experienced readers, and subsequent machine parsing is always highly intolerant of syntactical errors. Application of RDF generally takes the form of creating XML templates for particular cases, where the resources and properties are structured in the assertions that will define the relationships to be mapped from the available data in some database. The XML template is constructed as an abstract model of metadata, and it may also contain information about how to view and edit data in the model. Populating the template with actual values from a database record generates a viewable document to display as a response to an end-user request. Figure 5.7 illustrates a typical flow around a metadata database using populated templates. Using RDF Vocabularies Properties would normally not be defined in isolation, but would instead come in vocabularies – that is, ready-to-use ‘packages’ of several context-associated descriptors. Languages and Protocols 133 As an example, a set of basic bibliographic Properties for a simple book database might be Author, Title, and Publication Date, which in a more formal context can be extended with ISBN, Publisher, Format, and so on. Different vocabularies would be expected to arise for any number of Web contexts. The nice thing about RDF vocabularies is that correspondences between similar voca- bularies can easily (and globally) be established through new Assertions, so that one set’s Author can be related to another’s Creator. As anyone can create vocabularies, so anyone can create and publish correspondence definitions. It is unrealistic to think that everyone will (or can) use the same vocabulary; that is neither desirable nor necessary. Bit 5.11 Custom RDF vocabularies can become valuable commodities We can envision that opinions, pointers, indexes, and anything that helps people discover things on the ever-growing Web can become commodities of very high value. With RDF (and appropriate tools) anyone can invent vocabularies, advertise them, and sell them – creating a free marketplace in vocabularies. Most niches of information would probably come to be dominated by a small number of specialized vocabularies, determined mainl y by consensus and usage – or, if you will, by marketing and market-share. The really useful vocabularies would represent invest- ments of expertise comparable to typeface designs, for example, or good technical dictionaries. A ballpark estimate on the number of uniquely referenced objects on the Web today is in the order of half a million. It would clearly be a wasteful effort for everyone to reinvent vocabularies representing relationships between them all. Yet such wastefulness is precisely what happens when proprietary KB systems are implemented, and it risks happening if future RDF vocabularies are not made open, available for free or for modest licensing. RDF is agnostic in terms of processing software. Different software implementations can process the same metadata with consistent results, and the same software could process (at least in part) many different metadata vocabularies. Figure 5.7 A possible application loop using RDF XML templates to access and manage metadata from a database. This model is fairly representative of many metadata management implementations 134 The Semantic Web Extended RDF Layers As defined, RDF is both general and simple. The language at this point has in fact neither negation nor implication, and is therefore very limited. Consequently, further layers are required to implement a broader and more complex functionality than simply making statements about properties and statemen ts about other statements. Fortunately for early adoption, applications at this basic level of RDF are still very numerous. Such applications focus on the representation of data, whi ch typically involves simple operations such as indexing, information storage, labeling, and associating style sheets with documents. This kind of processing does not require the expression of queries or inference rules. While RDF documents at this level do not have great power, it is expected that these simple data will eventually be combined with data from other Web applications. Such extensions would require a common framework for combining information from all these applications – reason enough to go to the trouble of already now RDF-mapping the data in the simple applications. Bit 5.12 Deploying RDF structure early is a way of evolving towards future reuse Whether the local applications at present require RDF is immaterial, because once the data are mapped, new application areas for existing data become possible (and profitable) in ways that are hard to foresee. The power of the greater whole will then greatly surpass what is possible in the local data representation language. Powerful query or access control logic implemented elsewhere can reference the local data through RDF exchanges. Even though it’s simple to define, RDF will be a complete language, capable of expressing paradox and tautology, and in which it will be possible to phrase questions whose answers would to a machine require a search of the entire Web and an unimaginable amount of time to resolve. Tim Berners-Lee Referencing Namespaces XML makes the (re)use of predefined vocabularies, such as within custom RDF schemas (described later), fairly straightforward with its namespace concept. This capability has particular application when converting from one namespace to another. Bit 5.13 RDF can correlate different properties that have similar meanings The choice of a tag name depends on local usage and intended purpose, but the values assigned to one property can often fit for another property in another context. In this way, an application can import appropriate externally-maintained values. For example, suppose that a particular e-commer ce implementation uses the tag shipTo, but could benefit from directly referencing another resource’s definition of Address. The Languages and Protocols 135 advantage would be that the former is then directly tied to any changes in the latter, which might reside in a central database for customer records. Such referencing utilizes two steps: A namespace declaration, which introdu ces (‘imports’) the other schema to which reference is being made. A type reference, which embodies the actual reference to the other resource’s stored value. The namespace declaration in XML consists of an attribute ‘xmlns:’ that defines a relation between a local prefix used in naming tags and an external schema referenced by a URI (often as a Web URL, and then often using a persistent PURL pointer): xmlns: wherestuff ¼"http:// where.com / stuff .xml" The URI is the exact reference, which is tied to the arbitrary prefix that can be used locally to consistently reference the remote schema in the rest of the XML document. The external schema types can thereafter be used almost as if they were defined in the local schema: <element name¼ shipTo type¼ wherestuff :Address /> While ‘Address’ alone would uniquely reference a name in the local schema, each prefixed version is a different unique reference to an item in a another URI-specified schema. A practical schema typically leverages at least several external references, starting with the basic W3C schema (or equivalent) for defining the terms used to define the tags of interest. Element referencing is simple (and human-readable despite the many tags), as shown by a really simple example RDF file: <?xml version¼"1.0" encoding¼"utf-8"?> <rdf:RDF xmlns:rdf¼"http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns: dc¼"http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about¼"http://leuf.com/TheSemanticWeb"> <dc:creator>Bo Leuf</dc:creator> <dc:subject> Information page for book The Semantic Web with support page links. </dc:subject> </rdf:Description> </rdf:RDF> This snippet of metadata imbues a resource (the specified Web page) with two ‘about’ properties: creator and subject. Published at some public location on the Web, it thus makes assertions about these properties for the resource. 136 The Semantic Web The meaning of the ‘about’ term is defined in an external resource maintained by W3C, and referenced after the xmnls declaration by the prefix in the ‘rdf:about’ container. The creator and subject properties are standard elements defined by a Dublin Core v1.1 (‘dc:’) reference that was created for publication metadata. This DC base list contains the 15 most relevant properties for this purpose: Title, Creator, Subject, Description, Publisher, Contributor, Date, Type, Format, Identi fier, Source, Language, Relation, Coverage, and Rights. Of course, other application areas can leverage these properties for other purposes, simply by referencing the DC definitions. RDF Schema The next layer up from just map ping the data into new formats is a schema layer in which to make meta-Assertions – statements about the language itself. For example, at this next level we can do a number of useful things, such as: declare the existence of a new Property; constrain the way a Property is used, or the types of object to which it can apply; perform rudimentary checks on Resources and associated Property values. This layer is formally adequate for dealing with conversions between different schemas, even though it too lacks logic tools, because most conversion is merely a matter of identifying and mapping similar Properties. Bit 5.14 A schema is both a defining and a mapping description A schema describes types of objects and types of properties (attributes or relations), both of them being organized in two hierarchies of types. The full power of a schema layer, however, will ultimately depend on yet another layer: the logical layer, which can fully express complex logical relations between objects. Because of the self-defining nature of the XML/RDF edifice, the logic needs to be written into the very documents to define rules of deduction and inference between different types of documents, rules for query resolution, rules for conversion from unknown to known properties, rules for self-consistency, and so on. The logical layer thus requires the addition of predicate logic and quantification, in that order, to expand the simple statements possible in the previous layer. RDF Schema Sample Despite the wordy length, a selection of simple RDF schema samples might illustrate these conventions in their proper context. At the core is the W3C syntax specification, often referenced using the suggestive local prefix ‘rdf:’ when applying its terms: Languages and Protocols 137 <?xml version¼"1.0"?> <RDF xmlns¼"http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf¼"http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:s¼"http://www.w3.org/2000/01/rdf-schema#"> <!- This is the RDF Schema for the RDF data model as described in the Resource Description Framework Model and Syntax Specification http://www.w3.org/TR/REC-rdf-syntax - > <s:Class rdf:ID¼"Statement" s:comment¼"A triple consisting of a predicate, a subject, and an object." /> <s:Class rdf:ID¼"Property" s:comment¼"A name of a property, defining specific meaning for the property" /> <s:Class rdf:ID¼"Bag" s:comment¼"An unordered collection" /> <s:Class rdf:ID¼"Seq" s:comment¼"An ordered collection" /> <s:Class rdf:ID¼"Alt" s:comment¼"A collection of alternatives" /> <Property ID¼"predicate" s:comment¼"Identifies the property used in a statement when representing the statement in reified form"> <s:domain rdf:resource¼"#Statement" /> <s:range rdf:resource¼"#Property" /> </Property> <Property ID¼"subject" s:comment¼"Identifies the resource that a statement is describing when representing the statement in reified form"> <s:domain rdf:resource¼"#Statement" /> </Property> <Property ID¼"object" s:comment¼"Identifies the object of a statement when representing the statement in reified form" /> <Property ID¼"type" s:comment¼"Identifies the Class of a resource" /> <Property ID¼"value" s:comment¼"Identifies the principal value (usually a string) of a property when the property value is a structured resource" /> </RDF> This basic set of defined relational properties comprises just ten: Statement, Property, Bag, Seq, Alt, predicate, subject, object, type, and value. The container comment provides an 138 The Semantic Web informal definition for human readers (that is, progr ammers) who are setting up correspon- dences in other schemas using these standard items. A schema for defining basic book-related properties is found in a collection of Dublin Core draf t base schemas (it is nam ed dc.xsd at www.ukoln.ac.uk/metadata/dcmi/dcxml/ examples.html). It renders several pages in this book’s format, so it is listed for reference in Appendix A. A so-called ‘Simple DC’ application (using only the 15 elements in the ‘purl.org/dc/elements/1.1/namespace’) might import only this basic schema, yet be adequate for many metadata purposes. The namespace definitions provide the information required to interpret the elements. An excerpt from the ‘purl.org/dc/elements/1.1/namespace’, including the first property-container (for ‘title’, which follows the initial namespace description container) should be sufficient to show the principle: <?xml version¼"1.0" encoding¼"UTF-8"?> <!DOCTYPE rdf:RDF [ <!ENTITY rdfns ‘http://www.w3.org/1999/02/22-rdf-syntax-ns#’> <!ENTITY rdfsns ‘http://www.w3.org/2000/01/rdf-schema#’> <!ENTITY dens ‘http://purl.org/dc/elements/1.1/’> <!ENTITY dctermsns ‘http://purl.org/dc/terms/’> <!ENTITY dctypens ‘http://purl.org/dc/dcmitype/’> ]> <rdf:RDF xmlns:dcterms¼"http://purl.org/dc/terms/" xmlns:dc¼"http://purl.org/dc/elements/1.1/" xmlns:rdfs¼"http://www.w3.org/2000/01/rdf-schema#" xmlns:rdf¼"http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf: Description rdf: about¼"http: //purl. o rg/dc/elements/1.1/"> <dc:title xml:lang¼"en-US"> The Dublin Core Element Set v1.1 namespace providing access to its content by means of an RDF Schema </dc:title> <dc:publisher xml:lang¼"en-US"> The Dublin Core Metadata Initiative </dc:publisher> <dc:description xml:lang¼"en-US"> The Dublin Core Element Set v1.1 namespace provides URIs for the Dublin Core Elements v1.1. Entries are declared using RDF Schema language to support RDF applications. </dc:description> <dc:language xml:1ang¼"en-US">English</dc:language> <dcterms:issued>l999-07-02</dcterms:issued> <dcterms:modified>2003-03-2 4</dcterms:modified> <dc:source rdf:resource¼ "http://dublincore.org/documents/dces/"/> Languages and Protocols 139 <dc:source rdf:resource¼ "http://dublincore.org/usage/decisions/"/> <dcterms:isReferencedBy rdf:resource¼ "http://www.dublincore.org/documents/2001/10/26/dcmi- namespace/"/> <dcterms:isReguiredBy rdf:resource¼"http://purl.org/dc/terms/"/> <dcterms:isReferencedBy rdf:resource¼"http://purl.org/dc/demitype/"/> </rdf:Description> <rdf:Property rdf:about¼"http://purl.org/dc/elements/1.1/title"> <rdfs:label xml:lang¼"en-US">Title</rdfs:label> <rdfs:comment xml:lang¼"en-US">A name given to the resource.</rdfs:comment> <dc:description xml:lang¼"en-US"> Typically, a Title will be a name by which the resource is formally known.</dc:description> <rdfs:isDefinedBy rdf: resource¼"http: //purl. org/dc/elements/1.1/"/> <dcterms:issued>1999-07-02</dcterms:issued> <dcterms:modified>2002-10-0 4</dcterms:modified> <dc:type rdf:resource¼ "http://dublincore.org/usage/documents/principles/ #element"/> <dcterms:hasVersion rdf:resource¼ "http://dublincore.org/usage/terms/history/#title-004"/> </rdf:Property> This entry formally defines the DC Property ‘title’, with description and pointers to further resources that provide usage guidelines. Each of the other properties has a corresponding entry in the complete definition file. The previous examples show some variation in style and might seem off-putting in their length in relation to what they provide. The important point, however, is that they already exist as a Web resource. You do not have to write them all over again – just reference the resources and properties as needed in application RDF constructions. In any case, most of the tag verbosity in RDF definitions is generated automatically by the tools used to construct the RDF. How-to Adding RDF metadata to existing Web pages is actually rather simple. An example is given in Appendix A, right after the dc.xsd book schema mentioned earlier. The points to note are the addition of the about.xrdf file to establish provenance, and metadata blocks to affected existing pages. Optional steps leverage public-key technology to 140 The Semantic Web [...]... organized in the Semantic Web using special structures to represent property definitions and meaningful relationships Ontology Defined starts with an overview of what an ontology in the modern, computer-related sense is, and why it is an important concept The Semantic Web: Crafting Infrastructure for Agency Bo Leuf # 2006 John Wiley & Sons, Ltd 156 The Semantic Web Ontologies for the Web describes the aspects... ready-to-use ontologies are therefore valuable Web resources that promote moving specialized solutions into the Semantic Web The follow-up survey noted increased support for ontology languages built on RDF (OWL) and the use of URIs as identifiers for referring to unique entities At the same time, controversy exists whether RDF is in fact the best base language for implementing ontologies on the Web, or elsewhere... result might lead to the dereferencing of one or more other URIs, returning to the Web part for new requests Application can be varied For example, consider how someone might be granted access to a Web resource in the Semantic Web A document can be issued which explains to the Web server why that particular person should have access The underlying authority and authentication would then rest on a chain... meets the formal requirements and use cases mentioned earlier Many of its powerful and structured facilities have been recognized as so fundamental that they are incorporated into the new version of XPath (v2.0) So, what is the standard’ for QL applied to the Semantic Web? For several years, up to 2004, the verdict was ‘none yet’ Revisiting the scene in early 20 05, a W3C working draft suggested that for. .. aspects specific to the Web Ontology Types is an overview of different types of ontologies and their purpose, noting that they will vary depending on application and view Building Ontologies outlines a methodology for how ontologies are built Web Ontology Language describes the core W3C efforts to design OWL, a common generic ontology language for the Web Other Web Ontology Efforts samples a few... examples were examined in detail for both cases in the book Peer to Peer 6 Ontologies and the Semantic Web In the broader context of the Semantic Web, applications need to understand not just the human-readable presentation of content but the actual content – what we tend to call the meaning Such capability is not covered by the markup or protocols discussed so far Another layer of functionality is... tools and ontologies for specific user communities (particularly in the sciences and in company-specific e-commerce applications), they were not defined to be compatible with the architecture of the World Wide Web in general, and the Semantic Web in particular OWL is a semantic markup language for publishing and sharing ontologies on the Web, using URI notation and RDF technology, suitable for applications... not rely on the presence of a schema for storage or query Adding new information does not change the structure of the RDF database in any relational sense This invariance makes pure RDF databases very useful for prototyping and for other fast-moving data environments 148 The Semantic Web Figure 5. 10 Relationship between HTML, XML and possible rule markup in terms of subsequent processing of Web- published... process the information in other ways (for example, to determine the relationship between the siblings Page2 and Page3) Figure 5. 9 A DLG representation of a Web page that links to other pages Languages and Protocols 143 Note that all the information is here given as relationships From a certain point of view, RDF is just a special instance of DLG – you can map all the relationships as a graph Many of the. .. defined, and specified The resulting structure forms a complete set with formally defined relationships, one element to another, which provides the semantic basis for the terminology On the other hand, ontologies include richer relationships between terms than the simply taxonomic contribution to the semantics These relationships enable the expression of domain-specific knowledge without requiring domain-specific . the informat ion in other ways (for example, to determine the relationship between the siblings Page2 and Page3). Figure 5. 9 A DLG representation of a Web page that links to other pages 142 The. from the Web by sampling, conversion, and indexing methods. In the Semantic Web, on the other hand, queries should primarily trigger resource discovery and seek information directly from the Web. other rules, before selecting a course of action. The result might lead to the dereferencing of one or more other URIs, returning to the Web part for new requests. Application can be varied. For