private void printEntitiesInNary(ORASSNode node, String naryRelName, List<String> entities, int currEntityIndex, int numOfTabs) {
		
		String entityName = node.getName();
		writer.println(getTabs(numOfTabs) + "<xs:element name=\""+entityName+"\" minOccurs=\"0\" maxOccurs=\"unbounded\">");
		writer.println(getTabs(numOfTabs + 1) + "<xs:complexType>");
		writer.println(getTabs(numOfTabs + 2) + "<xs:attribute name=\""+entityName+"_Ref\" type=\"xs:string\" use=\"required\"/>");
		
		List<ColumnDetail> naryRelAttrs = new ArrayList<ColumnDetail>();
		if (currEntityIndex == entities.size()-1) {
			List<ColumnDetail> relAttrs = node.getRelAttributes();
			if (relAttrs.size() > 0) {
				Iterator<ColumnDetail> relAttrsItr = relAttrs.iterator();
				while (relAttrsItr.hasNext()) {
					ColumnDetail relAttr = relAttrsItr.next();
					if (relAttr.getTableName().equals(naryRelName))
						naryRelAttrs.add(relAttr);
				}
			}
			
			if (naryRelAttrs.size() > 0) {
				writer.println(getTabs(numOfTabs + 2) + "<xs:all>");
				printColumns(naryRelAttrs, numOfTabs + 3);
				writer.println(getTabs(numOfTabs + 2) + "</xs:all>");
			}
		}
		
		else {
			List<ORASSNode> children = node.getChildren();
			Iterator<ORASSNode> childrenItr = children.iterator();
			String nextEntityNameInNary = entities.get(currEntityIndex + 1);
			while (childrenItr.hasNext()) {
				ORASSNode child = childrenItr.next();
				if (child.getName().equals(nextEntityNameInNary)) {
					printEntitiesInNary(child, naryRelName, entities, currEntityIndex + 1, numOfTabs+2);
					break;
				}
			}
		}
		
		writer.println(getTabs(numOfTabs + 1) + "</xs:complexType>");
		writer.println(getTabs(numOfTabs) + "</xs:element>");
	}