You are previewing Semantic Web Programming.
O'Reilly logo
Semantic Web Programming

Book Description

The next major advance in the Web Web 3.0 will be built on semantic Web technologies, which will allow data to be shared and reused across application, enterprise, and community boundaries. Written by a team of highly experienced Web developers, this book explains examines how this powerful new technology can unify and fully leverage the ever-growing data, information, and services that are available on the Internet. Helpful examples demonstrate how to use the semantic Web to solve practical, real-world problems while you take a look at the set of design principles, collaborative working groups, and technologies that form the semantic Web. The companion Web site features full code, as well as a reference section, a FAQ section, a discussion forum, and a semantic blog.

Table of Contents

  1. Copyright
  2. About the Authors
    1. About The Technical Editors
  3. Credits
  4. Acknowledgments
  5. Foreword
  6. Introduction
    1. Overview of the Book and Technology
    2. How This Book Is Organized
    3. Who Should Read This Book
    4. Tools You Will Need
    5. What's on the Website
    6. Summary (From Here, Up Next, and So On)
  7. I. Introducing Semantic Web Programming
    1. 1. Preparing to Program a Semantic Web of Data
      1. 1.1. Defining the Semantic Web
      2. 1.2. Identifying the Major Programming Components
      3. 1.3. Determining Impacts on Programming
        1. 1.3.1. Establishing a Web Data–Centric Perspective
        2. 1.3.2. Expressing Semantic Data
        3. 1.3.3. Sharing Data
        4. 1.3.4. Making Data Dynamic and Flexible
      4. 1.4. Avoiding the Roadblocks, Myths, and Hype
        1. 1.4.1. Semantic Web Roadblocks
        2. 1.4.2. Semantic Web Myths
        3. 1.4.3. Semantic Web Hype
      5. 1.5. Understanding Semantic Web Origins
      6. 1.6. Exploring Semantic Web Examples
        1. 1.6.1. Semantic Wikis (semantic-mediawiki.org)
        2. 1.6.2. Twine (www.twine.com)
        3. 1.6.3. The FOAF Project (www.foaf-project.org)
        4. 1.6.4. RDFa and Microformats
        5. 1.6.5. Semantic Query Endpoint (dbpedia.org/sparql)
        6. 1.6.6. Semantic Search (www.trueknowledge.com)
      7. 1.7. Summary and Onward
      8. 1.8. Notes
    2. 2. Hello Semantic Web World
      1. 2.1. Setting Up Your Semantic Web Development Environment
      2. 2.2. Programming the Hello Semantic Web World Application
      3. 2.3. Summary
  8. II. Foundations of Semantic Web Programming
    1. 3. Modeling Information
      1. 3.1. Modeling Information in Software
        1. 3.1.1. Sharing Information: Syntax and Semantics
          1. 3.1.1.1. Serialized Objects
          2. 3.1.1.2. Relational Databases
          3. 3.1.1.3. Extensible Markup Language (XML)
        2. 3.1.2. Metadata and Data in Information Sharing
      2. 3.2. The Semantic Web Information Model: The Resource Description Framework (RDF)
        1. 3.2.1. Nodes: Resources and Literals
        2. 3.2.2. Edges: Predicates
      3. 3.3. Exchanging Information with RDF
        1. 3.3.1. Statements as Points
        2. 3.3.2. RDF Serializations
          1. 3.3.2.1. RDF/XML
            1. 3.3.2.1.1. Comments
            2. 3.3.2.1.2. Statements
            3. 3.3.2.1.3. Resources
            4. 3.3.2.1.4. Literals
            5. 3.3.2.1.5. Shorthand and Special Features
          2. 3.3.2.2. Terse RDF Triple Language (Turtle)
            1. 3.3.2.2.1. Comments
            2. 3.3.2.2.2. Statements
            3. 3.3.2.2.3. Resources
            4. 3.3.2.2.4. Literals
            5. 3.3.2.2.5. Shorthand and Special Features
          3. 3.3.2.3. N-Triples
          4. 3.3.2.4. Quick Hack
        3. 3.3.3. More RDF
          1. 3.3.3.1. Blank Nodes
          2. 3.3.3.2. Reification
          3. 3.3.3.3. RDF Organizational Constructs
            1. 3.3.3.3.1. RDF Containers
            2. 3.3.3.3.2. RDF Lists
      4. 3.4. Summary
    2. 4. Incorporating Semantics
      1. 4.1. Semantics on the Web
        1. 4.1.1. Motivating Factors
          1. 4.1.1.1. Understanding the World Wide Web
          2. 4.1.1.2. Knowledge Domain Integration
        2. 4.1.2. Expressing Semantics in RDF
          1. 4.1.2.1. Vocabularies, Taxonomies, and Ontologies
          2. 4.1.2.2. A Vocabulary Language for RDF
          3. 4.1.2.3. An Ontology Language for the Web
      2. 4.2. Introduction to Ontologies
        1. 4.2.1. Distributed Knowledge
          1. 4.2.1.1. Open World Assumption
          2. 4.2.1.2. No Unique Names Assumption
        2. 4.2.2. Overview of Ontology Elements
          1. 4.2.2.1. Ontology Header
          2. 4.2.2.2. Classes and Individuals
          3. 4.2.2.3. Properties
          4. 4.2.2.4. Annotations
          5. 4.2.2.5. Datatypes
      3. 4.3. Elements of an Ontology
        1. 4.3.1. OWL 2 Typing
        2. 4.3.2. Ontology Header
        3. 4.3.3. Annotations
        4. 4.3.4. Basic Classification
          1. 4.3.4.1. Classes and Individuals
          2. 4.3.4.2. rdfs:SubClassOf
          3. 4.3.4.3. Instance versus Subclass
          4. 4.3.4.4. owl:Thing and owl:Nothing
        5. 4.3.5. Defining and Using Properties
        6. 4.3.6. Property Domain and Range
        7. 4.3.7. Describing Properties
          1. 4.3.7.1. rdfs:subPropertyOf
          2. 4.3.7.2. Top and Bottom Properties
          3. 4.3.7.3. Inverse Properties
          4. 4.3.7.4. Disjoint Properties
          5. 4.3.7.5. Property Chains
          6. 4.3.7.6. Symmetric, Reflexive, and Transitive Properties
          7. 4.3.7.7. Functional and Inverse Functional Properties
          8. 4.3.7.8. Keys
        8. 4.3.8. Datatypes
          1. 4.3.8.1. Datatype Restrictions
          2. 4.3.8.2. Defining Datatypes in Terms of Other Datatypes
        9. 4.3.9. Negative Property Assertions
        10. 4.3.10. Property Restrictions
          1. 4.3.10.1. Value Restrictions
          2. 4.3.10.2. Cardinality Restrictions
          3. 4.3.10.3. Qualified Cardinality Restrictions
        11. 4.3.11. Advanced Class Description
          1. 4.3.11.1. Enumerating Class Membership
          2. 4.3.11.2. Set Operators
          3. 4.3.11.3. Disjoint Classes
        12. 4.3.12. Equivalence in OWL
          1. 4.3.12.1. Equivalence among Individuals
          2. 4.3.12.2. Equivalence among Classes and Properties
      4. 4.4. Summary
    3. 5. Modeling Knowledge in the Real World
      1. 5.1. Exploring the Components of the Semantic Web
        1. 5.1.1. Semantic Web Frameworks
        2. 5.1.2. Storing and Retrieving RDF
          1. 5.1.2.1. RDF Store Implementations
          2. 5.1.2.2. Retrieving Information in a Knowledgebase
        3. 5.1.3. Realizing the Semantics of OWL
          1. 5.1.3.1. Understanding Forward Chaining Inference
          2. 5.1.3.2. Understanding Backward Chaining Inference
          3. 5.1.3.3. Choosing the Right Inference Method
        4. 5.1.4. Common Frameworks and Components
          1. 5.1.4.1. RDF Store Implementations
          2. 5.1.4.2. Retrieval Components
          3. 5.1.4.3. Reasoning Engines
        5. 5.1.5. Knowledgebase Performance
      2. 5.2. Exploring the Profiles of OWL
        1. 5.2.1. OWL Full and OWL DL
        2. 5.2.2. The Profiles of OWL
          1. 5.2.2.1. OWL EL
          2. 5.2.2.2. OWL QL
          3. 5.2.2.3. OWL RL
      3. 5.3. Demonstrating OWL Inference
        1. 5.3.1. The Ontology
        2. 5.3.2. The Example Application
        3. 5.3.3. The Results
          1. 5.3.3.1. Performing No Inference
          2. 5.3.3.2. Performing RDFS Inference
          3. 5.3.3.3. Performing OWL Inference
      4. 5.4. Working with Ontologies
        1. 5.4.1. Decoupling the Knowledge Model from the Application
        2. 5.4.2. Sharing across Domain and Application Boundaries
        3. 5.4.3. What Is a Foundational Ontology?
        4. 5.4.4. Common Foundational Ontologies
          1. 5.4.4.1. BFO
          2. 5.4.4.2. Cyc and OpenCyc
          3. 5.4.4.3. DOLCE
          4. 5.4.4.4. SUMO
          5. 5.4.4.5. Dublin Core Metadata Initiative
          6. 5.4.4.6. FOAF
          7. 5.4.4.7. GeoRSS and OWL-Time
        5. 5.4.5. Finding Ontologies to Reuse or Extend
        6. 5.4.6. Choosing the Right Foundational Ontologies
      5. 5.5. Summary
    4. 6. Discovering Information
      1. 6.1. Navigating the Semantic Web
      2. 6.2. Searching the Semantic Web
      3. 6.3. Querying the Semantic Web
        1. 6.3.1. Quickstart with SPARQL
        2. 6.3.2. Four Foundational Query Forms
        3. 6.3.3. SELECT Essentials
        4. 6.3.4. RDF Datasets, FROM and FROM NAMED
        5. 6.3.5. Query Modifiers
          1. 6.3.5.1. DISTINCT
          2. 6.3.5.2. REDUCED
          3. 6.3.5.3. ORDER BY
          4. 6.3.5.4. Data Streaming with OFFSET and LIMIT
          5. 6.3.5.5. Flexible Querying with FILTER and OPTIONAL
          6. 6.3.5.6. FILTER
          7. 6.3.5.7. OPTIONAL
          8. 6.3.5.8. UNION
        6. 6.3.6. CONSTRUCT Essentials
        7. 6.3.7. DESCRIBE Essentials
        8. 6.3.8. ASK Essentials
        9. 6.3.9. SPARQL Entailment
        10. 6.3.10. Unsupported Functionality
          1. 6.3.10.1. Data Modification
          2. 6.3.10.2. Subqueries
          3. 6.3.10.3. Aggregation
      4. 6.4. Summary
    5. 7. Adding Rules
      1. 7.1. What Are Rules?
      2. 7.2. Reasons for Rules
        1. 7.2.1. No Support for Property Composition
        2. 7.2.2. Use of Built-ins
        3. 7.2.3. Ontological Mediation
        4. 7.2.4. Limiting Assumptions
      3. 7.3. Rule Languages
      4. 7.4. SWRL Essentials
        1. 7.4.1. The Abstract Syntax
        2. 7.4.2. The XML Concrete Syntax
          1. 7.4.2.1. var
          2. 7.4.2.2. imp
          3. 7.4.2.3. _rlab
          4. 7.4.2.4. _body
          5. 7.4.2.5. _head
          6. 7.4.2.6. classAtom
          7. 7.4.2.7. datarangeAtom
          8. 7.4.2.8. individualPropertyAtom
          9. 7.4.2.9. datavaluedPropertyAtom
          10. 7.4.2.10. sameIndividualAtom
          11. 7.4.2.11. differentIndividualsAtom
          12. 7.4.2.12. builtinAtom
        3. 7.4.3. The RDF Concrete Syntax
        4. 7.4.4. Built-ins
          1. 7.4.4.1. Examples
        5. 7.4.5. DL-Safe Rules
        6. 7.4.6. Ontological Mediation
          1. 7.4.6.1. Mapping Friends without Upsetting Any of Them
          2. 7.4.6.2. The Power of Rules
      5. 7.5. Jena Rules
      6. 7.6. Rule Interchange Format
        1. 7.6.1. Delving into the Details
        2. 7.6.2. The Future of RIF
      7. 7.7. Summary
  9. III. Building Semantic Web Applications
    1. 8. Applying a Programming Framework
      1. 8.1. Framing the Semantic Web
      2. 8.2. The Jena Semantic Web Framework
        1. 8.2.1. Defining Jena Programming Concepts
      3. 8.3. Programming with Jena
        1. 8.3.1. Establishing the Jena Development Environment
        2. 8.3.2. Establishing the Knowledgebase: Setting Up the Model
        3. 8.3.3. Populating the Model with Semantic Web Data
        4. 8.3.4. Combining Semantic Web Data
        5. 8.3.5. Interrogating Semantic Web Data
        6. 8.3.6. Reasoning across Semantic Web Data
        7. 8.3.7. Exporting Semantic Web Data
        8. 8.3.8. Deallocating Semantic Web Data Resources
        9. 8.3.9. Managing Semantic Web Data
          1. 8.3.9.1. Getting Information Regarding Your Semantic Web Data
          2. 8.3.9.2. Generating Events Based on Semantic Web Data
          3. 8.3.9.3. Dealing with Concurrency and Your Semantic Web Data
          4. 8.3.9.4. Customizing the Jena Framework
          5. 8.3.9.5. Serializing Semantic Web Data
      4. 8.4. Common App Overview: FriendTracker
      5. 8.5. Summary
    2. 9. Combining Information
      1. 9.1. Combining Information
        1. 9.1.1. Representing Information
        2. 9.1.2. Translating between Representations
        3. 9.1.3. Addressing the Challenges of Translation
          1. 9.1.3.1. Maintaining Fidelity
          2. 9.1.3.2. Tracking Provenance Information
          3. 9.1.3.3. Reversing the Process
          4. 9.1.3.4. Handling Varying Data
          5. 9.1.3.5. Managing Data Volume
        4. 9.1.4. Introducing the FriendTracker Data Sources
          1. 9.1.4.1. Facebook XML Web Service
          2. 9.1.4.2. Jabber Java Client
          3. 9.1.4.3. Upcoming.org XML Web Service
          4. 9.1.4.4. WordPress Relational Database
      2. 9.2. Exposing XML-Based Web Services as RDF
        1. 9.2.1. Introducing the Weather.gov XML Feed
        2. 9.2.2. Exposing XML Using XSL Transformations
          1. 9.2.2.1. Traversing XML Documents with XPath
          2. 9.2.2.2. Applying XSLT to a Simple Example
          3. 9.2.2.3. Processing XML and XSLT Programmatically
          4. 9.2.2.4. Applying XSLT to the Facebook Data Source
          5. 9.2.2.5. Weighing the Benefits and the Costs of XSLT
        3. 9.2.3. Exposing XML Using XML Bindings and Velocity
          1. 9.2.3.1. Generating Java Bindings for XML Data
          2. 9.2.3.2. Unmarshalling XML Data into Java
          3. 9.2.3.3. Introducing the Velocity Template Engine
          4. 9.2.3.4. Generating RDF with Velocity
          5. 9.2.3.5. Weighing the Benefits and the Costs
      3. 9.3. Exposing Relational Databases as RDF
        1. 9.3.1. Exposing a WordPress Blog Using D2RQ
          1. 9.3.1.1. Creating D2RQ Mappings for the WordPress Database
          2. 9.3.1.2. Wrapping the D2RQ Instance in a Jena Model
          3. 9.3.1.3. Querying the D2RQ Exposed WordPress Database
          4. 9.3.1.4. Weighing the Benefits and the Costs of D2RQ
      4. 9.4. Exposing Other Sources of Data
        1. 9.4.1. Exposing Jabber with a Custom Streaming RDF Writer
        2. 9.4.2. Exposing Java Objects Using Reflection
          1. 9.4.2.1. Applying the RDF Generator to the Weather.gov XML Feed
          2. 9.4.2.2. Applying the RDF Generator to the Upcoming.org XML Feed
      5. 9.5. Summary
    3. 10. Aligning Information
      1. 10.1. Data Source, Domain, and Application Ontologies
      2. 10.2. Aligning Ontologies
        1. 10.2.1. Ontology Constructs
        2. 10.2.2. Translation via Rules
        3. 10.2.3. Explicit Translation
        4. 10.2.4. Ad Hoc Approaches to Translation
      3. 10.3. FriendTracker
        1. 10.3.1. Aligning Ontologies with OWL and SWRL
        2. 10.3.2. Aligning Ontologies with XSLT
        3. 10.3.3. Aligning Ontologies with Code
        4. 10.3.4. Aligning Simple Ontologies with RDFS
      4. 10.4. Record Linkage
      5. 10.5. Summary
    4. 11. Sharing Information
      1. 11.1. Microformats
      2. 11.2. eRDF
      3. 11.3. RDFa
        1. 11.3.1. Supported Attributes
          1. 11.3.1.1. xmlns
          2. 11.3.1.2. rel
          3. 11.3.1.3. rev
          4. 11.3.1.4. content
          5. 11.3.1.5. href
          6. 11.3.1.6. src
          7. 11.3.1.7. about
          8. 11.3.1.8. property
          9. 11.3.1.9. resource
          10. 11.3.1.10. datatype
          11. 11.3.1.11. typeof
        2. 11.3.2. Blank Nodes
        3. 11.3.3. Language Support
      4. 11.4. Tools and Frameworks
        1. 11.4.1. RDF Transformational Tools
        2. 11.4.2. SPARQL Endpoints
          1. 11.4.2.1. Joseki Installation and Operation
        3. 11.4.3. xOperator
          1. 11.4.3.1. Installation and Operation
          2. 11.4.3.2. Example Query
      5. 11.5. FriendTracker in RDFa
      6. 11.6. Summary
  10. IV. Expanding Semantic Web Programming
    1. 12. Developing and Using Semantic Services
      1. 12.1. Background
        1. 12.1.1. Discovery
        2. 12.1.2. Invocation
        3. 12.1.3. Negotiation
        4. 12.1.4. Error Handling
        5. 12.1.5. Monitoring
        6. 12.1.6. Composition
      2. 12.2. Implementing Semantic Services
      3. 12.3. Semantic Markup for Web Services
        1. 12.3.1. ServiceProfile
        2. 12.3.2. ServiceModel
        3. 12.3.3. ServiceGrounding
      4. 12.4. Web Service Modeling Ontology
      5. 12.5. Semantic Annotations for WSDL
        1. 12.5.1. SAWSDL Example
        2. 12.5.2. SAWSDL Tools
      6. 12.6. Summary
    2. 13. Managing Space and Time
      1. 13.1. Space and Time in Software
        1. 13.1.1. Spatial Information
        2. 13.1.2. Temporal Information
      2. 13.2. Representing Spatiotemporal Data on the Semantic Web
      3. 13.3. Spatial and Temporal Software with Jena
        1. 13.3.1. Working with Spatial Data
        2. 13.3.2. Example: Spatial Queries
          1. 13.3.2.1. Framing the Problem
          2. 13.3.2.2. Approach and Rationale
          3. 13.3.2.3. Components
        3. 13.3.3. Example: Transaction Time–Bounded Queries
          1. 13.3.3.1. Framing the Problem
          2. 13.3.3.2. Approach and Rationale
          3. 13.3.3.3. Components
      4. 13.4. Summary
      5. 13.5. Notes
    3. 14. Semantic Web Patterns and Best Practices
      1. 14.1. Aggregating Disparate Data Sources
        1. 14.1.1. Exposing Data Sources as RDF
        2. 14.1.2. Bringing Data into the Domain Knowledge Model
        3. 14.1.3. Storing Information in the Knowledgebase
        4. 14.1.4. Initiating the Flow of Data
      2. 14.2. Annotating Unstructured Data
        1. 14.2.1. Annotation Management
        2. 14.2.2. Ontology Management
        3. 14.2.3. Unstructured Data Sources and the Client Application
      3. 14.3. Coordinating Semantic Services
      4. 14.4. Applying Semantic Web Best Practices
        1. 14.4.1. Creating URIs
          1. 14.4.1.1. Making URIs Unique
          2. 14.4.1.2. Making URIs Consistent
          3. 14.4.1.3. Making URIs Resolvable
        2. 14.4.2. Specifying Units of Measurement
          1. 14.4.2.1. Unit-Specific Properties and Datatypes
          2. 14.4.2.2. Statement Reification
          3. 14.4.2.3. Value Containers
        3. 14.4.3. Representing N-ary Relationships
        4. 14.4.4. Managing Bad Data
      5. 14.5. Summary
    4. 15. Moving Forward
      1. 15.1. Advancing Ontologies
        1. 15.1.1. Ontology Repositories and Registries
        2. 15.1.2. Linked Data
        3. 15.1.3. Versioning
        4. 15.1.4. Ontology Metrics
      2. 15.2. Advancing Integration
        1. 15.2.1. Semantic Pipes
        2. 15.2.2. Distributed Queries
        3. 15.2.3. Alignment
      3. 15.3. Advancing Reasoning
        1. 15.3.1. Rule Interchange Format (RIF)
        2. 15.3.2. Probabilistic Reasoning
        3. 15.3.3. Trust: Proof Markup Language
        4. 15.3.4. LarKC: The Large Knowledge Collider
      4. 15.4. Advancing Visualization
      5. 15.5. Summary
  11. A. RDF
    1. A.1. Reification
    2. A.2. Containers
  12. B. The OWL Web Ontology Language
    1. B.1. Annotation Properties
    2. B.2. Individuals
    3. B.3. Classes
    4. B.4. Properties
    5. B.5. Datatypes
    6. B.6. Property Restrictions
  13. C. SWRL
    1. C.1. SWRL Examples
      1. C.1.1. RDF concrete syntax:
      2. C.1.2. Turtle:
    2. C.2. Namespaces
    3. C.3. Built-ins
      1. C.3.1. Comparisons, Booleans
      2. C.3.2. Mathematics
      3. C.3.3. Strings
      4. C.3.4. Date, Time, Duration
      5. C.3.5. URIs
      6. C.3.6. Lists
    4. C.4. Keywords
  14. D. SPARQL
    1. D.1. SPARQL Examples
    2. D.2. Operators
      1. D.2.1. Unary Operators
      2. D.2.2. Binary Operators
      3. D.2.3. Trinary Operators
    3. D.3. Keywords
  15. E. Jena Reference Guide
    1. E.1. Key Jena Classes
      1. E.1.1. DIGReasoner Class
      2. E.1.2. DIGReasonerFactory Class
      3. E.1.3. Graph Interface
      4. E.1.4. IDBConnection Interface
      5. E.1.5. InfModel Interface
      6. E.1.6. Model Interface
      7. E.1.7. ModelFactory Class
      8. E.1.8. ModelMaker Interface
      9. E.1.9. OntModelSpec Class
      10. E.1.10. Query Class
      11. E.1.11. QueryExecution Interface
      12. E.1.12. QuerySolution Interface
      13. E.1.13. ObjectListener Class
      14. E.1.14. OntClass Interface
      15. E.1.15. OntModel Interface
      16. E.1.16. Ontology Interface
      17. E.1.17. OntProperty Interface
      18. E.1.18. OntResource Interface
      19. E.1.19. RDFNode Interface
      20. E.1.20. Reasoner Interface
      21. E.1.21. Resource Interface
      22. E.1.22. ResultSet Interface
      23. E.1.23. Statement Interface
      24. E.1.24. StmtIterator Interface
      25. E.1.25. ValidityReport Interface
    2. E.2. Main Programming Steps
      1. E.2.1. Establishing the Model
      2. E.2.2. Populating the Model
      3. E.2.3. Querying the Model
      4. E.2.4. Binding a Reasoner to the Model
      5. E.2.5. Exporting the Model
  16. F. Installation Reference Guide
    1. F.1. D2RQ: Conversion from Relational Database to Jena Model
    2. F.2. Eclipse Integrated Development Environment
    3. F.3. Java Classpath
    4. F.4. JAXB-RI
    5. F.5. Jena Semantic Web Framework
    6. F.6. JDBC Driver for MySQL
    7. F.7. Pellet Reasoner
    8. F.8. Protégé Ontology Editor
    9. F.9. Tar/Gzipped Files
    10. F.10. Velocity: GUI Templates