programming with OWL API

-What is OWLAPI -Why we need OWL API -How can we use OWP API -Example

Prototype Autocomplete

Prototype is a JavaScript framework that makes web development a lot easier.
You can download it at www.prototypejs.org

You can use prototype to create an AutoComplete input box:

At first you'll need to include prototype into your website:

<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="autocomplete.js"></script>

Now create an input box

<input type="text" name="q" id="query" />

and an instance of your Autocomplete object:

<script type="text/javascript">
new Autocomplete('query', { serviceUrl:'service/autocomplete.ashx' });

If you want, you can add further options:

new Autocomplete('query', {
// callback function:
onSelect: function(value, data){
alert('You selected: ' + value + ', ' + data);

autocomplete.ashx will receive the GET request with the querystring ?query=Know - it must return JSON data as follows:

suggestions:['Knowledge Management','Knowing','Know How'],

Using Java to read an XML file

The DOM is a W3C (World Wide Web Consortium) standard. The DOM defines a standard for accessing documents like XML and HTML:"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document." </br> The DOM is separated into 3 different parts / levels: </br> Core DOM - standard model for any structured document </br> XML DOM - standard model for XML documents </br> HTML DOM - standard model for HTML documents </br> The DOM defines the objects and properties of all document elements, and the methods (interface) to access them. Write a program to read the content of an XML file using DOM parser.

Navigation, Predicates and Functions in XPath

<strong>Write the following XPath queries for the document finance.xml: </strong> • head of all articles between the 4th and the 9th of May • The first and the third article of Alliance & Leicester • The depth of the XML document (Hint: XPath2 usage) • Explain why the query //head[2] returns a different result to descendant::head[2], and how the results look like for this particular example file </br> <p> </strong>Get the maximum and minimum of the values in values.xml </strong> • Try first to do it in XPath1 (trick: use negation of existential comparison) • Write an XPath2 query that iterates over the numbers 1 to 12 and returns the square product of each number • Return the concatenated textual value of all the child elements of the element data in text.xml. Further, remove all non-breakable spaces that are used in the concatenated text. And normalize/trim the white-spaces finally . </p> The files <cite>finance,values</cite> can be found in the attachment.

Make the Navigation Menu user specific

For a workflow application serveral user types are defined. In general, depending on their roles, users have different rights. In particular the navigation menu must be user specific (e.g. some users may have write access, others only read access ).

Get JAX-B to work with circular dependencies.

When serializing objects that have circular dependencies with JAX-B the framework throws a CyclicDependencyDetected exception. For example there are two classes A and B. Class A has a property x of type B and class B has a list y of As. Using the annotations <code>@XmlElementRef B x</code> in class A and <code>@XmlWrapperElement("ys") @XmlElementRef List&lt;A> y</code> in class B will throw the aforementioned exception. How to serialize object graphs like these?

Get JAX-WS to work with duplicate xsd:types

When writing a SOAP webservice using JAX-WS using NO explicit namespace declarations on the model and you have the following constellation: a webservice with a method named "order", a model class with the name "Order" the JAX-WS processor (e.g. Apache CXF) will complain because there are two XSD types referring to two different things. The webservice looks like this: <code>@WebService(...) public class WS { @WebMethod public void order(Order o); }</code> And the model like this: <code>@XmlRootElement public class Order { ... }</code> How can you work around this without using explicit namespace declarations and renaming the class or method?

Using dapper to create our own content

To create a custom content from various website, we can use dapper from http://open.dapper.net/
1. click create a new Dapp
2. enter one of the url from the website that you want in the box, click "Next Step"
3. once the page is loaded, do anything you want (for example: enter the keyword in the search criteria). After the webpage show information that you want, click "Add to Basket".
4. Enter a new url, and do the same thing with point 3, click "Add to Basket". Your Dapp will work better with 2 or more sample url
5. Click "Next Step"
6. Select the content that you want to be displayed in you custom content. For example: select the name of thet product, detail information, and the price in the online shop or select the header of the news, the pictures, and the news in the news website. Give a name for each content.
7. You can also group the content if you want.
8. Preview the result. You can also go back to the previous step if you want.
9. Save you dapp.
10. Finish. Save the url that Dapper give you. You can also visit your custom content with that link/url.


Creating custom content from various website

Sometimes we want to organize the information from several different website so that it become easier for us. For example: compare the price of a product from many different on line shops, browse pictures from many different websites, read news from many different news website, and so on.

Using AJAX to load XML contents dynamically to XHTML websites

First we are going to create a standard HTML form with two input fields: Name and Time. The "Name" field will be filled out by the user, and the "Time" field will be filled out with AJAX.The HTML file will be named "testAjax.htm", and it looks like this (notice that the HTML form below has no submit button!):<html><body><form name="myForm">Name: <input type="text" name="username" />Time: <input type="text" name="time" /></form></body></html>The keystone of AJAX is the XMLHttpRequest object.All new browsers use the built-in JavaScript XMLHttpRequest object to create an XMLHttpRequest object (IE5 and IE6 uses an ActiveXObject).Let's update our "testAjax.htm" file with a JavaScript that creates an XMLHttpRequest object:<html><body><script type="text/javascript">function ajaxFunction(){var xmlhttp;if (window.XMLHttpRequest)  {  // code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else if (window.ActiveXObject)  {  // code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }else  {  alert("Your browser does not support XMLHTTP!");  }}</script><form name="myForm">Name: <input type="text" name="username" />Time: <input type="text" name="time" /></form></body></html>Example explained1. Create a variable named xmlhttp to hold the XMLHttpRequest object.2. Try to create the XMLHttpRequest object with xmlhttp=new XMLHttpRequest().3. If that fails, try xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"). This is for IE6 and IE5.To send off a request to the server, we use the open() and send() methods.The open() method takes three arguments. The first argument defines which method to use when sending the request (GET or POST). The second argument specifies the URL of the server-side script. The third argument specifies that the request should be handled asynchronously.The send() method sends the request off to the server. If we assume that the HTML and ASP file are in the same directory, the code would be:xmlhttp.open("GET","time.asp",true);xmlhttp.send(null);Now we must decide when the AJAX function should be executed.We will let the function run "behind the scenes" when a user types something in the "Name" field:<form name="myForm">Name: <input type="text" name="username" onkeyup="ajaxFunction();" />Time: <input type="text" name="time" /></form>Our updated "testAjax.htm" file now looks like this:<html><body><script type="text/javascript">function ajaxFunction(){var xmlhttp;if (window.XMLHttpRequest)  {  // code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {  // code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4)  {  document.myForm.time.value=xmlhttp.responseText;  }}xmlhttp.open("GET","time.asp",true);xmlhttp.send(null);}</script><form name="myForm">Name: <input type="text" name="username" onkeyup="ajaxFunction();" />Time: <input type="text" name="time" /></form></body></html>Now we are going to create the server-side script that displays the current time.The responseText property (explained in the previous chapter) will store the data returned from the server. Here we want to send back the current time.The code in "time.asp" looks like this:<%response.expires=-1response.write(time)%>Note: The response.expires command sets how long time (in minutes) a page will be cached on a browser before it expires. If a user returns to the same page before it expires, the cached version is displayed. response.expires=-1 indicates that the page will never be cached.


Subscribe to XML