You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2012/02/17 11:57:08 UTC

svn commit: r1245386 - in /incubator/stanbol/site/trunk/content/stanbol: css/stanbol.css docs/trunk/enhancer/enhancerrest.mdtext

Author: rwesten
Date: Fri Feb 17 10:57:07 2012
New Revision: 1245386

URL: http://svn.apache.org/viewvc?rev=1245386&view=rev
Log:
minor corrections and a css class for xml nodes

Modified:
    incubator/stanbol/site/trunk/content/stanbol/css/stanbol.css
    incubator/stanbol/site/trunk/content/stanbol/docs/trunk/enhancer/enhancerrest.mdtext

Modified: incubator/stanbol/site/trunk/content/stanbol/css/stanbol.css
URL: http://svn.apache.org/viewvc/incubator/stanbol/site/trunk/content/stanbol/css/stanbol.css?rev=1245386&r1=1245385&r2=1245386&view=diff
==============================================================================
--- incubator/stanbol/site/trunk/content/stanbol/css/stanbol.css (original)
+++ incubator/stanbol/site/trunk/content/stanbol/css/stanbol.css Fri Feb 17 10:57:07 2012
@@ -137,16 +137,19 @@ div.codehilite {
     border: 1px solid #bebab0;
     line-height: 133%;
 }
-span.c1, span.cm {
+span.c1, span.cm { /* comments */
     color: #667f5b;
 }
-span.k {
+span.nt { /* XML Nodes */
+    color: #667f5b;
+}
+span.k { /* keyword */
     color: #8e2b75;
     font-weight:bold;
 }
-span.nd {
+span.nd { /* Java Annotations */
     color: #646464;
 }
-span.s , span.s2{
+span.s , span.s2 { /* Strings */
     color: #1500ff;
 }
\ No newline at end of file

Modified: incubator/stanbol/site/trunk/content/stanbol/docs/trunk/enhancer/enhancerrest.mdtext
URL: http://svn.apache.org/viewvc/incubator/stanbol/site/trunk/content/stanbol/docs/trunk/enhancer/enhancerrest.mdtext?rev=1245386&r1=1245385&r2=1245386&view=diff
==============================================================================
--- incubator/stanbol/site/trunk/content/stanbol/docs/trunk/enhancer/enhancerrest.mdtext (original)
+++ incubator/stanbol/site/trunk/content/stanbol/docs/trunk/enhancer/enhancerrest.mdtext Fri Feb 17 10:57:07 2012
@@ -86,20 +86,21 @@ Requests to the Stanbol Enahcer with the
 The combination of <code>multipart/from-data</code> encoded requests with QueryParameters as described above allow for the usage of [MultiPart MIME format for ContentItems](contentitem.html#multipart_mime_serialization) for both request and resonse.
 
 
-### Example usages of the multi-part content item RESTful API extensions
+## Using the multi-part content item RESTful API extensions
 
-The following examples show some typical usages of the multi-part content item RESTful API. Note that for better readability the values of the query parameters are
-not URLEncoded.
+The following examples show typical usage scenarios of the multi-part content item RESTful API. Note that for better readability the values of the query parameters are not URLEncoded.
 
-Return Metadata and transformed Content versions
+### Example 1: Return metadata and content
+
+The first example shows how users can request both the metadata and transcoded versions of the parsed content.
+This can be achieved relatively easy by using the "<code>outputContent=*/*</code>" in combination with "<code>omitParsed=true</code>".
     
     :::bash
     curl -v -X POST -H "Accept: multipart/from-data" \
         -H "Content-type: text/html; charset=UTF-8"  \
-        --data "&lt;html&gt;&lt;body&gt;&lt;p&gt;John Smith was born in London.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;" \
+        --data "<html><body><p>John Smith was born in London.</p></body></html>" \
         "${it.serviceUrl}?outputContent=*/*&omitParsed=true&rdfFormat=application/rdf+xml"
 
-__Example 1: Return metadata and content__
 
 This will result in an Response with the mime type <code>"Content-Type: multipart/from-data; charset=UTF-8; boundary=contentItem"</code> and the Metadata as well as the plain text version of the parsed HTML document as content.
 
@@ -109,10 +110,10 @@ This will result in an Response with the
     Content-Type: application/rdf+xml; charset=UTF-8;
     Content-Transfer-Encoding: 8bit
 
-    &lt;rdf:RDF
+    <rdf:RDF
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     [..the metadata formatted as RDF+XML..]
-    &lt;/rdf:RDF&gt;
+    </rdf:RDF>
 
     --contentItem
     Content-Disposition: form-data; name="content"
@@ -129,13 +130,15 @@ This will result in an Response with the
 
     --contentItem--
 
-__Example 2: Directly return the plain text version of parsed content__
+Se also the formal specification of the [MultiPart MIME format for ContentItems](contentitem.html#multipart_mime_serialization) for ContentItems.
+
+#### Example 2: Directly return the plain text version of parsed content
 
-This shows how the Apache Stanbol Enhancer can be used to transcode parsed content.
+The using the '<code> omitMetadata=true</code>' together with the "Accept: {requested-content-type}" the multi-part content API allows to directly request the transcoded version of the content with the format {requested-content-type}. 
 
     curl -v -X POST -H "Accept: text/plain" \
         -H "Content-type: text/html; charset=UTF-8" \
-        --data "&lt;html&gt;&lt;body&gt;&lt;p&gt;John Smith was born in London.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;" \
+        --data "<html><body><p>John Smith was born in London.</p></body></html>" \
         "${it.serviceUrl}?omitMetadata=true"
 
 The response will use <code>Content-Type: text/plain</code> and contain the string
@@ -143,9 +146,11 @@ The response will use <code>Content-Type
     :::text
     John Smith was born in London.
 
-To make this work the requested [Enhancement Chain](chains) will need to include an engine (e.g. [Metaxa](engines/metaxaengine.html)) that supports transcoding the parsed content. Not that because the metadata are omitted by responses to such requests it is also recommended to configure/use a chain that does no further processing on the transcoded content. 
+To make this work the requested [Enhancement Chain](chains) will need to include an engine (e.g. [Metaxa](engines/metaxaengine.html)) that supports transcoding the parsed content. If not content with the request type is available the request will answer with a "<code>404 NOT FOUND</code>". 
+
+Note also that because the metadata are omitted by responses to such requests it is also recommended to configure/use a chain that does no further processing on the transcoded content. 
 
-__Example 3: Parse multiple content versions__
+#### Example 3: Parse multiple content versions
 
 This example will use the "httpmime" part of the Apache commons httpcomponents to create the Multipart MIME sent to the Stanbol enhancer.
 
@@ -183,8 +188,8 @@ The created Multipart MIME content MUST 
             "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 
             "example.docx")));
 
-     //now add the alternate plain text version
-     content.addBodyPart(new FormBodyPart(
+    //now add the alternate plain text version
+    content.addBodyPart(new FormBodyPart(
         "http://www.example.com/example.docx", //the id of the content part
         new StringBody( //use a StringBody to avoid binary encoding for text
             IOUtils.toString(plainIn), //apache commons IO utility
@@ -195,13 +200,13 @@ The created Multipart MIME content MUST 
     //Stanbol Enhancer
     HttpPost request = new HttpPost("http://localhost:8080/enhancer");
     request.setEntity(contentItem);
-    request.setHeader("Accept","application/rdf+xml);
+    request.setHeader("Accept","application/rdf+xml");
     Response response = httpClient.execute(request);
 
 
 Note that for such requests [Metaxa](engines/metaxaengine.html) will still try to extract metadata of the parsed MS Word document, but all other engines will use the plain text version as parsed by the request for processing.
 
-__Example 4: Parse existing free text annotations__
+#### Example 4: Parse existing free text annotations
 
 This example shows how the multi-part content item API can be used to parse already existing tags for an parsed content to the Stanbol Enhancer. For this example it is important to understand that parsed metadata need to confirm to the Stanbol Enhancement Structure. Because of that this example consist of two main steps:
 
@@ -260,16 +265,16 @@ Now the 'graph' contains a valid TextAnn
 
 In the next step we need to serialize the RDF data. Again I will use here Clerezza as API, but any RDF framework will provide similar functionality
 
-   :::java
-   ByteArrayOutputStream out = new ByteArrayOutputStream();
-   //this tells the Serializer to create "application/rdf+xml"
-   serializer.serialize(out, metadata, SupportedFormat.RDF_XML);
-   String rdfContent = new String(out.toByteArray(),UTF8);
+    :::java
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    //this tells the Serializer to create "application/rdf+xml"
+    serializer.serialize(out, metadata, SupportedFormat.RDF_XML);
+    String rdfContent = new String(out.toByteArray(),UTF8);
    
 Now we need to create the MultiPart MIME content item containing the metadata and the content
 
-   :::java
-   String content; //the content we want to send to the Stanbol Enhancer
+    :::java
+    String content; //the content we want to send to the Stanbol Enhancer
 
     //the container for the ContentITem
     MultipartEntity contentItem = new MultipartEntity(null, null ,UTF8);
@@ -284,9 +289,9 @@ Now we need to create the MultiPart MIME
             }
         });
 
-Note that because the StringBody class provided my the "httpmime" framework does not set a Filename we need to override this method and return the URI of the content item. This is essential, because we need ensure that the URI of the ContentItem is the same as the URI (variable 'ciUri') as used when creating the TextAnnotations for the user tags.
+Note that because the <code>StringBody</code> class provided my the "httpmime" framework does not set a Filename we need to override this method and return the URI of the content item. This is essential, because we need ensure that the URI of the ContentItem is the same as the URI (variable '<code>ciUri</code>') as used when creating the TextAnnotations for the user tags.
 
-For the following code snippet note that we can directly add the content to the content item container. Only if we would need to sent multiple alternate content versions (as shown in 'Example 3') the usage of an 'multipart/alternate' container is required.
+For the following code snippet note that we can directly add the content to the content item container. Only if we would need to sent multiple alternate content versions (as shown in 'Example 3') the usage of an <code>'multipart/alternate'</code> container is required.
  
     :::java
     //Add the content as second mime part
@@ -298,7 +303,7 @@ For the following code snippet note that
     //Stanbol Enhancer
     HttpPost request = new HttpPost("http://localhost:8080/enhancer");
     request.setEntity(contentItem);
-    request.setHeader("Accept","application/rdf+xml);
+    request.setHeader("Accept", SupportedFormat.RDF_XML);
     Response response = httpClient.execute(request);
 
 The response of the Enhancer will now contain Entity suggestions for the free text user tags.