Using Altova s SemanticWorks


Using Altova's SemanticWorks

One RDF tool out there is Altova's SemanticWorks (found at http://www.altova.com). This tool allows you to work with an RDF document as either a graph or as XML. Altova's SemanticWorks is a good way to visually design your RDF document. Using it, you can later look at the underlying RDF schema that was created by the tool around your graph.

Using this tool with the previous Ernest Hemingway example, you can visually create what is presented in Figure 24-8.

image from book
Figure 24-8

In this figure, you can see that the tool provides a good visual representation of the RDF model. You can see a number of statements defined. Note there is even a statement contained within a statement. Again, the statements are defined with the dashed, squared boxes that always surround a triples statement.

This example shows a complete RDF graph. You can use this designer to create a brand new graph from scratch. The first step is to open up Altova's SematicWorks and modify the document to work in RDF mode. You simply set the drop-down box in the menu to RDF as shown in Figure 24-9.

image from book
Figure 24-9

Next, you set up a namespace prefix to use in the RDF document. Select Tools image from book URIref Prefixes. The URIref Prefixes dialog (presented in Figure 24-10) pops up. This dialog enables you to create the prefixes that are used in the document.

image from book
Figure 24-10

To add a new prefix, click the Add button in the dialog and a new prefix line is added to the list. For this example, type the prefix ex in the Prefix column and provide a URI in the second column. In this case, you can use http://www.example.org/ as the URI of the ex prefix. Next, click the OK button to continue with the construction of the RDF document.

You see a Resources tab on the RDF document with a single toolbar strip at the top. In the toolbar strip, you find a single button. Clicking this button enables you to add a new resource to the RDF document as illustrated in Figure 24-11.

image from book
Figure 24-11

To add a new resource to your RDF document, click the button in the toolbar and select Add resource from the provided menu. You then see that a line has been added to the list box where you can type the name of resource you want. At first, the resource has the name urn:unnamed-1. You must rename this resource. For the first resource, use the following definition on the resource line:

      ex:Ernest_Hemingway 

In this case, ex: is the prefix of the resource. This ex value maps back to the URI you defined in the URIref Prefixes dialog earlier in the example. After you have associated the resource to the prefix you want (because you can have more than one custom prefix), you then type the name of the resource. In this case, the name of the resource is Ernest_Hemingway (with the underscore). The following is an incorrect value:

      ex:Ernest Hemingway 

This is incorrect because of the space between the words Ernest and Hemingway. The name that is placed here is actually used in the namespace value within the XML RDF document. For instance, if you use the correct form: ex:Ernest_Hemingway, you get the following namespace value:

http://www.example.org/Ernest_Hemingway

This works, of course, because it is a properly structured value (being a continuous string). If you put a space between Ernest and Hemingway, the following URI results:

http://www.example.org/ErnestHemingway

This, of course, is invalid because it is in two parts.

Now you have a resource in place within your RDF document. The resource list must also include all the pieces of the triples-all the subjects, predicates, and objects. Complete your list using the following resource values:

  • q ex:Ernest_Hemingway

  • q ex:The_Sun_Also_Rises

  • q ex:Charles_Scribners_Sons

  • q ex:was_published_by

  • q ex:wrote_a_book

After these five items in place within Altova's SemanticWorks, you should see something similar to the screen shown in Figure 24-12.

image from book
Figure 24-12

In this example, you can see that all five resources are listed in the document. The list is presented alphabetically. Although the resources exist within the document, no relationship exists between the items. In order to create these relationships, which are the core of the RDF document, you use the SemanticWorks tool. To access the tool, press the icon to the left of the ex:Ernest_Hemingway resource. This brings up a visual representation of the resource. The resource is presented as a bubble on the design surface and is labeled with its URI. This is shown in Figure 24-13.

image from book
Figure 24-13

Looking at Figure 24-13, you can see that a little more is going on. You see the ex:Ernest_Hemingway resource and also the start of the creation of a relationship. The first step in creating a relationship with this resource is adding a predicate. Because the ex:Ernest_Hemingway resource is, in fact, a subject, the next step is to add a predicate that can act upon an object (the object is added after the predicate is created).

To associate a predicate to this subject, right-click on the ex:Ernest_Hemingway bubble and select Add Predicate from the provided menu. This creates a box next to the ex:Ernest_Hemingway resource. After the predicate is added, the predicate box has a drop-down list that can be initiated by clicking the arrow button within the box. This is illustrated in Figure 24-14.

image from book
Figure 24-14

You now select the appropriate predicate from the list. In this case, the appropriate choice is the ex:wrote_a_book option. Now that the ex:Ernest_Hemingway subject has an associated predicate, you associate this predicate with an object. To accomplish this task, right-click the predicate and select Add Resource Object from the provided menu. This is illustrated in Figure 24-15.

image from book
Figure 24-15

In the example in Figure 24-15, a new object is added to the predicate. The object behaves just as the predicate behaved when it was added to the diagram. A bubble which represents the object appears on the screen, and you are provided with a dropdown list to choose the object from the list of resources that you defined earlier. In this case, you select the ex:The_Sun_Also_Rises option from the list of options presented in the drop-down list.

With these three items in place, you have created your first triples. You have a subject, predicate, and an object all related through a relationship you defined. This is as far as you can go here. You must also define statements in succession and relate the statements through the joint use of subjects and objects. For instance, you cannot define another predicate by clicking the object ex:The_Sun_Also_Rises in the design surface. Instead, you go back to your resource list by clicking the small button located at the upper- left corner of the design surface. After you are back to the resource list (shown earlier in Figure 24-12), you can click the icon next to the ex:The_Sun_Also_Rises resource to further define it. In the first statement that you created, the ex:The_Sun_Also_Rises resource was the object, but in the next case, this resource is the only one found on the design surface and is in the left-most position-signifying that it is now the subject of the statement. From this point in the design surface, you simply right-click the new resource and select Add Predicate from the menu provided-just as you did before with the ex:Ernest_Hemingway resource.

In this case, your predicate is ex:was_published_by, and the object of this statement is ex:Charles_ Sribners_Sons. With this relationship in place, you have built two statements which are related through their common use of the ex:The_Sun_Also_Rises resource.

If you go back to the ex:Ernest_Hemingway resource in design view, you can expand all the nodes until you get the result presented in Figure 24-16.

image from book
Figure 24-16

In this example, the ex:Ernest_Hemingway statement is connected to the ex:The_Sun_Also_Rises statement though the relations that you defined earlier. You can see that the ex:The_Sun_Also_Rises statement is a full statement with a subject, predicate, and object because it is surrounded with a dashed box.

Now that you have designed this RDF document completely within Altova's SemanticWorks application, you can view the XML behind this RDF graph. To do this, click the Text button within the tool. This switches the view from the RDF graph view to the XML text view. The XML view is illustrated in Figure 24-17.

image from book
Figure 24-17

The next section looks more closely at creating RDF documents using XML rather than graph design.




Professional XML
Professional XML (Programmer to Programmer)
ISBN: 0471777773
EAN: 2147483647
Year: 2004
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net