本文整理汇总了C#中com.ximpleware.VTDNav.toElement方法的典型用法代码示例。如果您正苦于以下问题:C# VTDNav.toElement方法的具体用法?C# VTDNav.toElement怎么用?C# VTDNav.toElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ximpleware.VTDNav
的用法示例。
在下文中一共展示了VTDNav.toElement方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: computeContextSize4Parent
protected internal int computeContextSize4Parent(Predicate p, VTDNav vn)
{
int i=0;
AutoPilot ap = (AutoPilot)currentStep.o;
vn.push2();
i = 0;
if (vn.toElement(VTDNav.PARENT)){
if (currentStep.eval(vn,p)){
i++;
}
}
vn.pop2();
currentStep.resetP(vn,p);
currentStep.out_of_range=false;
currentStep.o = ap;
return i;
}
示例2: computeContextSize4PrecedingSibling
protected internal int computeContextSize4PrecedingSibling(Predicate p, VTDNav vn)
{
int i=0;
vn.push2();
while(vn.toElement(VTDNav.PREV_SIBLING)){
if (currentStep.eval(vn,p)){
i++;
}
}
vn.pop2();
currentStep.resetP(vn,p);
currentStep.out_of_range=false;
//currentStep.o = ap;
return i;
}
示例3: process_preceding_sibling
private int process_preceding_sibling(VTDNav vn)
{
bool b = false, b1 = false;
Predicate t = null;
int result;
switch (state)
{
case START:
case FORWARD:
t = currentStep.p;
while (t != null)
{
if (t.requireContext)
{
int i = computeContextSize(t, vn);
if (i == 0)
{
b1 = true;
break;
}
else
t.ContextSize=(i);
}
t = t.nextP;
}
if (b1)
{
if (state == FORWARD)
{
state = BACKWARD;
currentStep = currentStep.prevS;
}
else
state = END;
break;
}
if (state == START)
state = END;
else
state = BACKWARD;
vn.push2();
while (vn.toElement(VTDNav.PS))
{
if ((currentStep.nt_eval || currentStep.nt.eval(vn))
&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn)))
{
if (currentStep.nextS != null)
{
state = FORWARD;
currentStep = currentStep.nextS;
break;
}
else
{
state = TERMINAL;
result = vn.getCurrentIndex2();
if (isUnique(result))
return result;
}
}
}
if(state == END) {
if (currentStep.hasPredicate)
currentStep.resetP(vn);
vn.pop2();
}else if (state == BACKWARD)
{
if (currentStep.hasPredicate)
currentStep.resetP(vn);
vn.pop2();
currentStep = currentStep.prevS;
}
break;
case END:
currentStep = null;
// reset();
return -1;
case BACKWARD:
if (currentStep.out_of_range)
{
currentStep.out_of_range = false;
transition_preceding_sibling(vn);
break;
}
while (vn.toElement(VTDNav.PS))
{
if ((currentStep.nt_eval || currentStep.nt.eval(vn))
&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn)))
{
if (currentStep.nextS != null)
{
state = FORWARD;
currentStep = currentStep.nextS;
b = true;
break;
}
else
{
//.........这里部分代码省略.........
示例4: computeContextSize4Child
protected internal int computeContextSize4Child(Predicate p, VTDNav vn)
{
int i=0;
bool b = vn.toElement(VTDNav.FIRST_CHILD);
if (b) {
do {
if (currentStep.eval(vn, p)) {
i++;
}
} while (vn.toElement(VTDNav.NS));
vn.toElement(VTDNav.PARENT);
currentStep.resetP(vn,p);
currentStep.out_of_range=false;
return i;
} else
return 0;
}
示例5: evalNodeSet
public override int evalNodeSet(VTDNav vn)
{
int result;
if (currentStep == null)
{
if (pathType == ABSOLUTE_PATH)
{
vn.toElement(VTDNav.ROOT);
vn.toElement(VTDNav.PARENT);
}
currentStep = s;
if (currentStep == null)
{
if (state == START)
{
state = END;
return 0;
}
else
{
return -1;
}
}
}
while (true)
{
switch (currentStep.axis_type)
{
case AxisType.CHILD0:
if ((result = process_child(vn)) != -2)
{
return result;
}
break;
case AxisType.CHILD:
if ((result = process_child2(vn)) != -2)
{
return result;
}
break;
case AxisType.DESCENDANT_OR_SELF0:
case AxisType.DESCENDANT0:
case AxisType.PRECEDING0:
case AxisType.FOLLOWING0:
if ((result = process_DDFP(vn)) != -2)
return result;
break;
case AxisType.DESCENDANT_OR_SELF:
case AxisType.DESCENDANT:
case AxisType.PRECEDING:
case AxisType.FOLLOWING:
if ((result = process_DDFP2(vn)) != -2)
return result;
break;
case AxisType.PARENT:
if ((result = process_parent(vn)) != -2)
return result;
break;
case AxisType.ANCESTOR:
if ((result = process_ancestor2(vn)) != -2)
return result;
break;
case AxisType.ANCESTOR_OR_SELF:
if ((result = process_ancestor_or_self2(vn)) != -2)
return result;
break;
case AxisType.SELF:
if ((result = process_self2(vn)) != -2)
return result;
break;
case AxisType.FOLLOWING_SIBLING:
if ((result = process_following_sibling2(vn)) != -2)
return result;
break;
case AxisType.FOLLOWING_SIBLING0:
if ((result = process_following_sibling(vn)) != -2)
return result;
break;
case AxisType.PRECEDING_SIBLING:
if ((result = process_preceding_sibling2(vn)) != -2)
return result;
break;
case AxisType.PRECEDING_SIBLING0:
if ((result = process_preceding_sibling(vn)) != -2)
return result;
break;
case AxisType.ATTRIBUTE:
if ((result = process_attribute(vn)) != -2)
return result;
break;
default:
if ((result = process_namespace(vn)) != -2)
return result;
break;
}
}
}
示例6: process_parent
private int process_parent(VTDNav vn)
{
bool b1 = false;
Predicate t = null;
int result;
switch (state)
{
case START:
case FORWARD:
t = currentStep.p;
while (t != null)
{
if (t.requireContext)
{
int i = computeContextSize(t, vn);
if (i == 0)
{
b1 = true;
break;
}
else
t.ContextSize=(i);
}
t = t.nextP;
}
if (b1)
{
if (state == FORWARD)
{
state = BACKWARD;
currentStep = currentStep.prevS;
}
else
state = END;
break;
}
if (vn.getCurrentDepth() == -1)
{
if (state == START)
state = END;
else
{
//vn.pop();
state = BACKWARD;
currentStep = currentStep.prevS;
}
}
else
{
vn.push2();
vn.toElement(VTDNav.P); // must return true
if ((currentStep.nt_eval || currentStep.nt.eval(vn))
&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn)))
{
if (currentStep.nextS != null)
{
state = FORWARD;
currentStep = currentStep.nextS;
}
else
{
state = TERMINAL;
result = vn.getCurrentIndex2();
if (isUnique(result))
return result;
}
}
else
{
vn.pop2();
if (currentStep.hasPredicate)
currentStep.resetP(vn);
if (state == START)
state = END;
else
{
state = BACKWARD;
currentStep = currentStep.prevS;
}
}
}
break;
case END:
currentStep = null;
// reset();
return -1;
case BACKWARD:
case TERMINAL:
if (currentStep.prevS == null)
{
vn.pop2();
state = END;
break;
}
else
{
//.........这里部分代码省略.........
示例7: transition_child
protected internal void transition_child(VTDNav vn)
{
vn.toElement(VTDNav.P);
if (currentStep.prevS != null){
currentStep = currentStep.prevS;
state = BACKWARD;
}else{
state = END;
}
}
示例8: process_child
private int process_child(VTDNav vn)
{
int result;
bool b = false, b1 = false;
int k=1;
Predicate t= null;
// Console.WriteLine(" index-============= " + vn.getCurrentIndex());
// Console.WriteLine(" depth ==============" + vn.getCurrentDepth());
switch(state){
case START:
//if (currentStep.nt.testType < NodeTest.TEXT){
// first search for any predicate that
// requires contextSize
// if so, compute its context size
// if size > 0
// set context
// if size ==0
// immediately set the state to backward or end
t = currentStep.p;
while(t!=null){
if (t.requireContext){
int i = computeContextSize(t,vn);
if (i==0){
b1 = true;
break;
}else
t.ContextSize=(i);
}
t = t.nextP;
}
if (b1){
state = END;
break;
}
b=vn.toElement(VTDNav.FIRST_CHILD);
state = END;
if (b ){
do {
if ((currentStep.nt_eval || currentStep.nt.eval(vn))
&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
if (currentStep.nextS != null){
//currentStep.position++;
state = FORWARD;
currentStep = currentStep.nextS;
}
else {
state = TERMINAL;
result = vn.getCurrentIndex2();
if ( isUnique(result)){
return result;
}
}
break;
}
} while (vn.toElement(VTDNav.NS));
if (state == END)
vn.toElement(VTDNav.PARENT);
}
break;
case END:
currentStep =null;
// reset();
return -1;
case FORWARD:
//if (currentStep.nt.testType < NodeTest.TEXT){
t = currentStep.p;
while(t!=null){
if (t.requireContext){
int i = computeContextSize(t,vn);
if (i==0){
b1 = true;
break;
}else
t.ContextSize=(i);
}
t = t.nextP;
}
if (b1){
currentStep = currentStep.prevS;
state = BACKWARD;
break;
}
state = BACKWARD;
if (vn.toElement(VTDNav.FC)) {
do {
if ((currentStep.nt_eval || currentStep.nt.eval(vn))
&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
if (currentStep.nextS != null) {
state = FORWARD;
currentStep = currentStep.nextS;
} else {
state = TERMINAL;
result = vn.getCurrentIndex2();
if ( isUnique(result))
return result;
}
//.........这里部分代码省略.........
示例9: lang
/// <summary>
///
/// </summary>
/// <param name="vn"></param>
/// <param name="s"></param>
/// <returns></returns>
private bool lang(VTDNav vn, String s)
{
// check the length of s
bool b = false;
vn.push2();
try
{
while (vn.getCurrentDepth() >= 0)
{
int i = vn.getAttrVal("xml:lang");
if (i != -1)
{
b = vn.matchTokenString(i, s);
break;
}
vn.toElement(VTDNav.P);
}
}
catch (NavException e)
{
}
vn.pop2();
return b;
}
示例10: process_child
private int process_child(VTDNav vn)
{
int result;
bool b = false, b1 = false;
//int contextSize;
Predicate t = null;
switch (state)
{
case START:
if (currentStep.nt.testType != NodeTest.TEXT)
{
// first search for any predicate that
// requires contextSize
// if so, compute its context size
// if size > 0
// set context
// if size ==0
// immediately set the state to backward or end
t = currentStep.p;
while (t != null)
{
if (t.requireContextSize())
{
int i = computeContextSize(t, vn);
if (i == 0)
{
b1 = true;
break;
}
else
t.ContextSize = i;
}
t = t.nextP;
}
if (b1)
{
state = END;
break;
}
b = vn.toElement(VTDNav.FIRST_CHILD);
state = END;
if (b == true)
{
do
{
if (currentStep.eval(vn))
{
if (currentStep.NextStep != null)
{
//currentStep.position++;
state = FORWARD;
currentStep = currentStep.NextStep;
}
else
{
state = TERMINAL;
result = vn.getCurrentIndex();
if (isUnique(result))
{
return result;
}
}
break;
}
}
while (vn.toElement(VTDNav.NS));
if (state == END)
vn.toElement(VTDNav.PARENT);
}
}
else
{
if (vn.AtTerminal == true)
{
state = END;
}
else
{
// compute context size;
t = currentStep.p;
while (t != null)
{
if (t.requireContextSize())
{
int i = computeContextSize(t, vn);
if (i == 0)
{
b1 = true;
break;
}
else
t.ContextSize=i;
}
t = t.nextP;
}
// b1 false indicate context size is zero. no need to go any further...
if (b1)
//.........这里部分代码省略.........
示例11: computeContextSize
public int computeContextSize(Predicate p, VTDNav vn){
bool b = false;
Predicate tp = null;
int i = 0;
AutoPilot ap;
switch(currentStep.axis_type){
case AxisType.CHILD:
if (currentStep.nt.testType != NodeTest.TEXT){
b = vn.toElement(VTDNav.FIRST_CHILD);
if (b) {
do {
if (currentStep.eval(vn, p)) {
i++;
}
} while (vn.toElement(VTDNav.NS));
vn.toElement(VTDNav.PARENT);
currentStep.resetP(vn,p);
return i;
} else
return 0;
}else {
TextIter ti = new TextIter();
ti.touch(vn);
while((ti.getNext())!=-1){
if (currentStep.evalPredicates(vn,p)){
i++;
}
}
currentStep.resetP(vn,p);
return i;
}
case AxisType.DESCENDANT_OR_SELF:
case AxisType.DESCENDANT:
case AxisType.PRECEDING:
case AxisType.FOLLOWING:
String helper = null;
if (currentStep.nt.testType == NodeTest.NODE){
helper = "*";
}else {
helper = currentStep.nt.nodeName;
}
ap = new AutoPilot(vn);
if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF )
if (currentStep.nt.testType == NodeTest.NODE)
ap.Special = true;
else
ap.Special = false;
//currentStep.o = ap = new AutoPilot(vn);
if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF)
if (currentStep.nt.localName!=null)
ap.selectElementNS(currentStep.nt.URL,currentStep.nt.localName);
else
ap.selectElement(helper);
else if (currentStep.axis_type == AxisType.DESCENDANT)
if (currentStep.nt.localName!=null)
ap.selectElementNS_D(currentStep.nt.URL,currentStep.nt.localName);
else
ap.selectElement_D(helper);
else if (currentStep.axis_type == AxisType.PRECEDING)
if (currentStep.nt.localName!=null)
ap.selectElementNS_P(currentStep.nt.URL,currentStep.nt.localName);
else
ap.selectElement_P(helper);
else
if (currentStep.nt.localName!=null)
ap.selectElementNS_F(currentStep.nt.URL,currentStep.nt.localName);
else
ap.selectElement_F(helper);
vn.push2();
while(ap.iterate()){
if (currentStep.evalPredicates(vn,p)){
i++;
}
}
vn.pop2();
currentStep.resetP(vn,p);
return i;
case AxisType.PARENT:
vn.push2();
i = 0;
if (vn.toElement(VTDNav.PARENT)){
if (currentStep.eval(vn,p)){
i++;
}
}
vn.pop2();
currentStep.resetP(vn,p);
return i;
case AxisType.ANCESTOR:
vn.push2();
i = 0;
while (vn.toElement(VTDNav.PARENT)) {
if (currentStep.eval(vn, p)) {
i++;
}
//.........这里部分代码省略.........
示例12: process_preceding_sibling
private int process_preceding_sibling(VTDNav vn)
{
bool b = false, b1 = false;
//int contextSize;
Predicate t = null;
int result;
switch (state)
{
case START:
case FORWARD:
t = currentStep.p;
while (t != null)
{
if (t.requireContextSize())
{
int i = computeContextSize(t, vn);
if (i == 0)
{
b1 = true;
break;
}
else
t.ContextSize = i;
}
t = t.nextP;
}
if (b1)
{
if (state == FORWARD)
{
state = BACKWARD;
currentStep = currentStep.PrevStep;
}
else
state = END;
break;
}
if (state == START)
state = END;
else
state = BACKWARD;
vn.push2();
while (vn.toElement(VTDNav.PS))
{
if (currentStep.eval(vn))
{
if (currentStep.NextStep != null)
{
state = FORWARD;
currentStep = currentStep.NextStep;
break;
}
else
{
state = TERMINAL;
result = vn.getCurrentIndex();
if (isUnique(result))
return result;
}
}
}
if (state == END)
{
currentStep.resetP(vn);
vn.pop2();
}
else if (state == BACKWARD)
{
currentStep.resetP(vn);
vn.pop2();
currentStep = currentStep.PrevStep;
}
break;
case END:
currentStep = null;
// reset();
return - 1;
case BACKWARD:
while (vn.toElement(VTDNav.PS))
{
if (currentStep.eval(vn))
{
if (currentStep.NextStep != null)
{
state = FORWARD;
currentStep = currentStep.NextStep;
b = true;
break;
}
else
{
state = TERMINAL;
result = vn.getCurrentIndex();
if (isUnique(result))
//.........这里部分代码省略.........
示例13: process_ancestor_or_self
private int process_ancestor_or_self(VTDNav vn)
{
bool b = false, b1 = false;
Predicate t = null;
int result;
switch (state)
{
case START:
t = currentStep.p;
while (t != null)
{
if (t.requireContext)
{
int i = computeContextSize(t, vn);
if (i == 0)
{
b1 = true;
break;
}
else
t.ContextSize=(i);
}
t = t.nextP;
}
if (b1)
{
state = END;
break;
}
state = END;
vn.push2();
if (currentStep.ft)
{
currentStep.ft = false;
if ((currentStep.nt_eval || currentStep.nt.eval(vn))
&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn)))
{
if (currentStep.nextS != null)
{
state = FORWARD;
currentStep = currentStep.nextS;
break;
}
else
{
//vn.pop();
state = TERMINAL;
if (vn.atTerminal)
result = vn.LN;
else
result = vn.getCurrentIndex();
if (isUnique(result))
return result;
}
}
}
while (vn.toElement(VTDNav.P))
{
if ((currentStep.nt_eval || currentStep.nt.eval(vn))
&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn)))
{
if (currentStep.nextS != null)
{
state = FORWARD;
currentStep = currentStep.nextS;
break;
}
else
{
//vn.pop();
state = TERMINAL;
result = vn.getCurrentIndex();
if (isUnique(result))
return result;
}
}
}
if (state == END)
{
if (currentStep.hasPredicate)
currentStep.resetP(vn);
vn.pop2();
}
break;
case FORWARD:
t = currentStep.p;
while (t != null)
{
if (t.requireContext)
{
int i = computeContextSize(t, vn);
if (i == 0)
{
b1 = true;
break;
//.........这里部分代码省略.........