supporting foundry and layer specification in spans
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index 161aa18..2302fe3 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -466,7 +466,6 @@
 			ParseTree valNode;
 			if (QueryUtils.hasChild(node, "key")) valNode = node.getChild(3);
 			else valNode = node.getChild(2);
-			System.err.println("WOOAH "+valNode.toStringTree(poliqarpParser));
 			String valType = QueryUtils.getNodeCat(valNode);
 			fieldMap.put("@type", "korap:term");
 			if (valType.equals("simple_query")) {
@@ -478,11 +477,9 @@
 			}
 			if (key == null) {
 				fieldMap.put("key", value);
-				System.err.println("WUUUH "+key+value);
 			} else {
 				fieldMap.put("key", key);
 				fieldMap.put("value", value);
-				System.err.println("WAAAH "+key+value);
 			}
 			
 			if (layer.equals("base")) layer="lemma";
@@ -643,7 +640,16 @@
 			stackedObjects++;
 			// Step II: fill object (token values) and put into containing sequence
 			elem.put("@type", "korap:span");
-			String value = node.getChild(1).toStringTree(poliqarpParser);
+			int valChildIdx = node.getChildCount()-2; // closing '>' is last child
+			String value = node.getChild(valChildIdx).toStringTree(poliqarpParser);
+			ParseTree foundryNode = QueryUtils.getFirstChildWithCat(node, "foundry");
+			ParseTree layerNode = QueryUtils.getFirstChildWithCat(node, "layer");
+			if (foundryNode != null) {
+				elem.put("foundry", foundryNode.getChild(0).toStringTree(poliqarpParser));
+			}
+			if (layerNode != null) {
+				elem.put("layer", layerNode.getChild(0).toStringTree(poliqarpParser));
+			}	
 			elem.put("key", value);
 			// add token to sequence only if it is not an only child (in that case, cq_segments has already added the info and is just waiting for the values from "field")
 			if (node.getParent().getChildCount()>1) {
@@ -731,7 +737,6 @@
 				ParseTree spanNode = node.getChild(2);
 				for (int i=0; i<spanNode.getChildCount()-1; i++) {
 					String ref = spanNode.getChild(i).getText();
-					System.err.println("       "+ref);
 					if (ref.equals("|") || ref.equals("&")) {
 						classRefOp = ref.equals("|") ? "intersection" : "union";
 					} else {
@@ -984,7 +989,8 @@
 				"{[base=Mann]}",
 				"shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})",
 				"[base=Mann/i]",
-				"[cnx/base=pos:n]"
+				"[cnx/base=pos:n]",
+				"<cnx/c=np>"
 		};
 		PoliqarpPlusTree.debug=true;
 		for (String q : queries) {
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index ad293eb..bb97c45 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -81,6 +81,7 @@
 	
 	@Test
 	public void testElements() throws QueryException {
+		String query;
 		// <s>
 		String elem1 = "{@type=korap:span, key=s}";
 		assertTrue(equalsQueryContent(elem1, "<s>"));
@@ -88,6 +89,20 @@
 		// <vp>
 		String elem2 = "{@type=korap:span, key=vp}";
 		assertTrue(equalsQueryContent(elem2, "<vp>"));
+		
+		// <cnx/c=vp>
+		query = "<c=vp>";
+		String span3 = "{@type=korap:span, layer=c, key=vp}";
+		ppt = new PoliqarpPlusTree(query);
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(span3.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		// <cnx/c=vp>
+		query = "<cnx/c=vp>";
+		String span4 = "{@type=korap:span, foundry=cnx, layer=c, key=vp}";
+		ppt = new PoliqarpPlusTree(query);
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(span4.replaceAll(" ", ""), map.replaceAll(" ", ""));
 	}
 	
 	@Test