/*
* Class XPathHelper
* This class talks directly to the VOTable XML document.
* This class is used for getting all required information
* such as VTable, MetaData, and Data from the XML document.
*
*/


#ifndef XPATH_HELPER_H
#define XPATH_HELPER_H

// Base header file.  Must be first.
#include "Include/PlatformDefinitions.hpp"

#include <cassert>


//#if defined(XALAN_OLD_STREAM_HEADERS)
//#include <iostream.h>
//#else
//#include <iostream>
//#endif

#include "util/PlatformUtils.hpp"
#include "framework/LocalFileInputSource.hpp"



#include "XalanDOM/XalanDocument.hpp"
#include "XalanDOM/XalanElement.hpp"
#include "XalanDOM/XalanNamedNodeMap.hpp"
#include "XalanDOM/XalanNodeList.hpp"
#include "DOMSupport/DOMServices.hpp"



#include "XPath/XObject.hpp"
#include "XPath/XPathEvaluator.hpp"
#include "XPath/NodeRefListBase.hpp"



#include "XalanSourceTree/XalanSourceTreeDOMSupport.hpp"
#include "XalanSourceTree/XalanSourceTreeInit.hpp"
#include "XalanSourceTree/XalanSourceTreeParserLiaison.hpp"

#include <string.h>
#include "global.h"
#include "VTable.h"
#include "Resource.h"


const int MAX_XPATH_EXPR_LEN = 256;

class XPathHelper {

public:

	XPathHelper(void);
	int getVTableTree(VTable &v, const char * filename, 
		const char * xpath, int *status);
	int getResourceTree(Resource &r, const char * filename, 
		const char * xpath, int *status);
	

private:
	
	int extractResourceInfo(XObjectPtr  xObj, Resource &r, int *status);
	int extractTableInfo(XObjectPtr node, VTable &v, int *status);
	int getTable(VTable &v, const XalanNode* node, int *status);
	int getFieldParam(const XalanNode *siblingNode, FieldParam *f, bool isField, int *status);
	Link getLink(const XalanNode *siblingNode, int *status);
	char* getDescription(const XalanNode *siblingNode, int *status);
	int getTableAttributes(VTable &v, const XalanNode *node, int *status);
	int getFieldParamAttributes(const XalanNode *node, FieldParam *f, bool isField, int * status);
	Values getValuesAttributes(const XalanNode *node, int * status);
	char * getCharString(XalanDOMString str);
	Values getValues(const XalanNode *node, int *status);
	Option getOptionAttributes(const XalanNode *node, int *status);
	Range * getRange(const XalanNode *node, int *status);
	vector<Row> getRows(const XalanNode *node, int *status);
	Column getColumnAttributes(const XalanNode *node, int *status);
	Range getRangeAttributes(const XalanNode *node, int *status);
	TableData getData(const XalanNode *node, int *status);
	Option getOption(const XalanNode *node, int *status);
	Row getRow(const XalanNode *node, int *status);
	Column getColumn(const XalanNode *node, int *status);
	int getResourceAttributes(Resource &r, const XalanNode *node, int *status);
	Info getInfoAttributes(const XalanNode *node, int *status);
	Coosys getCoosysAttributes(const XalanNode *node, int *status);
	int getResource(Resource &r, const XalanNode* node, int * status);
	Info getInfo(const XalanNode *node, int *status);
	Coosys getCoosys(const XalanNode *node, int *status);
	


};


#endif