/** * Select an attribute name for iteration, * choose all attributes of an element * @param en */ public void selectAttr(String en) { if (en == null) throw new IllegalArgumentException("attribute name can't be null"); iter_type = ATTR; ft = true; size = vn.getTokenCount(); name = en; }
/** * Select an attribute name for iteration, * choose all attributes of an element * @param en */ public void selectAttr(String en) { if (en == null) throw new IllegalArgumentException("attribute name can't be null"); iter_type = ATTR; ft = true; size = vn.getTokenCount(); name = en; }
/** * Select an attribute name for iteration, * choose all attributes of an * element * * @param en */ public void selectAttr(String en) { if (en == null) throw new IllegalArgumentException("attribute name can't be null"); iter_type = ATTR; ft = true; size = vn.getTokenCount(); name = en; }
/** * Select the name space nodes as defined in XPath * @param en */ protected void selectNameSpace(String en){ if (en == null) throw new IllegalArgumentException("namespace name can't be null"); iter_type = NAME_SPACE; ft = true; size = vn.getTokenCount(); name = en; if (!en.equals("*")) name2="xmlns:"+en; if (fib==null) fib = new FastIntBuffer(4); else fib.clear(); }
/** * Select the name space nodes as defined in XPath * * @param en */ protected void selectNameSpace(String en) { if (en == null) throw new IllegalArgumentException("namespace name can't be null"); iter_type = NAME_SPACE; ft = true; size = vn.getTokenCount(); name = en; if (!en.equals("*")) name2 = "xmlns:" + en; if (fib == null) fib = new FastIntBuffer(4); else fib.clear(); }
/** * Select the name space nodes as defined in XPath * @param en */ protected void selectNameSpace(String en){ if (en == null) throw new IllegalArgumentException("namespace name can't be null"); iter_type = NAME_SPACE; ft = true; size = vn.getTokenCount(); name = en; if (!en.equals("*")) name2="xmlns:"+en; if (fib==null) fib = new FastIntBuffer(4); else fib.clear(); }
/** * Reads the doctype of the XML input file and sets the appropriate tagset * enum element from {@link Tagset}. * * @throws NavException * @throws DocTypeNotFoundException */ private void setTagset() throws NavException, DocTypeNotFoundException { for (int i = 0; i < vn.getTokenCount(); i++) { if (vn.getTokenType(i) == VTDNav.TOKEN_DTD_VAL) { String docType = StringUtils.normalizeSpace(vn.toString(i)).replaceAll("'", "\""); if (docType.contains("JATS-archivearticle1.dtd")) tagset = Tagset.JATS_1_0; else if (docType.contains("journalpublishing.dtd") || docType.contains("archivearticle.dtd")) tagset = Tagset.NLM_2_3; else if (docType.contains("journalpublishing3.dtd") || docType.contains("archivearticle3.dtd")) tagset = Tagset.NLM_3_0; else throw new IllegalArgumentException( "Unsupported document type in file " + nxmlFile.getAbsolutePath() + ": " + docType); return; } } throw new DocTypeNotFoundException("Could not find a doctype in file " + nxmlFile); }
/** * Sets the VTDNav cursor the first position after the current element. * * @return The new token index. */ protected int skipElement() { int elementDepth = vn.getCurrentDepth(); int i = vn.getCurrentIndex() + 1; while (i < vn.getTokenCount() && tokenIndexBelongsToElement(i, elementDepth)) { ++i; } return i; }
/** * This method returns the next node in the nodeset * it returns -1 if there is no more node * Afer finishing evaluating, don't forget to <em> reset the xpath </em> * @return int corresponding to the VTD index */ public int evalXPath() throws XPathEvalException, NavException{ if (xpe!=null){ if (ft == true){ if (vn != null){ stackSize = vn.contextStack2.size; } ft = false; xpe.adjust(vn.getTokenCount()); } return xpe.evalNodeSet(vn); } throw new PilotException(" Null XPath expression "); }
/** * This method returns the next node in the nodeset it returns -1 if there * is no more node Afer finishing evaluating, don't forget to * <em> reset the xpath </em> * * @return int corresponding to the VTD index */ public int evalXPath() throws XPathEvalException, NavException { if (xpe != null) { if (ft == true) { if (vn != null) { stackSize = vn.contextStack2.size; } ft = false; xpe.adjust(vn.getTokenCount()); } return xpe.evalNodeSet(vn); } throw new PilotException(" Null XPath expression "); }
private int findIndexAfterElement(int elementDepth, int startIndex) { int index = vn.getCurrentIndex(); int tokenType = vn.getTokenType(index); if (tokenType == VTDNav.TOKEN_STARTING_TAG) index = findIndexAfterStartingTag(index); while (index < vn.getTokenCount() && tokenIndexBelongsToElement(index, elementDepth)) ++index; return index; }
/** * This method returns the next node in the nodeset * it returns -1 if there is no more node * Afer finishing evaluating, don't forget to <em> reset the xpath </em> * @return int corresponding to the VTD index */ public int evalXPath() throws XPathEvalException, NavException{ if (xpe!=null){ if (ft == true){ if (vn != null){ stackSize = vn.contextStack2.size; } ft = false; xpe.adjust(vn.getTokenCount()); } return xpe.evalNodeSet(vn); } throw new PilotException(" Null XPath expression "); }
private int count(VTDNav vn){ int a = -1; // if (argCount!=1 || argumentList.e.isNodeSet()==false) // throw new IllegalArgumentException // ("Count()'s argument count is invalid"); vn.push2(); int size= vn.contextStack2.size ; try{ a = 0; argumentList.e.adjust(vn.getTokenCount()); while(argumentList.e.evalNodeSet(vn)!=-1){ a ++; } }catch(Exception e){ System.out.println("exception in count"); } argumentList.e.reset(vn); vn.contextStack2.size = size; vn.pop2(); return a; }
private int count(VTDNav vn){ int a = -1; // if (argCount!=1 || argumentList.e.isNodeSet()==false) // throw new IllegalArgumentException // ("Count()'s argument count is invalid"); vn.push2(); int size= vn.contextStack2.size ; try{ a = 0; argumentList.e.adjust(vn.getTokenCount()); while(argumentList.e.evalNodeSet(vn)!=-1){ //System.out.println(" ===>"+vn.getCurrentIndex()); a ++; } }catch(Exception e){ System.out.println("exception in count"); } argumentList.e.reset(vn); vn.contextStack2.size = size; vn.pop2(); return a; }
public static String getElementText(VTDNav vn) throws NavException { StringBuilder sb = new StringBuilder(); int depth = vn.getCurrentDepth(); int i = vn.getCurrentIndex(); while (vn.getTokenType(i) == VTDNav.TOKEN_STARTING_TAG) i++; while (vn.getTokenDepth(i) >= depth && !(vn.getTokenType(i) == VTDNav.TOKEN_STARTING_TAG && vn.getTokenDepth(i) == depth) && i < vn.getTokenCount()) { if (vn.getTokenType(i) == VTDNav.TOKEN_CHARACTER_DATA || vn.getTokenType(i) == VTDNav.TOKEN_CDATA_VAL) sb.append(vn.toString(i)); i++; } return sb.toString(); }
private int count(VTDNav vn){ int a = -1; // if (argCount!=1 || argumentList.e.isNodeSet()==false) // throw new IllegalArgumentException // ("Count()'s argument count is invalid"); vn.push2(); int size= vn.contextStack2.size ; try{ a = 0; argumentList.e.adjust(vn.getTokenCount()); while(argumentList.e.evalNodeSet(vn)!=-1){ //System.out.println(" ===>"+vn.getCurrentIndex()); a ++; } }catch(Exception e){ System.out.println("exception in count"); } argumentList.e.reset(vn); vn.contextStack2.size = size; vn.pop2(); return a; }
protected String moveToNextStartingTag() throws DocumentParsingException { try { int i = vn.getCurrentIndex(); int tokenType = vn.getTokenType(i); while (tokenType != VTDNav.TOKEN_STARTING_TAG && i < vn.getTokenCount()) ++i; vn.recoverNode(i); return vn.toString(vn.getCurrentIndex()); } catch (NavException e) { throw new DocumentParsingException(e); } }
int i = 0; e.adjust(vn.getTokenCount()); while(e.evalNodeSet(vn)!=-1) i++;
int i = 0; e.adjust(vn.getTokenCount()); while(e.evalNodeSet(vn)!=-1) i++;
int i = 0; e.adjust(vn.getTokenCount()); while(e.evalNodeSet(vn)!=-1) i++;