Index: /MDService2/trunk/MDService2/WebContent/static/queries2.xml
===================================================================
--- /MDService2/trunk/MDService2/WebContent/static/queries2.xml	(revision 1494)
+++ /MDService2/trunk/MDService2/WebContent/static/queries2.xml	(revision 1495)
@@ -6,14 +6,16 @@
 			<dd><p>just one word like:</p>
 				<ul>		
-					<li><a class="query" href="?squery=system">system</a></li>							
+					<li><a class="query count" href="?squery=system">system</a></li>					
+					<li><a class="query count" href="?squery=-year-olds">-year-olds</a> - a bug solved (parser doesn't like '-' at the beginning!)</li>
+					<li><a class="query count" href="?squery=acquisition">acquisition</a></li>												
 				</ul>
 			</dd>
 			
-			<!--
+			
 			<dt >all of multiple terms (AND)</dt>
 			<dd>
 				<ul>
-					<li><a class="query" href="/MDService2/?squery=child%20acquisition">child acquisition</a></li>
-					<li><a class="query" href="/MDService2/?squery=longitudinal%20study">longitudinal study</a></li>			
+					<li><a class="query count" href="?squery=child%20acquisition">child acquisition</a></li>
+					<li><a class="query count" href="?squery=longitudinal%20study">longitudinal study</a></li>			
 				</ul>
 			</dd>
@@ -21,8 +23,17 @@
 			<dd>a sequence of terms
 				<ul>
-					<li><a class="query" href="/MDService2/?squery=%22longitudinal%20study%22">"longitudinal study"</a></li>
+					<li><a class="query count" href="?squery=%22longitudinal%20study%22">"longitudinal study"</a></li>
 				</ul>
-			</dd> 
-			<dt >Bookmarks</dt>	
+			</dd>
+			
+			<dt >Special stuff</dt>	
+			<dd>
+				<ul>
+					<li><a class="query" href="?q=clarin.eu:ws-registry&amp;repository=localhost-mirror">WS registry</a></li>
+				</ul>
+			</dd>
+			 
+			<!-- 
+					<dt >Bookmarks</dt>	
 			<dd>search/remember individual records (by handle/identifier)
 				<ul>			
Index: /MDService2/trunk/MDService2/WebContent/style/cmds-ui.css
===================================================================
--- /MDService2/trunk/MDService2/WebContent/style/cmds-ui.css	(revision 1494)
+++ /MDService2/trunk/MDService2/WebContent/style/cmds-ui.css	(revision 1495)
@@ -21,5 +21,5 @@
 .data {display: none; }
 .hilight { font-size: 1.1em; font-weight: bold}
-.error { font-color: red}
+.error { color: #660000; border: 1px solid red; background-color: #ffcccc; }
 /* this is temporary for MdREcordView-Titlebar; -> move to ui-box-header */ 
 /* obsolete .box_heading { background-color: #014172;  color: #FAFAFF; font-weight: bold; padding: 2px; } 
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Admin.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Admin.java	(revision 1494)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Admin.java	(revision 1495)
@@ -37,5 +37,5 @@
 	private static String config_path = "mdservice.properties";
 	private static Properties  config;
-	public static Logger log = Logger.getLogger("Admin.class");
+	public static Logger log = Logger.getLogger(Admin.class);
 	
 	public static String FATAL = "fatal";
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java	(revision 1494)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java	(revision 1495)
@@ -38,9 +38,9 @@
 /**
  * This is a rudimentary caching mechanism.
- * serializes the inputstream to a file (identifier => filename)
- * and returns the inpustream based on the identifier.
+ * It serializes the inputstream to a file (identifier => filename) (putInCache())
+ * or returns the inputstream based on the identifier (getFromCache())
  * 
- * It maintains the cache_index (persisted as xml-file in the cache-folder)
- * mapping the request parameters to the indexed files.
+ * <p>It maintains the cache_index (persisted as xml-file in the cache-folder)
+ * mapping the request parameters to the indexed files.</p>
  * 
  * This is an internal object, direct user access to cache-data via interface is only possible via <code>AdminAction</code>
@@ -48,8 +48,4 @@
  *
  */
-/* TODO: necessary to maintain own index
- * for resolution of IDs to filenames
- */
-
 
 public class Cache {
@@ -353,5 +349,5 @@
 	 * read counter-integer from file in cache
 	 * or start that file
-	 * @return
+	 * @return The current maximum cache counter
 	 */
 	public Integer initCachecounter() {
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java	(revision 1494)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java	(revision 1495)
@@ -26,16 +26,13 @@
 
 import org.apache.struts2.interceptor.ServletRequestAware;
-
 import com.opensymphony.xwork2.ActionSupport;
-
 import eu.clarin.cmdi.mdservice.model.Diagnostics;
 
 /**
- * main Struts 2 controller 
- * responds to requests (collections, model, recordset) 
- * by dispatching the requests to appropriate internal methods and filling the inputStream with the result
+ * main Struts2 controller (ie implemenets the struts' execute()-method), all other Actions are derived from.   
+ * Defines the methods used for retrieving the data 
+ * and provides basic implementation where possible.
  *  
  * @author vronk
- *
  */
 public class GenericProxyAction extends ActionSupport 
@@ -69,7 +66,10 @@
 	private String repository;
 	//private Map<String,Object> session;
-	 private HttpServletRequest request; 
-	 private long duration = 0;
-	 
+	private HttpServletRequest request; 
+	private long duration = 0;
+	private InputStream resultStream;
+	private InputStream sourceStream;
+	protected URL base_url ;
+		
 	 public GenericProxyAction(){
 		 super();
@@ -198,4 +198,8 @@
 	}
 
+	/**
+	 * is used in struts.xml to dynamically set the mime-type of the result, depending on the format-parameter
+	 * @return
+	 */
 	public String getActionContentType() {
 		if (format.toLowerCase().startsWith("html")) {
@@ -269,8 +273,8 @@
 
 	/**
-	 * primitive identification of the target-proxy
-	 * base for finding the right base_url in the props
+	 * internal identification of the target-proxy
+	 * base for finding the right base_url in the properties
 	 * subclass has to override with its specific proxykey
-	 * @return
+	 * @return the key identifying this type of proxy
 	 */
 	public String getProxyKey() {
@@ -278,4 +282,8 @@
 	}
 	
+	/**
+	 * TODO: check what this does, where it is used?
+	 * @return
+	 */
 	public String getUserMsg() {
 		return userMsg;
@@ -286,4 +294,8 @@
 	}
 	
+	/**
+	 * TODO: check what this does, where it is used?
+	 * @return
+	 */
 	@Override
 	public void setServletRequest(HttpServletRequest arg0) {
@@ -294,8 +306,4 @@
 		return request;
 	}
-
-
-	private InputStream resultStream;
-	private InputStream sourceStream;
 
 	/**
@@ -335,6 +343,18 @@
 	}
 	
-	protected URL base_url ;
-	
+	/**
+	 * Reads URI from the configuration (mdservice.properties) based on the proxy-key
+	 * @return the base-URI of the target repository or registry
+	 */
+	public String getBaseURI() {		
+		String uri =Admin.getConfig().getProperty(getProxyKey() + ".uri");		
+		return uri;
+	}
+
+	/**
+	 * Provides the base-URL specific to given target repository or registry 
+	 * @return
+	 * @throws MalformedURLException
+	 */	
 	public URL getBaseURL() throws MalformedURLException {		
 		if (base_url == null) {
@@ -344,34 +364,22 @@
 	}
 	
-	public String getBaseURI() {		
-		String uri =Admin.getConfig().getProperty(getProxyKey() + ".uri");		
-		return uri;
-	}
-
-	
+	/**
+	 * Constructs the actual URL to be send to the target repository/registry
+	 * It has to be overridden by the subclasses 
+	 * as every target service has a different request-pattern.  
+	 * @return URL of the target request 
+	 * @throws IOException
+	 */
 	public URL getTargetRequest() throws IOException {
-        // URL targetURL =new URL( base_url, compname + ".xml");
-		URL targetURL = getBaseURL();	   
-                      
+		URL targetURL = getBaseURL();                      
         return targetURL;
 	}
 	
-	/*
-	public String getRequestKey() {
-		String key="";
-		if (getActionkey()!=null) {
-			key += getActionkey() + "//-" ;
-		}
-		if (getQ()!=null) {
-			key += getQ() + "//-" ;
-		}
-		if (getCollection()!=null) {
-			key += getCollection();
-		}
-		 
-		return key;
-	}
-*/
-
+	/**
+	 * Constructs an unambiguous key for the request (encoding all the parameters).
+	 * This is used as identifier for caching 
+	 * @return key unambiguously encoding the request
+	 */
+	
 	 public String getRequestKey() {
 			String key="";
@@ -416,14 +424,18 @@
 			}else{
 				key +="//-" ;
-			}
-			
+			}			
 			 
-			return key;
-	}
+		return key;
+	}
+	 
+	 
 	public InputStream getSourceStream() throws IOException, NoStylesheetException {		
 		return getTargetRequest().openStream();
-		//	Admin.notifyUser(getProxyKey() + ".getSourceStream() - unable to open stream: " + getTargetRequest();  
-	}
-	
+ 
+	}
+	
+	/*
+	 * TODO: this should go to Utilities!
+	 */
 	public  static String convertStreamToString(InputStream is) {  
 		
@@ -677,4 +689,14 @@
 	}
 	
+	/**
+	 * This is the work-horse function.
+	 * It does two things: 
+	 * a) check if the source data is already in cache (based on cache-key that is constructed from the request parameters)
+	 * b) if format-parameter provided, invokes the transformation. 
+	 * at the end the data to be returned as result is contained in the resultStream
+	 * If format is xml, then the data from sourceStream is passed further as resultStream. 
+	 *    
+	 * @throws Exception  This is handled by struts (is mapped to some result in struts.xml based on the Exception-Class)
+	 */
 	
 	public void prepare() throws Exception {		
@@ -716,12 +738,11 @@
 			resultStream = sourceStream;	
 		}else {
+			MDTransformer transformer = new MDTransformer();
 			// set URL as srcFile (for MDTransformer to pass to xsl-scripts)
-			MDTransformer transformer = new MDTransformer();
+			// TODO: WHY??
 			transformer.setSrcFile(getTargetRequest());
-			// getColumns
-		//	Admin.notifyUser("GPA.getRepository, before xsl:" + getRepository());
 			transformer.setParams(createTransformerParams());
-			
-			resultStream = transformer.transformXML(sourceStream);//, getFullFormat(), getColumns(), getStartRecord(), getMaximumRecords(),getLang(),getQ(),String.valueOf(getRepository()));
+			// here the transformation is invoked
+			resultStream = transformer.transformXML(sourceStream);
 		}
 			
@@ -730,5 +751,5 @@
 
 	/**
-	 * default Action method
+	 * default Action method that gets called by Struts. Everything interesting happens in prepare()
 	 */
 	public String execute() throws Exception {
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDRepoProxyAction.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDRepoProxyAction.java	(revision 1494)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDRepoProxyAction.java	(revision 1495)
@@ -29,6 +29,6 @@
 
 /**
- * Main Struts 2 controller 
- * responds to requests (collections, model, recordset) 
+ * Proxy to the Metadata Repository.  
+ * Responds to requests (collections, model, recordset) 
  * by dispatching the requests to appropriate internal methods and filling the inputStream with the result
  * 
@@ -44,9 +44,10 @@
 	private String proxy_key = "mdrepository";
 	
-	@Override
+	/**
+	 * Override of the basic method provided by the super-class 
+	 */	
+	@Override	
 	public String getBaseURI() {		
-		Admin.notifyUser("MDREPO-property:" + Admin.getConfig().getProperty(getProxyKey() + ".uri"));
-		Admin.notifyUser("MDREPO-profile:" + getRepositoryPath());
-		String uri = getRepositoryPath();//Admin.getConfig().getProperty(getProxyKey() + ".uri");		
+		String uri = getRepositoryPath();		
 		return uri;
 	}
@@ -56,4 +57,5 @@
 		super.setFormat(format);		
 	}
+	
 	@Override
 	public String getProxyKey() {
@@ -61,5 +63,7 @@
 	}
 	
-	
+	/**
+	 * A mapping between the actionkeys in the request and the operation-parameter expected by the MDRepository 
+	 */
 	private final static HashMap<String,String> urls = new HashMap<String,String>();
 	 static
@@ -70,27 +74,5 @@
 	 	 urls.put("record", "?operation=searchRetrieve&query=");
 	 } 
-	/*
-	 @Override
-	 public URL getBaseURL() throws MalformedURLException {		
-			if (base_url == null) {
-				base_url = new URL(Admin.getConfig().getProperty(getProxyKey() + ".uri"));
-				try {
-					Admin.notifyUser("TEST-URLold:" + base_url.toURI());
-				} catch (URISyntaxException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-				base_url = new URL(getRepository());
-				try {
-					Admin.notifyUser("TEST-URLnew:" + base_url.toURI());
-				} catch (URISyntaxException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-			}
-			return base_url;
-		}
-	 */
-	 
+ 
 	/**
 	 * uses base_url + url_pattern (parametrized by actionkey) to form a url
@@ -102,8 +84,9 @@
 		
 		Admin.notifyUser("MDRPA.getQ:" + getSquery() + " and (" +  getQ() + ")");
-		Admin.notifyUser("MDRPA.getActionkey:" + getActionkey());
-		Admin.notifyUser("MDRPA.getMaxdepth:" + getMaxdepth());
+		Admin.notifyUser("MDRPA.getActionkey:" + getActionkey());		
 		
 		Query query = new Query(getSquery(), getQ(),getActionkey());
+
+	// check if the query could get parsed
 		if (query.isStatus(Query.PARSEERROR)) {
 			Admin.notifyUser("MDRPA.query.PARSEERROR:" + query.getMsg());
@@ -119,8 +102,6 @@
 			query.setOptions(getOptions());
 			query.setSort(getSort());
-			//Admin.notifyUser("MDRPA.records:" + query.getStartRecord());
-			//Admin.notifyUser("MDRPA.records:" + query.getMaximumRecords());
-			URL targetURL = null;		
-			
+		
+			URL targetURL = null;
 			targetURL =new URL( getBaseURL(), urls.get(getActionkey()) + query.toURLParam() );
 			Admin.notifyUser("MDRPA.targetURL.query.toURLParam:" + query.toURLParam());
@@ -130,71 +111,5 @@
 	}
 
-	
-/* 
- * FOLLOWING ARE OBSOLETE METHODS 
- * for processing the requests and serving the results
- * they stay here for reference (as bad examples) temporarily
- * and can/shall be removed in the near future.	
- */
-	
-/**
- * serves the collections, passes the Request to MDRepositoryProxy
- * @return
- * @throws Exception
- */
-	/*
-	public String collections() throws Exception {
-	
-		Query query = new Query(getQ(),Query.COLLECTIONS);
-		
-//		 inputStream = getMDRepo().getCollections(query);
-		 
-		return SUCCESS;
-	}
-*/
-	/**
-	 * serves the model/terms, via Query.execute() and .getResult()
-	 * @return
-	 * @throws Exception
-	 */
-/*
-	public String model() throws Exception {
-		
-		Query query = new Query(getQ(), Query.MODEL, getCollection());
-			Admin.notifyUser(query.getTargetRequest().toString());
-			query.setMaxdepth(getMaxdepth());
-		query.execute();				
-			
-		//inputStream = query.getResult().getResultStream(format);
-		return SUCCESS;
-	}
-*/
-	/**
-	 * the method for actual querying of MDRepository 
-	 * and getting back the MD-recordset
-	 * using Query-object (not asking MDRepository yet)
-	 *    
-	 * @return
-	 * @throws Exception 
-	 * @throws Exception
-	 */	
-	/*
-	public String recordset() throws Exception {
-		
-		Query query = new Query(getQ(), Query.RECORDSET, getCollection());
-			
-			Admin.notifyUser("recordset_target_uri:" + query.getTargetRequest().toString());		
-			query.execute();				
 
-//		String str =query.getResult().getHeader();		
-		 
-//		inputStream = new ByteArrayInputStream(str.getBytes());
-
-//		inputStream = query.getResult().getResultStream(format);
-		return SUCCESS;
-		 
-	}
-	*/
-	
 	@Override
 	public void prepare() throws Exception{
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDTransformer.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDTransformer.java	(revision 1494)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDTransformer.java	(revision 1495)
@@ -52,7 +52,8 @@
 
 /**
- * Helper class, encapsulating the xsl-transformations handling
- * the contract is, that the requester passes a key, which can be resolved to a xsl-script (momentary mapped in properties: Admin.getConfig())
- * Bad things happen, if the key or the appropriate xsl-file do not exist
+ * Helper class, encapsulating the xsl-transformations handling.
+ * The contract is, that the requester passes a key, which can be resolved to a xsl-script (momentary mapped in properties: Admin.getConfig())
+ * 
+ * Bad things happen, if the key or the appropriate xsl-file do not exist - well the client gets a diagnostic message.
  *    
  * 
@@ -66,5 +67,6 @@
 	private HashMap<String,String> params;
 		
-	private MDTransformer singleton;
+	// don't use singleton!! Bad things happen
+	// private MDTransformer singleton;
 	TransformerFactory tfactory ; 
 	
@@ -73,12 +75,4 @@
 	}
 	
-	/*
-	public static MDTransformer getMDTransformer () {
-		if (singleton == null) {
-			singleton = new MDTransformer();
-		} 
-		return singleton;
-	}
-	*/
 	
 	public URL getSrcFile() {
@@ -90,13 +84,20 @@
 	}
 
+	/**
+	 * This serves the caller (mainly GenericProxyAction.prepare())
+	 * to provide/fill the request parameters. 
+	 * They then get translated to stylesheet-parameters (in SetTransformerParameters()).
+	 * @return
+	 */
 	public void setParams(HashMap<String,String> params){
 		this.params = params;
 	}
 	
+	
 	public HashMap<String,String> getParams(){
 		return this.params;
 	}
 	/**
-	 * get the path to the transform-xsl file from properties, based on the key
+	 * get the path to the transform-xsl file from properties, based on the key (aka format-parameter)
 	 * @param key
 	 * @return
@@ -116,4 +117,14 @@
 	}
 
+	/**
+	 * Tries to load the stylesheet based on the key.
+	 * This is done in two steps:
+	 * 1. try to resolve the key to a path
+	 * 2. get the xsl-file as a stream (and establish it as StreamSource) 
+	 * 
+	 * @param key The key identifying the stylesheet for the transformation as passed by GenericProxyAction.
+	 * @return the stylesheet to be applied (as StreamSource)
+	 * @throws NoStylesheetException If the stylesheet could not be located
+	 */
 	private StreamSource getXSLStreamSource (String key) throws NoStylesheetException{		
 		
@@ -126,62 +137,7 @@
 		StreamSource streamSource = new StreamSource(xslstream);
 
-		//Admin.notifyUser(this.getClass().getClassLoader().getResource(xslPath).toString());
-		//Admin.notifyUser(this.getClass().getClassLoader().getResource(xslPath).getPath());
-		
-		
 		streamSource.setSystemId(this.getClass().getClassLoader().getResource(xslPath).toString());
-		return streamSource ;		
-		
-	}
-
-	public Object getCols() throws TransformerConfigurationException, TransformerFactoryConfigurationError{
-		
-		String xmlString = null;
-		// create new document
-		Document doc = null;
-		DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
-     	DocumentBuilder docBuilder;
-		try {
-			docBuilder = docFactory.newDocumentBuilder();
-			doc = docBuilder.newDocument();
-			// append root tag <col >
-			Element root = (Element) doc.createElement("root");
-			doc.appendChild(root);
-			
-			Element child1 = (Element) doc.createElement("col");
-			child1.setTextContent("Id");
-			root.appendChild(child1);			
-			Element child = (Element) doc.createElement("col");
-			child.setTextContent("Name");
-			root.appendChild(child);
-			//Element child = doc.createElement("col");
-			//child.setNodeValue("Id");
-			
-			
-			Transformer transformer = TransformerFactory.newInstance().newTransformer();
-			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-
-			//initialize StreamResult with File object to save to file
-			StreamResult result = new StreamResult(new StringWriter());
-			DOMSource source = new DOMSource(doc);
-			try {
-				transformer.transform(source, result);
-				xmlString = result.getWriter().toString();
-				
-				Admin.notifyUser(xmlString);
-			} catch (TransformerException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-
-			
-
-		} catch (ParserConfigurationException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		//return xmlString;
-		//return doc.getElementsByTagName("col").item(0);
-		return doc.getDocumentElement();
+		return streamSource ;	
+		
 	}
 	
@@ -189,5 +145,10 @@
 		return params.get("format");
 	}
-	
+
+	/**
+	 * Makes the request-parameters available in the stylesheets
+	 * by translating them to stylesheet-parameters
+	 * @param transformer
+	 */
 	public void SetTransformerParameters(Transformer transformer){
 		
@@ -231,25 +192,6 @@
 	        me.setWriter(w);
 	       ((net.sf.saxon.Controller)transformer).setMessageEmitter(me);//new net.sf.saxon.event.MessageWarner());
+
 	       
-/*	        transformer.setParameter("q", q);
-	        transformer.setParameter("lang", lang);
-	        transformer.setParameter("format", transkey);
-	        transformer.setParameter("cols", cols);
-	        if ((startRecord != null) && (maximumRecords != null)) {
-
-		        transformer.setParameter("startRecord", startRecord);
-		        transformer.setParameter("maximumRecords", maximumRecords);
-	        }
-	        if (repositoryURI != null) {
-
-		        transformer.setParameter("repository_uri", repositoryURI);
-	        }
-	        */
-	        /*       transformer.setParameter("cols", "<col label='id'>Id</col>" +
-	        								 "<col label='id'>idno</col>" +
-	        								 "<col label='name'>Name</col>" +
-	        								 "<col label='title'>Title</col>" +
-	        								 "<col label='title'>title</col>"); */
-	        
 	        if (srcFile!=null) {
 	        	
@@ -288,6 +230,92 @@
 	        writeXslMessages(w);
 	        ///Admin.notifyUser(w.getBuffer().toString());	        
-	    }
-	
+   }
+	
+
+	/**
+	 * just a wrapper for the main method translating the output-stream into a input-stream (expected by the Controller-Actions to return as response)
+	 * @param xmlStream the source xml stream 
+	 * @param transkey 
+	 * @return result-stream (converted to InputStream)
+	 * @throws IOException
+	 * @throws InterruptedException
+	 * @throws TransformerException
+	 * @throws NoStylesheetException 
+	 */
+	public InputStream transformXML ( InputStream xmlStream) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
+	//public InputStream transformXML ( InputStream xmlStream, String transkey, String cols, String startRecord, String maximumRecords, String lang, String q, String repositoryURI) throws IOException, InterruptedException, TransformerException {
+		
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		transformXML(xmlStream, out);		
+	    InputStream transformedStream = new ByteArrayInputStream(out.toByteArray());
+	    return transformedStream;
+	}
+	
+	/**
+	 * another wrapper for the main method allowing to directly pass a URL to the source-xml    
+	 * @param xmlFile URL of the source-file   
+	 * @param transkey
+	 * @return the result-stream (already converted to an InputStream) 
+	 * @throws TransformerException
+	 * @throws IOException
+	 * @throws NoStylesheetException 
+	 */
+	public InputStream transformXML (URL xmlFile ) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
+	//public InputStream transformXML (URL xmlFile, String transkey ) throws IOException, InterruptedException, TransformerException {
+		srcFile= xmlFile;
+		InputStream  xmlStream =
+	     new BufferedInputStream(new FileInputStream(xmlFile.getPath()));
+	    
+		return transformXML ( xmlStream); 
+	}
+
+
+	/**
+	 * this is for xml-data present as string (primarily the query string present as XCQL).
+	 * if xml in a file or a stream, use the other methods 
+	 * @param xml xml-data as string
+	 * @param transkey 
+	 * @return
+	 * @throws NoStylesheetException 
+	 * @throws IOException 
+	 */
+	public String transformXML (String xml) throws NoStylesheetException {
+	//public String transformXML (String xml, String transkey ) {
+		String result="";
+		try {
+	        // Create a transform factory instance.
+			System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
+			//System.setProperty("javax.xml.transform.TransformerFactory", "com.icl.saxon.TransformerFactoryImpl");
+	        TransformerFactory tfactory = TransformerFactory.newInstance();
+	        OutputStream os = new ByteArrayOutputStream();
+	        StreamResult stream = new StreamResult(os);
+	        // Create a transformer for the stylesheet.
+	        Transformer transformer = tfactory.newTransformer(
+	        				getXSLStreamSource(getTranskey()));
+
+	        MessageEmitter me = new net.sf.saxon.event.MessageEmitter();
+	        StringWriter w = new StringWriter();
+	        me.setWriter(w);
+	        ((net.sf.saxon.Controller)transformer).setMessageEmitter(me);//new net.sf.saxon.event.MessageWarner());
+
+	        // Transform the source XML to System.out.
+	        StreamSource src =new StreamSource();        
+	        Reader reader  = new StringReader(xml);
+	        src.setReader(reader);
+	        
+	        transformer.transform(src, stream );
+	                            //  new StreamResult(new File("Simple2.out")));
+	     // Write <xsl:message>
+	        writeXslMessages(w);
+	          
+	        result = os.toString(); 
+	        
+			} catch (TransformerException e) {
+				e.printStackTrace();
+			}
+			
+			return result;
+	}
+
 	private void writeXslMessages(StringWriter w){
         
@@ -304,119 +332,5 @@
 			e.printStackTrace();
 		}
-
-	}
-	/**
-	 * just a wrapper for the main method translating the output-stream into a input-stream (expected by the Controller-Actions to return as response)
-	 * @param xmlStream the source xml stream 
-	 * @param transkey 
-	 * @return result-stream (converted to InputStream)
-	 * @throws IOException
-	 * @throws InterruptedException
-	 * @throws TransformerException
-	 * @throws NoStylesheetException 
-	 */
-	public InputStream transformXML ( InputStream xmlStream) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
-	//public InputStream transformXML ( InputStream xmlStream, String transkey, String cols, String startRecord, String maximumRecords, String lang, String q, String repositoryURI) throws IOException, InterruptedException, TransformerException {
-		
-		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		transformXML(xmlStream, out);
-		//transformXML(xmlStream, transkey, cols, startRecord, maximumRecords, lang, q, repositoryURI, out);		
-	    InputStream transformedStream = new ByteArrayInputStream(out.toByteArray());
-	    //Admin.notifyUser("transformedStream:" + transformedStream.toString());
-	    return transformedStream;
-	}
-	
-	/**
-	 * just a wrapper for the main method translating the output-stream into a input-stream (expected by the Controller-Actions to return as response)
-	 * @param xmlStream the source xml stream 
-	 * @param transkey 
-	 * @return result-stream (converted to InputStream)
-	 * @throws IOException
-	 * @throws InterruptedException
-	 * @throws TransformerException
-	 */
-	/*
-	public InputStream transformXML ( InputStream xmlStream, String transkey) throws IOException, InterruptedException, TransformerException {
-		
-		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		transformXML(xmlStream, transkey, "", "", "","","", "", out);		
-	    InputStream transformedStream = new ByteArrayInputStream(out.toByteArray());
-	    //Admin.notifyUser("transformedStream:" + transformedStream.toString());
-	    return transformedStream;
-	}
-*/
-	/**
-	 * another wrapper for the main method allowing to directly pass a URL to the source-xml    
-	 * @param xmlFile URL of the source-file   
-	 * @param transkey
-	 * @return the result-stream (already converted to an InputStream) 
-	 * @throws TransformerException
-	 * @throws IOException
-	 * @throws NoStylesheetException 
-	 */
-	public InputStream transformXML (URL xmlFile ) throws IOException, InterruptedException, TransformerException, NoStylesheetException {
-	//public InputStream transformXML (URL xmlFile, String transkey ) throws IOException, InterruptedException, TransformerException {
-		srcFile= xmlFile;
-		InputStream  xmlStream =
-	     new BufferedInputStream(new FileInputStream(xmlFile.getPath()));
-	    
-		return transformXML ( xmlStream); 
-	}
-
-
-	/**
-	 * this is for xml present as string.
-	 * if xml in a file or a stream, use the other methods 
-	 * @param xml xml as string
-	 * @param transkey 
-	 * @return
-	 * @throws NoStylesheetException 
-	 * @throws IOException 
-	 */
-	public String transformXML (String xml) throws NoStylesheetException {
-	//public String transformXML (String xml, String transkey ) {
-		String result="";
-		try {
-	        // Create a transform factory instance.
-			System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
-			//System.setProperty("javax.xml.transform.TransformerFactory", "com.icl.saxon.TransformerFactoryImpl");
-	        TransformerFactory tfactory = TransformerFactory.newInstance();
-	        OutputStream os = new ByteArrayOutputStream();
-	        StreamResult stream = new StreamResult(os);
-	        // Create a transformer for the stylesheet.
-	        Transformer transformer = tfactory.newTransformer(
-	        				getXSLStreamSource(getTranskey()));
-/* instead of:
-	        InputStream  xslIS       =
-	            new BufferedInputStream(new FileInputStream(getXSLPath(transkey)));
-	        
-	        Transformer transformer =
-	            tfactory.newTransformer(new StreamSource(xslIS));
-	            */
-	        ////////////////////
-	        MessageEmitter me = new net.sf.saxon.event.MessageEmitter();
-	        StringWriter w = new StringWriter();
-	        me.setWriter(w);
-	        ((net.sf.saxon.Controller)transformer).setMessageEmitter(me);//new net.sf.saxon.event.MessageWarner());
-
-	        // Transform the source XML to System.out.
-	        StreamSource src =new StreamSource();        
-	        Reader reader  = new StringReader(xml);
-	        src.setReader(reader);
-	        
-	        transformer.transform(src, stream );
-	                            //  new StreamResult(new File("Simple2.out")));
-	     // Write <xsl:message>
-	        writeXslMessages(w);
-	          
-	        result = os.toString(); 
-	        
-			} catch (TransformerException e) {
-				e.printStackTrace();
-			}
-			
-			return result;
-	}
-
+	}
 	
 	public static HashMap<String,String> createParamsMap(String transkey){
Index: /MDService2/trunk/MDService2/src/xsl/mdinst2view.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/mdinst2view.xsl	(revision 1494)
+++ /MDService2/trunk/MDService2/src/xsl/mdinst2view.xsl	(revision 1495)
@@ -19,5 +19,8 @@
 -->
     
-<xsl:output method="html" />
+<!--  method="xhtml" is saxon-specific! prevents  collapsing empty <script> tags, that makes browsers choke -->
+<xsl:output method="xhtml" media-type="application/xhtml+xml" indent="yes" encoding="UTF-8" 
+doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" /> 
+
 
 <xsl:include href="cmd_commons.xsl"/>
Index: /MDService2/trunk/MDService2/src/xsl/mdset2view.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/mdset2view.xsl	(revision 1494)
+++ /MDService2/trunk/MDService2/src/xsl/mdset2view.xsl	(revision 1495)
@@ -20,4 +20,5 @@
 <xsl:import href="terms2view.xsl"/>
 
+<!--  method="xhtml" is saxon-specific! prevents  collapsing empty <script> tags, that makes browsers choke -->
 <xsl:output method="xhtml" media-type="application/xhtml+xml" indent="yes" encoding="UTF-8" 
 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" /> 
Index: /MDService2/trunk/MDService2/src/xsl/test2view.xsl
===================================================================
--- /MDService2/trunk/MDService2/src/xsl/test2view.xsl	(revision 1494)
+++ /MDService2/trunk/MDService2/src/xsl/test2view.xsl	(revision 1495)
@@ -27,25 +27,50 @@
 <xsl:template match="a">
 
+ <xsl:variable name="specific_prefix" select="if (contains(@href,'query')) then 'recordset/htmlpage/' else ''" />
+ 
+ <xsl:variable name="data" >
+ 	<xsl:choose>			
+			<xsl:when test="@class='request count'">
+					<xsl:copy-of select="document(concat($base_url,@href))" />					
+			</xsl:when>
+			<xsl:when test="@class='query count'">
+					<xsl:copy-of select="document(concat($base_url, 'recordset/xml/', @href))" />										
+			</xsl:when>		
+			<xsl:when test="@class='query'">
+					<xsl:copy-of select="document(concat($base_url, 'recordset/htmltable/', @href))"  />										
+			</xsl:when>		
+			<xsl:otherwise>
+					<xsl:copy-of select="document(concat($base_url, @href))"  />
+			</xsl:otherwise>
+		</xsl:choose>	
+ </xsl:variable>
+
+	
  <div class="cmds-ui-block" >
 	 <div class="ui-widget-header">
-		<xsl:value-of select="@class" />: <xsl:copy-of select="." /> [<a href="{concat($base_url,@href)}" ><xsl:value-of select="@href" /></a>]
+		<xsl:value-of select="@class" />: <xsl:copy-of select="." /> [<a href="{concat($base_url,$specific_prefix,@href)}" ><xsl:value-of select="@href" /></a>]
 	</div>	
 	
 	<div class="ui-widget-content">
 		<xsl:choose>
-			<xsl:when test="@class='requestcount'">
-					<xsl:variable name="data" select="document(concat($base_url,@href))" />
-					<xsl:value-of select="count($data//*)" />
+			<xsl:when test="exists($data/diagnostics)">
+				<span class="error" >
+					<xsl:value-of select="$data/diagnostics/diag:diagnostic/diag:message" />
+				</span>
 			</xsl:when>
-			<xsl:when test="@class='query'">
+			<xsl:when test="@class='request count'">
+				root: <xsl:value-of select="$data/*/name()" />|<xsl:value-of select="count($data//*)" />|
+			</xsl:when>
+			<xsl:when test="@class='query count'">
+							<xsl:value-of select="$data//numberOfRecords" />
+							</xsl:when>
+			
+			<!-- <xsl:when test="@class='query'">
 					<xsl:variable name="data" select="document(concat($base_url,'recordset/htmltable/', @href))" />
 					<xsl:copy-of select="$data" />
-			</xsl:when>
-			<xsl:when test="@class='query count'">
-					<xsl:variable name="data" select="document(concat($base_url,'recordset/xml/', @href))" />
-					<xsl:value-of select="$data//numberOfRecords" />
-			</xsl:when>
+			</xsl:when> -->		
 			<xsl:otherwise>
-					<xsl:apply-templates select="document(concat($base_url,@href))" mode="process-query"/>
+<!--					<xsl:apply-templates select="$data" mode="process-result"/>-->				
+					<xsl:copy-of select="$data" />
 			</xsl:otherwise>
 		</xsl:choose>
@@ -61,7 +86,7 @@
 </xsl:template>
 
-<xsl:template match="*|@*" mode="process-query" >
+<xsl:template match="*|@*" mode="process-result" >
 	<xsl:copy>
-		<xsl:apply-templates select="node()|@*" mode="process-query" />
+		<xsl:apply-templates select="node()|@*" mode="process-result" />
 	</xsl:copy>	
 </xsl:template>
@@ -73,5 +98,5 @@
     <message>Exception occurred: Connection refused: connect</message> 
 -->
-<xsl:template match="diagnostics" mode="process-query" >
+<xsl:template match="diagnostics" mode="process-result" >
 	<div class="error" >
 		 <xsl:value-of select="diag:diagnostic/diag:message" />
