Index: /MDService2/trunk/MDService2/WebContent/WEB-INF/web.xml
===================================================================
--- /MDService2/trunk/MDService2/WebContent/WEB-INF/web.xml	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/WEB-INF/web.xml	(revision 1081)
@@ -44,5 +44,5 @@
       <web-resource-name>MDService Workspace</web-resource-name>
       <description></description>
-      <url-pattern>/workspace.jsp</url-pattern>
+      <url-pattern>/workspace.jsp</url-pattern>      
     </web-resource-collection>
     <auth-constraint>
Index: /MDService2/trunk/MDService2/WebContent/index.jsp
===================================================================
--- /MDService2/trunk/MDService2/WebContent/index.jsp	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/index.jsp	(revision 1081)
@@ -36,5 +36,5 @@
 					<% if ( request.getRemoteUser() == null) {  %> 
 					<a href="workspace.jsp" >    login</a>
-					<a href="docs/htmlpage/info" > docs</a>
+					<a class="open-in-context" target="_blank" href="docs/htmlpage/info" > docs</a>
 					
 					<% } else {  %> 
@@ -148,4 +148,5 @@
 						</div>
 			        <input type="checkbox" checked="false" id="input-withsummary" name="WS"/><label>with Summary</label>
+			        &nbsp;&nbsp;&nbsp;<a class="open-in-context" target="_blank" href="docs/htmlpage/queries" > example queries</a>
 					</td>      
 				</tr></table>		
Index: /MDService2/trunk/MDService2/WebContent/scripts/mdservice2_ui.js
===================================================================
--- /MDService2/trunk/MDService2/WebContent/scripts/mdservice2_ui.js	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/scripts/mdservice2_ui.js	(revision 1081)
@@ -160,14 +160,17 @@
 		var blankdata = "<html><\html>";
 		
-		if (xmlhttpreq.responseXML != null){
-			var isinfo = xmlhttpreq.responseXML.baseURI.split("/static/info.xml?id="); 
-			if (isinfo != "undefined"){
-				if ( isinfo.length = 2){
-					var infoid = new RegExp('[\\?]id=([^&#]*)').exec(xmlhttpreq.responseXML.baseURI);
-					infoid = infoid[1] || 0;
-					infoid = infoid + "-info";
-					data = $(_data).find('#' + infoid);
-				}
-			}		
+		if(typeof xmlhttpreq!='undefined')
+		{
+			if (xmlhttpreq.responseXML != null){
+				var isinfo = xmlhttpreq.responseXML.baseURI.split("/static/info.xml?id="); 
+				if (isinfo != "undefined"){
+					if ( isinfo.length = 2){
+						var infoid = new RegExp('[\\?]id=([^&#]*)').exec(xmlhttpreq.responseXML.baseURI);
+						infoid = infoid[1] || 0;
+						infoid = infoid + "-info";
+						data = $(_data).find('#' + infoid);
+					}
+				}		
+			}
 		}
 		
@@ -197,5 +200,6 @@
 		{
 			$('#detail-float').html(data);
-			var title =  $('#detail-float').find('.inner_title').attr("value");
+			var title =  $('#detail-float').find('.inner_title').attr('value');
+			if (title=='') title = $('#detail-float').find('.title, .inner_title').first().text();
 			$('#detail-float').dialog( "option", "title", title );
 			
@@ -649,4 +653,17 @@
 					$(".treeview","#collections").find(".showselection").css("color","white");
 	
+					// activate detail_call
+					$(".treeview","#collections").find(".cmd_detail").click(function(event) {
+							var uri = $(this).parent().find('.folder a').attr('href');
+							$.get(uri, showDetail,'html');
+							return false;	
+					});					
+					$(".treeview","#collections").find("a").click(function(event) {
+							event.preventDefault();
+						var uri = $(this).attr('href');
+						$.get(uri, showDetail,'html');
+						return false;
+					});
+					
 					// handle treeview click
 					$(".treeview","#collections").find(".selection").click(function() {
@@ -1153,4 +1170,17 @@
 	});
 	
+	 $('a.open-in-context').live('click', function(event) {
+			event.preventDefault();
+			var uri = $(this).attr('href');
+			/* notifyUser("open_incontext:" + uri);
+			$(this).after("<div class='ui-context-dialog cmds-ui-block' ></div>");
+			var trg = $(this).next(".ui-context-dialog");
+			trg.show();						
+			$(trg).load(uri); //function(event) {	} */
+			var contextual_uri = uri.replace('htmlpage','htmldetail'); 		
+			
+			$.get(contextual_uri, showDetail,'html');
+	});
+	
 // RECORDSET searchRetrieve
 	$('#searchretrieve').submit( function(event) {
@@ -1472,5 +1502,5 @@
 function loadQuery(q){
 	if (q["bookmark"] == "1") {
-		var uri = "http://localhost:8080/MDService2/record/htmldetail/" + q["querystring"];
+		var uri = "/MDService2/record/htmldetail/" + q["querystring"];
 		showDetail(null,'html');
 		$.get(uri, showDetail,'html');
Index: /MDService2/trunk/MDService2/WebContent/scripts/mdservice_helpers.js
===================================================================
--- /MDService2/trunk/MDService2/WebContent/scripts/mdservice_helpers.js	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/scripts/mdservice_helpers.js	(revision 1081)
@@ -13,5 +13,6 @@
 	}).next().hide();
 	*/
-	$(elems).children('.header').append('<span class="cmd cmd-collapse cmd_down" > </span>');
+	
+	$(elems).children('.header').prepend('<span class="cmd cmd-collapse cmd_down" > </span>');
 	$(elems).find('.cmd-collapse').click(function(event) {
 			$(this).closest('.header').next().toggle('fast');
@@ -21,10 +22,14 @@
 	
 	$(elems).each(function(i) {
+		// default is: hidden
 		if ($(this).hasClass('init-show'))  {		
 			$(this).children('.content').show();
 			$(this).find('.cmd-collapse').toggleClass('cmd_down cmd_up');		
-		}
+		} else {
+			$(this).children('.content').hide();			
+		}		
+			
 		if ($(this).parent().hasClass('cmds-ui-closable'))  {		
-			$(this).children('.header').append('<span class="cmd cmd_close" > </span>');
+			$(this).children('.header').prepend('<span class="cmd cmd_close" > </span>');
 			$(this).find('.cmd_close').click(function(event) {
 					$(this).closest('.header').parent().parent('.cmds-ui-closable').remove();	
@@ -50,5 +55,5 @@
 	} 
 
-	var paging = '<span class="label" >from:</span><span><input type="text" class="value start-item paging-input">' +
+	var paging = '<div class="cmds-navi-header ui-widget"><span class="label" >from:</span><span><input type="text" class="value start-item paging-input">' +
 	'</input></span>' +
 	'<span class="label" >max:</span><span><input type="text" class="value maximum-items paging-input" ></input></span>' +
@@ -67,5 +72,5 @@
 	//	'</xsl:when>' +
 	//	'</xsl:choose>' +
-	'</span>';
+	'</span></div';
 	
 	$(header).append(paging);
Index: /MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js
===================================================================
--- /MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js	(revision 1081)
@@ -454,5 +454,5 @@
 						var qid = $(this).closest('.query_wrapper').attr("id");
 						var q = queryset.getQuery(qid);
-						q.format = $(this).find('option:selected').text().trim();
+						q.format = $(this).find('option:selected').val();
 						queryset.resubmit(qid);
 						
Index: /MDService2/trunk/MDService2/WebContent/static/info.xml
===================================================================
--- /MDService2/trunk/MDService2/WebContent/static/info.xml	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/static/info.xml	(revision 1081)
@@ -1,4 +1,4 @@
 <info xml:lang="en" >
-	<div id="title">Information</div>
+	<div class="title">Information</div>
 	<div id="welcome">
 	
@@ -6,12 +6,13 @@
 	<p>Metadata Service is the user-interface for exploring the CMDRepository. Yes, you can:
 	 <ul>
-		<li>simply search</li>
+		<li>try one of the <a href="/MDService2/docs/htmlpage/queries" >sample queries</a></li>
+		<li>simply search (simple terms, combined terms, phrases)</li>		
+		<li>perform complex boolean-searches (according to the SRU/CQL standard)</li>		
 		<li>browse the collections</li>
-		<li>try one of the sample queries</li>
-		<li>perform complex boolean-searches</li>
+		<li>browse the (aggregated) xml-structure of the MD records</li>
 		<li>search by profiles</li>
-		<li>search by data categories</li>
-		<li>perform semantic search (elements of individual CMD-profiles are related via ConceptLinks to Datacategories, 
-			which are in turn related in the <strong>Relation registry</strong></li>
+		<li>search by data categories</li>		
+		<li>perform semantic search (elements of individual CMD-profiles are related via ConceptLinks to Data Categories, 
+			which are in turn related in the <strong>Relation Registry</strong>)</li>
 		<li>view individual metadata records </li>
 		<li>page through the results</li>
@@ -50,27 +51,38 @@
 	<div id="terms-info">
 		<span class="title">Terms</span>
-		<p>Terms combines information from MDRepository, ComponentRegistry, Datacategory Registries (isocat, dublincore) and Relationregistry to allow to search by profiles or data categories, or even perform semantic search</p>
-		<p>You can search in the fields of individual profiles instantiated as the MDrecords in the repository, or search over multiple profiles via datacategories.</p>
+		<p>Terms combine information from MDRepository, <em>Component Registry</em>, Data Category Registries (<a target="_blank" href="http://www.isocat.org">isocat</a>, <a target="_blank" href="http://dublincore.org/">dublincore</a>) 
+			and Relation Registry to allow to search by profiles or data categories, or even perform semantic search</p>
+		<p>Thus you can search in the fields of individual profiles instantiated as the MDrecords in the repository, or search over multiple profiles via datacategories.</p>
 	</div>	
 	<div id="compreg-info">
 		<span class="title" >Component Registry</span>
-		<p>Overview of all profiles and components defined in the Component Registry</p>
+		<p>Overview of all profiles and components defined in the Component Registry. (Proxy to Component Registry)</p>
 	</div>
 	<div id="query-input-info">
 		<span class="title" >Query Input</span>
-		<p>Form for entering the query. Either a simple or complex query</p>
-		<p>Both parts can be used in parallel: i.e. you can specify some terms for full-text search
-		and further refine them with.
-		The two parts are combined with boolean AND (the matching records have to satisfy both parts of the query.)
-		See <a href="queries" >example queries</a> for an overview of possible query types.
+		<p>Form for entering the query. Either a simple or complex query. 
+		See <a href="queries" >example queries</a> for an overview of possible query types.</p>
+		<dt id="input-simplequery-info">simple full-text search</dt>
+			<dd><p>individual terms, multiple terms, phrases</p>
+			</dd>
+		<dt id="searchclauselist-info">complex queries</dt>
+		<dd><p>complex queries according to SRU/CQL-standard</p>
+			<p>Basic <em>search clause</em> consists of: <code>index relation term</code>, e.g. <code>dc.title any system</code>.
+			You can combine these search clauses with boolean operators (AND, OR), to more complex queries. </p>
+		</dd>
+		<p>Both parts can be used in parallel - i.e. you can specify some terms for full-text search
+		and further refine them with filters on specific indices - 
+		the two parts being combined with boolean AND (the matching records have to satisfy both parts of the query.).
+		So the general syntax of the queries feasible within the query input is:
+		<p><code>simple-query AND (XQ1 or XQ2) AND (XQ3 or XQ4 or ...) AND ...<br/></code>
+			<code>XQ</code> consisting of <code>index relation term</code>  
+		</p>		
 		</p>
-		<div id="input-simplequery-info">
-			<p>simple full-text search: individual terms, multiple terms, phrases</p>
-		</div>
-		<div d="searchclauselist-info">
-			<p>complex queries according to SRU/CQL-standard</p>
-			<p>Basic <em>search clause</em> consists of: <code>index relation term</code>, e.g. <code>dc.title any system</code>.
-			You can combine this search clauses with boolean operators (AND, OR), to more complex queries</p>
-		</div>
+		<dt id="repositories_select-info">Repository</dt>
+		<dd><p>You can select target repository(-mirror).</p> 
+			<p>The <em>Collections</em> and <em>Terms</em> are updated accordingly (but this can take a few seconds)</p>
+		</dd>
+		<dt id="input-withsummary-info" >with Summary</dt>
+		<dd>This option provides a summary of the profiles used in the (whole) result and of the (XML-structure of the) displayed part of the result, but it obviously makes you wait a bit longer (generally 20-50% longer)</dd>
 	</div>	
 	<div id="querylist-info">
@@ -84,4 +96,6 @@
 	<dt id="cmd_add_or">Add a alternative condition (OR)</dt>
 	<dt id="cmd_columns">Manage columns/fields</dt> 
+	<dd>Allows to de/select the columns and change the list-format (list or table).
+	It requires the option <em>withSummary</em> to be activated, to provide the list of elements/indices that can be added as columns/fields.</dd>
 	<dt id="userqueries.cmd_del" idref="#userqueries .cmd_del" >Delete!</dt>
 	<dd>Delete the stored query!</dd>
@@ -96,6 +110,8 @@
 	<dt id="cmd_reload">Reload</dt> 
 	<dt id="cmd_resubmit">Reload</dt> 
-	<dt id="cmd_save">Store query/bookmark</dt> 
-	<dt id="cmd_sc_delete">Remove search clause</dt> 
+	<dt id="cmd_save">Store query/bookmark</dt>
+	<dd>The query/bookmark will be added to the current Queryset in the <em>Personal Workspace</em>.</dd> 
+	<dt id="cmd_sc_delete">Remove search clause</dt>
+	<dd>if only one search clause - clear it</dd> 
 	<dt id="cmd_up">Collapse view</dt>	 
 	<dt id="cmd_prev" >Page back</dt>
Index: /MDService2/trunk/MDService2/WebContent/static/queries.xml
===================================================================
--- /MDService2/trunk/MDService2/WebContent/static/queries.xml	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/static/queries.xml	(revision 1081)
@@ -1,25 +1,26 @@
 <info xml:lang="en" >
 	<div>
-		<div id="title">Example metadata queries</div>	
+		<div class="title">Example metadata queries</div>	
 	<dt >simple term</dt>
 	<dd><p>just one word like:</p>
 		<ul>		
-			<li><a href="?squery=system">system</a></li>
-			<li><a href="">-year-olds</a></li>
+			<li><a href="/MDService2/?squery=system">system</a></li>
+			<li><a href="">-year-olds</a> - a bug there (don't use '-'!)</li>
 			<li><a href="/MDService2/?squery=acquisition">acquisition</a></li>			
 		</ul>
 	</dd>
-	<dt>multiple terms - any (OR)</dt>
+	<dt>any of multiple terms (OR)</dt>
 	<dd>
 		<ul>
-			<li><a href="/MDService2/?squery=children acquisition">system</a></li>
+			<li><a href="/MDService2/?squery=/?squery=child%20%7C%20acquisition">child | acquisition</a></li>
 		</ul>
 	</dd>
-	<dt >multiple terms - all (AND)</dt>
+	<dt >all of multiple terms (AND)</dt>
 	<dd>
 		<ul>
 			<li><a href="">child acquisition</a></li>
-			<li><a href="">child &amp; acquisition</a></li>
-			<li><a href="">child AND acquisition</a></li>
+				<li><a href="/MDService2/?squery=child%20acquisition">child acquisition</a></li>
+				<li><a href="/MDService2/?squery=longitudinal%20study">longitudinal study</a></li>
+			
 		</ul>
 	</dd>
@@ -27,11 +28,10 @@
 	<dd>a sequence of terms
 		<ul>
-			<li><a href="">system</a></li>
+			<li><a href="/MDService2/?squery=%2522longitudinal%2520study%2522">"longitudinal study"</a></li>
 		</ul>
 	</dd> 
 	<dt >Bookmarks</dt>	
 	<dd>search/remember individual records (by handle/identifier)
-		<ul>
-			<li><a href="/MDService2/record/htmlpage/oai:blc%2Eberkeley%2Eedu:la%2E131">oai:blc.berkeley.edu:la.131</a></li>
+		<ul>			
 			<li><a href="/MDService2/record/htmlpage/clarin-at:aac-test-corpus:C4:158">clarin-at:aac-test-corpus:C4:158</a></li>
 			<li><a href="/MDService2/record/htmlpage/clarin%252Eeu%3Alrt%3A1001">GENOMA</a></li>
@@ -48,15 +48,43 @@
 		<code>phrase in index </code>
 		<ul>
-			<li><a href="/MDService2/?q=Description contains 'spoken language'">Description contains 'spoken language'</a></li>
+			<li><a href='/MDService2/?q=Description contains "spoken language"'>Description contains "spoken language"</a></li>
+		</ul>
+	</dd>	
+	<dt >CQL - boolean</dt>	
+	<dd>combine search clauses with boolean operators: AND, OR, (AND NOT)
+		<ul>
+			<li><a href="/MDService2/?q=(title contains a)  and ( tei%3Aimprint.date &gt; 1910) and (tei%3Aimprint.date &lt; 1920)">title contains a and imprint.date between 1910 and 1920</a></li>
+		<li><a href="/MDService2/?q=( title any system ) and  ( description contains ethnologue )" > ( title any system ) and  ( description contains ethnologue )</a></li>
+		<li><a href="/MDService2/?q=%20%28%20%20%28%20title%20any%20language%20%29%20%20%29%20%20and%20%20%28%20%20%28%20identifier%20contains%20rosettaproject%20%29%20%20or%20%20%28%20publisher%20contains%20%22SIL%20International%22%20%29%20%20%29%20" >title any language and (identifier contains rosettaproject or publisher contains "SIL International")</a></li>
+		 			
+		</ul>			
+	</dd>
+	<dt >Combine simple query and search clauses</dt>
+	<dd>
+		<ul>
+		<li><a href="/MDService2/?q=( title any system )&amp;squery=university">university and (title any system)</a></li>
 		</ul>
 	</dd>
 	
-	<dt >CQL - boolean</dt>	
-	<dd>combine search clauses with boolean operators: AND, OR, (AND NOT)
+		<dt >Restriction by Collections</dt>
+	<dd> Either all resources of a given collection, or restrict the search to selected collection(s) (not working at the moment)
 		<ul>
-			<li><a href="/MDService2/?q=(title contains a)  and ( tei%3Aimprint.date &gt; 1910) and (tei%3Aimprint.date &lt; 1920)">title contains a and imprint.date between 1910 and 1920</a></li>			 
-		</ul>			
+		<li><a href="/MDService2/?q=&amp;squery=&amp;collection=clarin-at:aac-test-corpus">aac-test-corpus</a></li>
+		</ul>
 	</dd>
-		
+		<dt >Search in a profile</dt>
+	<dd>show all records of given profile, or
+		<ul> 	
+		<li><a href="/MDService2/?q= ( LrtInventoryResource contains * )">LrtInventoryResource</a></li>
+		<li><a href="/MDService2/?q= ( LrtInventoryResource contains system )">LrtInventoryResource contains system</a></li>
+		</ul>
+	</dd>
+		<dt >Search via Data categories (Semantic search)</dt>
+	<dd>search over elements linked to the same Data cagetory, irrespectively of the containing profile  
+		<ul> 	
+		<li><a href="MDService2/?q=%20%28%20%20%28%20relcat%3Adescription%20contains%20*%20%29%20%20%29%20">relcat:description</a></li>
+		<li><a href="/MDService2/?q=%20%28%20%20%28%20isocat%3Acreation_date%20contains%20191%20%29%20%20%29%20">isocat:creationDate contains 191</a></li>
+		</ul>
+	</dd>
 	</div>
 </info>
Index: /MDService2/trunk/MDService2/WebContent/style/cmds-ui.css
===================================================================
--- /MDService2/trunk/MDService2/WebContent/style/cmds-ui.css	(revision 1080)
+++ /MDService2/trunk/MDService2/WebContent/style/cmds-ui.css	(revision 1081)
@@ -70,7 +70,8 @@
 .cmds-ui-block { margin: 2px; text-align: left;}
 
+.cmds-elem-plus .detail,
 .ui-context-dialog { display:none; position:absolute; border 1px solid #A6C9E2; background-color: #fafaff; z-index:1; }
 
-.cmds-elem-plus .detail { display: none; border: 1px solid #A6C9E2;}
+/* .cmds-elem-plus .detail { display: none; border: 1px solid #A6C9E2;} */
 
 .cmds-elem-prop {}
@@ -88,4 +89,5 @@
 .cmds-xmlelem .attributes .label {}
 .cmds-xmlelem .attributes .value {}
+
 
 
@@ -114,7 +116,13 @@
 .value_input { width:32%; }
 .sc_cmds { }
+
+.result-header { float: right; }
+.cmds-navi-header { float:right;}
+/* hack, for weird behaviour, the (appearingly) same rules for result-header.paging-input and cmds-navi-header.paging-input
+different render (cmds-navi-header.paging-input too small) */
+.cmds-navi-header .paging-input { height: 1.2em;}
+
 .paging-input { width: 3em; text-align: right; height: 1em;}
 
-.result-header { float: right; }
 .query {margin-right: 4px;}
  
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/DocsAction.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/DocsAction.java	(revision 1081)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/DocsAction.java	(revision 1081)
@@ -0,0 +1,37 @@
+package eu.clarin.cmdi.mdservice.action;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import net.sf.json.JSONObject;
+import net.sf.json.xml.XMLSerializer;
+
+/**
+ *
+ *
+ */
+public class DocsAction extends GenericProxyAction {
+
+	private static final long serialVersionUID = 1L;
+	
+	private String proxy_key = "docs";
+
+	@Override
+	public String getProxyKey() {
+		return proxy_key;
+	}
+	
+	
+	public URL getTargetRequest() throws IOException {
+	        
+		URL targetURL = null;
+		//targetURL =new URL( getBaseURL(), getActionkey());
+		//FIXME: get maxdepth-constant out of here !!
+		targetURL = new URL(getBaseURL(), getQ() + ".xml");
+		//Admin.notifyUser("CollectionProxy.targetURL:" + targetURL);
+
+	    return targetURL;
+	}
+	
+}
Index: /MDService2/trunk/MDService2/src/mdservice.properties
===================================================================
--- /MDService2/trunk/MDService2/src/mdservice.properties	(revision 1080)
+++ /MDService2/trunk/MDService2/src/mdservice.properties	(revision 1081)
@@ -71,2 +71,3 @@
 xsl.admin2htmlpage = cache2view.xsl
 xsl.docs2htmlpage = docs2view.xsl
+xsl.docs2htmldetail = docs2view.xsl
Index: /MDService2/trunk/MDService2/src/terms_setup.xml
===================================================================
--- /MDService2/trunk/MDService2/src/terms_setup.xml	(revision 1080)
+++ /MDService2/trunk/MDService2/src/terms_setup.xml	(revision 1081)
@@ -6,10 +6,9 @@
 	<Termset type="model" id="tcp" name="TextCorpusProfile" url="" format="terms|cmdrepo" />
 	<Termset type="model" id="tei" name="teiHeader" url="" format="terms" />
-
+ 	
 	<Termset type="dcr" id="isocat" name="isoCAT" url="http://www.isocat.org/rest/profile/5" url_prefix="http://www.isocat.org/datcat/" format="dcif" />
-	<Termset type="dcr" id="dce" name="dublincore elements" url="http://purl.org/dc/elements/1.1/" format="rdf" />
-	<Termset type="dcr" id="dct" name="dublincore terms" url="http://purl.org/dc/terms/" format="rdf" />	
-	<Termset type="rr" id="relcat" name="Relation Registry CMDI-set" url="http://lux13.mpi.nl/relcat/rest/set/cmdi" format="rdf" />
-	<Termset type="rr" id="hdcrel" name="Relation Registry DC-set" url="http://lux13.mpi.nl/relcat/rest/set/dc" format="rdf" />
-	
+	<Termset type="dcr" id="dce" name="dublincore elements" url="http://purl.org/dc/elements/1.1/" url_prefix="http://purl.org/dc/elements/1.1/"  format="rdf" />
+	<Termset type="dcr" id="dct" name="dublincore terms" url="http://purl.org/dc/terms/" url_prefix="http://purl.org/dc/terms/"  format="rdf" />	
+	<Termset type="rr" id="relcat" name="Relation Registry CMDI-set" url="http://lux13.mpi.nl/relcat/rest/set/cmdi" url_prefix="http://lux13.mpi.nl/relcat/rest/set/cmdi" format="rdf" />
+	<Termset type="rr" id="reldc" name="Relation Registry DC-set" url="http://lux13.mpi.nl/relcat/rest/set/dc" url_prefix="http://lux13.mpi.nl/relcat/rest/set/dc" format="rdf" />	
 </Termsets>
Index: /MDService2/trunk/MDService2/src/xsl/XCQL2Xpath.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/XCQL2Xpath.xsl	(revision 1080)
+++ /MDService2/trunk/MDService2/src/xsl/XCQL2Xpath.xsl	(revision 1081)
@@ -211,5 +211,5 @@
 			</xsl:when>
 			<xsl:when test="value='='" >
-				<xsl:text>. eq </xsl:text> <xsl:text>'</xsl:text><xsl:value-of select="$sanitized_term"/><xsl:text>'</xsl:text>				
+				<xsl:text>.%20eq%20</xsl:text> <xsl:text>'</xsl:text><xsl:value-of select="$sanitized_term"/><xsl:text>'</xsl:text>				
 			</xsl:when>
 			<xsl:otherwise>		
Index: /MDService2/trunk/MDService2/src/xsl/cmd_functions.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/cmd_functions.xsl	(revision 1080)
+++ /MDService2/trunk/MDService2/src/xsl/cmd_functions.xsl	(revision 1081)
@@ -91,5 +91,5 @@
     <xsl:param name="resolve" /> <!--  true|false-->
     
-    <xsl:message>cmdprofiles_uri: <xsl:value-of select="$cmdprofiles_uri" /></xsl:message>
+    <!-- <xsl:message>cmdprofiles_uri: <xsl:value-of select="$cmdprofiles_uri" /></xsl:message>  -->
     
     <xsl:variable name="profile" select="doc($cmdprofiles_uri)//profileDescription[name=$term]" />
@@ -154,8 +154,9 @@
 		<xsl:param name="url" />
 		<!--   <xsl:value-of select="replace($url, 'http://www.isocat.org/datcat/','isocat:')" /> -->
-		<xsl:variable name="matching_termset"  select="if($url!='') then $terms_setup/Termsets/Termset[@url_prefix][starts-with($url,@url_prefix)] else ()" />
-		 <xsl:message>shortURL: <xsl:copy-of select="$matching_termset" />:: <xsl:value-of select="$matching_termset[1]/@url_prefix" />
-				<xsl:value-of select="$url" /> 
-		</xsl:message>  		
+		 <xsl:variable name="matching_termset"  select="if($url!='') then $terms_setup/Termsets/Termset[@url_prefix][starts-with($url,@url_prefix)] else ()" />
+		 <!-- <xsl:variable name="matchinge_termset"  select="if($url!='') then if ($terms_setup/Termsets/Termset[@url_prefix][starts-with($url,@url_prefix)]) then $terms_setup/Termsets/Termset[@url_prefix][starts-with($url,@url_prefix)][1] 
+		 				else if $terms_setup/Termsets/Termset[@url][starts-with($url,@url)] then $terms_setup/Termsets/Termset[@url][starts-with($url,@url)][1] else ()" /> -->  
+		 <!--<xsl:message>shortURL: <xsl:value-of select="$matching_termset/@url_prefix" />:: <xsl:value-of select="$url" />
+		</xsl:message> -->  		
 		<xsl:value-of select="if ($matching_termset/@url_prefix and $matching_termset/@url_prefix!='' and $url!='') then replace($url, $matching_termset[1]/@url_prefix, concat(string-join($matching_termset/@id,','),':')) else $url" />		
 	</xsl:function>	
@@ -209,5 +210,5 @@
 	</xsl:function>	
    
-<!--
+<!-- 
 <xsl:function name="my:numberFormat">
 <xsl:param name="unit" />
@@ -280,7 +281,9 @@
 
 	<xsl:variable name="ix_resolved" >
-		<xsl:choose>
-				<xsl:when test="contains($p_xpath,'//')">
-					<xsl:variable name="prefix" select="substring-before($p_xpath,'//')" />				
+		<!-- get rid off leading slashes -->
+		<xsl:variable name="stripped" select="if (starts-with($p_xpath,'//')) then substring-after($p_xpath, '//') else $p_xpath"  />
+		<xsl:choose>
+				<xsl:when test="contains($stripped,'//')">
+					<xsl:variable name="prefix" select="substring-before($stripped,'//')" />				
 					<xsl:variable name="termset" select="$terms_setup/Termsets/Termset[@name=$prefix]" />				
 					
@@ -293,12 +296,12 @@
 						<xsl:when test="not($termset/@id)"> 
 							<!-- when no matching termset, simply  use the original prefix  -->
-							<xsl:value-of select="concat($prefix,':',substring-after($p_xpath,'//'))" />
+							<xsl:value-of select="concat($prefix,':',substring-after($stripped,'//'))" />
 						</xsl:when>
 						<xsl:otherwise>
-							<xsl:value-of select="concat($termset/@id,':',substring-after($p_xpath,'//'))" />	
+							<xsl:value-of select="concat($termset/@id,':',substring-after($stripped,'//'))" />	
 						</xsl:otherwise>
 					</xsl:choose>					 
 				</xsl:when>
-				<xsl:otherwise><xsl:value-of select="$p_xpath" />
+				<xsl:otherwise><xsl:value-of select="$stripped" />
 				</xsl:otherwise>
 			</xsl:choose>
Index: /MDService2/trunk/MDService2/src/xsl/collection2view.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/collection2view.xsl	(revision 1080)
+++ /MDService2/trunk/MDService2/src/xsl/collection2view.xsl	(revision 1081)
@@ -2,5 +2,5 @@
 <xsl:stylesheet
   version="1.0"
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="myFunctions">
 <!-- 
 <purpose> convert fsls to html-list-snippet</purpose>
@@ -89,6 +89,6 @@
     	<xsl:value-of select="@handle"/>
   		</xsl:attribute>
-  		<xsl:value-of select="@n" /></span>
-     <span class="note"> |<xsl:value-of select="@cnt" />|</span> 
+  		<a href="{my:formURL('record','htmldetail', @handle )}" ><xsl:value-of select="@n" /></a></span>  		
+     <span class="note"> |<xsl:value-of select="@cnt" />|</span><span class="cmd cmd_detail"> </span> 
 	<!-- 
 	<span class="folder"><xsl:value-of select="@n" />(<xsl:value-of select="@cnt" />)
Index: /MDService2/trunk/MDService2/src/xsl/mdset2view.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/mdset2view.xsl	(revision 1080)
+++ /MDService2/trunk/MDService2/src/xsl/mdset2view.xsl	(revision 1081)
@@ -247,4 +247,5 @@
 
 <xsl:template match="CMD" mode="table">
+	<xsl:variable name="absolute_position" select="if (number($startItem)=number($startItem)) then number($startItem) + position() - 1 else  position()" />
 		<tr>
 		<td>
@@ -252,10 +253,10 @@
 				<xsl:when test="exists(.//MdSelfLink)" >
 				<a class="internal" href="{concat('record/htmldetail/', my:encodePID(.//MdSelfLink), '?repository=', $repository_id)}" >
-						<xsl:value-of select="position()" />
+						<xsl:value-of select="$absolute_position" />
 				</a>
 				<span class="cmd cmd_detail" ></span>				
 				<span class="cmd cmd_save" ></span>						
 				</xsl:when>
-				<xsl:otherwise><xsl:value-of select="position()" /></xsl:otherwise>
+				<xsl:otherwise><xsl:value-of select="$absolute_position" /></xsl:otherwise>
 			</xsl:choose>
 		</td>
@@ -309,4 +310,5 @@
 
 <xsl:template match="CMD" mode="list">
+	<xsl:variable name="absolute_position" select="if (number($startItem)=number($startItem)) then number($startItem) + position() - 1 else  position()" />
 		<tr>
 		<td>
@@ -314,10 +316,10 @@
 				<xsl:when test="exists(.//MdSelfLink)" >
 				<a class="internal" href="{concat('record/htmldetail/', my:encodePID(.//MdSelfLink))}" >
-						<xsl:value-of select="position()" />
+						<xsl:value-of select="$absolute_position" />
 				</a>
 				<span class="cmd cmd_detail" ></span>				
 				<span class="cmd cmd_save" ></span>						
 				</xsl:when>
-				<xsl:otherwise><xsl:value-of select="position()" /></xsl:otherwise>
+				<xsl:otherwise><xsl:value-of select="$absolute_position" /></xsl:otherwise>
 			</xsl:choose>
 		</td>
Index: /MDService2/trunk/MDService2/src/xsl/model2matrix.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/model2matrix.xsl	(revision 1080)
+++ /MDService2/trunk/MDService2/src/xsl/model2matrix.xsl	(revision 1081)
@@ -201,5 +201,5 @@
 	<xsl:param name="datcat_termsets" />
 	<xsl:copy>
-		<xsl:variable name="matching_datcat_terms" select="$datcat_termsets//Term[@datcat=current()/@datcat]" />
+		<xsl:variable name="matching_datcat_terms" select="$datcat_termsets//Term[@type='datcat'][@datcat=current()/@datcat]" />
 		<!-- <xsl:variable name="matching_datcat_relterms" select="$datcat_termsets//Term[@datcat=current()/@datcat]" /> -->
 		<xsl:variable name="name" select="($matching_datcat_terms//@name)[1]"></xsl:variable>
@@ -208,5 +208,5 @@
 		<xsl:copy-of select="@*"></xsl:copy-of>		
 		<xsl:copy-of select="$matching_datcat_terms" />
-		<xsl:apply-templates select="Term" mode="resolve-relcat">
+		<xsl:apply-templates select="Term[@type='rel']" mode="resolve-relcat">
 			<xsl:with-param name="datcat_termsets" select="$datcat_termsets"/>
 		</xsl:apply-templates>		
@@ -406,5 +406,5 @@
 					</xsl:variable>	
 			
-			<xsl:variable name="corresp_cmdterm" select="$profile//*[@context=$context]" />					
+			<xsl:variable name="corresp_cmdterm" select="if (parent::Terms) then $profile else $profile//*[@context=$context]" />					
 			<!--
 			<xsl:message>context: <xsl:copy-of select="$context" /> </xsl:message>  
Index: /MDService2/trunk/MDService2/src/xsl/params.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/params.xsl	(revision 1080)
+++ /MDService2/trunk/MDService2/src/xsl/params.xsl	(revision 1081)
@@ -34,6 +34,5 @@
 	<xsl:param name="components_uri" select="'http://localhost:8080/MDService2/comp/xml/'" />		
 	<xsl:param name="components_id_prefix" select="'clarin.eu:cr1:'" />
-
-
+	<xsl:param name="components_viewer_uri" select="'http://catalog.clarin.eu/ds/ComponentRegistry/?item='" />
 	
 	<xsl:param name="autocolumns_limit" select="6" />
Index: /MDService2/trunk/MDService2/src/xsl/terms2view.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/terms2view.xsl	(revision 1080)
+++ /MDService2/trunk/MDService2/src/xsl/terms2view.xsl	(revision 1081)
@@ -41,9 +41,13 @@
     	 		<xsl:call-template name="header"/>
 			    <div id="terms-matrix">
-			    	<xsl:apply-templates mode="terms-tree" />			    	
+			    	<xsl:apply-templates mode="terms-tree" >
+			    		<xsl:sort select="if (@type='model') then 1 else if (@type='dcr') then 2  else 3" data-type="number"  />
+			    	</xsl:apply-templates>			    	
 				</div>	    	 								    		
 	  	 	</xsl:when>	  	 	     	
      	 	<xsl:when test="$format='terms2htmllist'" >    	 		
-    	 		<xsl:apply-templates select=".//Termset" mode="list"/>    
+    	 		<xsl:apply-templates select=".//Termset" mode="list">
+    	 			<xsl:sort select="if (@type='model') then 1 else if (@type='dcr') then 2  else 3" data-type="number"  />
+    	 		</xsl:apply-templates>    
     	 	</xsl:when>
     	 	<xsl:when test="$format='terms2flat'" >    	 		    	 	    	 		
@@ -216,10 +220,26 @@
 	</xsl:variable>
 	
-	<tr id="{$xid}" >
+	<!--  this is especially for empty data-categories -->
+	<xsl:variable name="is_empty" select="if(Term or @count) then '' else 'empty-term'" /> 
+	<tr id="{$xid}">
 	  <xsl:if test="not(parent::Termset) or parent::Termset[@type='dcr' or @type='rr']" >
 	  	<xsl:attribute name="class" select="concat('child-of-',$parentid)" />
 	  </xsl:if>
-		<td class="treecol" ><span class="cmd cmd_add" > </span>
-				<span class="column-elem"><xsl:value-of select="@path" /></span></td>		
+	  <xsl:variable name="path_anchored" >
+		  <xsl:choose>
+			  <xsl:when test="@corresponding_component" >
+			  		<a target="_blank" href="{concat($components_viewer_uri, @corresponding_component)}" ><xsl:value-of select="@path" /></a>
+			  </xsl:when>
+			  <xsl:otherwise>
+			  	<xsl:value-of select="@path" />
+			  </xsl:otherwise>
+		  </xsl:choose>
+	 </xsl:variable>
+		<td class="treecol {$is_empty}"  ><span class="cmd cmd_add" > </span>
+				<span class="column-elem"><xsl:copy-of select="$path_anchored" /></span>
+			<xsl:if test="@datcat!=''" >[<a target="_blank" href="{@datcat}" ><xsl:value-of select="my:shortURL(@datcat)" /></a>]</xsl:if>
+		</td>
+		<!-- <td><xsl:value-of select="@path" />,<xsl:value-of select="@context" /></td>-->			
+		 		
 		<td class="number"><xsl:value-of select="@count" /></td>
 		<!--  has children don't show the text-count - they are empty on non-terminals
@@ -227,9 +247,12 @@
 		 -->
 		<td class="number"><!--   <xsl:if test="not(Term)"><xsl:value-of select="@count_text" /></xsl:if>-->
-				<xsl:value-of select="format-number(if (not(Term)) then @count_text else sum(descendant::Term/@count_text),'#.##0','european' )" />
+				<xsl:variable name="count_text_sanitized" select="if (not(Term)) then @count_text else sum(descendant::Term/@count_text)" />
+				<xsl:value-of select="if (number($count_text_sanitized)=number($count_text_sanitized)) then 
+				 				format-number(number($count_text_sanitized),'#.##0','european' ) else ''" />			
 		</td>
-		<td class="number">
-			<xsl:if test="not(Term)"><a class="detail-caller" href="{my:formURL('values', 'htmllist', @path)}" ><xsl:value-of select="@count_distinct_text" /></a></xsl:if>
-			<xsl:if test="Term"><xsl:value-of select="format-number(sum(descendant::Term/@count_distinct_text),'#.##0','european' )" /></xsl:if>
+			
+		<td class="number">			 
+			<xsl:if test="not(Term)"><a class="detail-caller" href="{my:formURL('values', 'htmllist', concat(@path,'&amp;sort=size'))}" ><xsl:value-of select="format-number(@count_distinct_text,'#.##0','european')" /></a></xsl:if>
+			<xsl:if test="Term"><xsl:value-of select="format-number(sum(descendant::Term/@count_distinct_text),'#.##0','european')" /></xsl:if>
 		</td>
 		<td class="number">			
@@ -237,11 +260,9 @@
 				<xsl:variable name="count_elems" select="parent::Term/@count" />
 				<xsl:variable name="inf_content_ratio" select="if (@count_distinct_text!=0) then (@count_text div $count_elems) * (@count_text div @count_distinct_text) else ''" />
-				<xsl:value-of select="format-number(number($inf_content_ratio),'#.##0,00','european' )" />
+				<xsl:value-of select="if (number($inf_content_ratio)=number($inf_content_ratio)) then format-number(number($inf_content_ratio),'#.##0,00','european' ) else ''" />
 			</xsl:if>
 			
 		</td>
-		<!-- <td><xsl:value-of select="@path" />,<xsl:value-of select="@context" /></td>			
-		<td><xsl:value-of select="@corresponding_component" />,<xsl:value-of select="@datcat" /></td>
-		 --> 
+		 
      </tr> 
 		<xsl:if test="Term and ($lv&lt;$max_depth or $max_depth=0)">
