⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpathparser.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		nodeType = (name.toString().equals("*")) ? -1				: _xsltc.registerNamespacePrefix(name);;            }	    else {		final String uri = name.getNamespace();		final String local = name.getLocalPart();		final QName namespace_uri = 		    _parser.getQNameIgnoreDefaultNs("namespace-uri");		// Expand {uri}:* to *[namespace-uri() = 'uri'] - same for @*		if (uri != null && (local.equals("*") || local.equals("@*"))) {		    if (predicates == null) {			predicates = new Vector(2);		    }		    // Priority is set by hand if no other predicates exist		    setPriority = (predicates.size() == 0);		    predicates.add(			new Predicate(			    new EqualityExpr(Operators.EQ, 				new NamespaceUriCall(namespace_uri), 				new LiteralExpr(uri))));		}		if (local.equals("*")) {		    nodeType = (axis == Axis.ATTRIBUTE) ? NodeTest.ATTRIBUTE			: NodeTest.ELEMENT;		}		else if (local.equals("@*")) {		    nodeType = NodeTest.ATTRIBUTE;		}		else {		    nodeType = (axis == Axis.ATTRIBUTE) ? _xsltc.registerAttribute(name)			: _xsltc.registerElement(name); 		}	    }	    final StepPattern result = new StepPattern(axis, nodeType, predicates); 	    // Set priority for case prefix:* and prefix:@* (no predicates)	    if (setPriority) {		result.setPriority(-0.25);	    }	    return result;	}    }    public int findNodeType(int axis, Object test) {	if (test == null) {  // *	    return (axis == Axis.ATTRIBUTE) ? 		NodeTest.ATTRIBUTE :		(axis == Axis.NAMESPACE) ? -1 : NodeTest.ELEMENT;        }        else if (test instanceof Integer) {            return ((Integer)test).intValue();        }        else {	    QName name = (QName)test;	    if (axis == Axis.NAMESPACE) {		return (name.toString().equals("*")) ? -1		    : _xsltc.registerNamespacePrefix(name);            }	    if (name.getNamespace() == null) {		final String local = name.getLocalPart();		if (local.equals("*")) {		    return (axis == Axis.ATTRIBUTE) ? NodeTest.ATTRIBUTE			: NodeTest.ELEMENT;		}		else if (local.equals("@*")) {		    return NodeTest.ATTRIBUTE;		}	    }	    return (axis == Axis.ATTRIBUTE) ? _xsltc.registerAttribute(name)		: _xsltc.registerElement(name);         }    }    /**     * Parse the expression passed to the current scanner. If this     * expression contains references to local variables and it will be      * compiled in an external module (not in the main class) request      * the current template to create a new variable stack frame.     *     * @param lineNumber Line where the current expression is defined.     * @param external   Set to <tt>true</tt> if this expression is     *                   compiled in a separate module.     *      */    public Symbol parse(String expression, int lineNumber) throws Exception {        try {	    _expression = expression;	    _lineNumber = lineNumber;	    return super.parse();        }        catch (IllegalCharException e) {            ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_CHAR_ERR,                                        lineNumber, e.getMessage());            _parser.reportError(Constants.FATAL, err);        }        return null;    }    /**     * Lookup a variable or parameter in the symbol table given its name.      *     * @param name Name of the symbol being looked up.     */    final SyntaxTreeNode lookupName(QName name) {        // Is it a local var or param ?        final SyntaxTreeNode result = _parser.lookupVariable(name);	if (result != null)            return(result);        else	    return(_symbolTable.lookupName(name));    }    public final void addError(ErrorMsg error) {	_parser.reportError(Constants.ERROR, error);    }                public void report_error(String message, Object info) {	final ErrorMsg err = new ErrorMsg(ErrorMsg.SYNTAX_ERR, _lineNumber, 	    _expression);	_parser.reportError(Constants.FATAL, err);    }    public void report_fatal_error(String message, Object info) {        // empty    }        public RelativeLocationPath insertStep(Step step, RelativeLocationPath rlp) {	if (rlp instanceof Step) {	    return new ParentLocationPath(step, (Step) rlp);	}	else if (rlp instanceof ParentLocationPath) {	    final ParentLocationPath plp = (ParentLocationPath) rlp;	    final RelativeLocationPath newrlp = insertStep(step, plp.getPath());	    return new ParentLocationPath(newrlp, plp.getStep());	}	else {	    addError(new ErrorMsg(ErrorMsg.INTERNAL_ERR, "XPathParser.insertStep"));	    return rlp;	}    }    /**     * Returns true if the axis applies to elements only. The axes     * child, attribute, namespace, descendant result in non-empty     * nodesets only if the context node is of type element.     */    public boolean isElementAxis(int axis) {	return (axis == Axis.CHILD || axis == Axis.ATTRIBUTE ||		axis == Axis.NAMESPACE || axis == Axis.DESCENDANT);    }}/** Cup generated class to encapsulate user supplied action code.*/class CUP$XPathParser$actions {  private final XPathParser parser;  /** Constructor */  CUP$XPathParser$actions(XPathParser parser) {    this.parser = parser;  }  /** Method with the actual generated action code. */  public final com.sun.java_cup.internal.runtime.Symbol CUP$XPathParser$do_action(    int                        CUP$XPathParser$act_num,    com.sun.java_cup.internal.runtime.lr_parser CUP$XPathParser$parser,    java.util.Stack            CUP$XPathParser$stack,    int                        CUP$XPathParser$top)    throws java.lang.Exception    {      /* Symbol object for return from actions */      com.sun.java_cup.internal.runtime.Symbol CUP$XPathParser$result;      /* select the action based on the action number */      switch (CUP$XPathParser$act_num)        {          /*. . . . . . . . . . . . . . . . . . . .*/          case 140: // QName ::= ID             {              QName RESULT = null;		 RESULT = parser.getQNameIgnoreDefaultNs("id");               CUP$XPathParser$result = new com.sun.java_cup.internal.runtime.Symbol(37/*QName*/, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).left, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).right, RESULT);            }          return CUP$XPathParser$result;          /*. . . . . . . . . . . . . . . . . . . .*/          case 139: // QName ::= SELF             {              QName RESULT = null;		 RESULT = parser.getQNameIgnoreDefaultNs("self");               CUP$XPathParser$result = new com.sun.java_cup.internal.runtime.Symbol(37/*QName*/, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).left, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).right, RESULT);            }          return CUP$XPathParser$result;          /*. . . . . . . . . . . . . . . . . . . .*/          case 138: // QName ::= PRECEDINGSIBLING             {              QName RESULT = null;		 RESULT = parser.getQNameIgnoreDefaultNs("preceding-sibling");               CUP$XPathParser$result = new com.sun.java_cup.internal.runtime.Symbol(37/*QName*/, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).left, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).right, RESULT);            }          return CUP$XPathParser$result;          /*. . . . . . . . . . . . . . . . . . . .*/          case 137: // QName ::= PRECEDING             {              QName RESULT = null;		 RESULT = parser.getQNameIgnoreDefaultNs("preceding");               CUP$XPathParser$result = new com.sun.java_cup.internal.runtime.Symbol(37/*QName*/, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).left, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).right, RESULT);            }          return CUP$XPathParser$result;          /*. . . . . . . . . . . . . . . . . . . .*/          case 136: // QName ::= PARENT             {              QName RESULT = null;		 RESULT = parser.getQNameIgnoreDefaultNs("parent");               CUP$XPathParser$result = new com.sun.java_cup.internal.runtime.Symbol(37/*QName*/, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).left, ((com.sun.java_cup.internal.runtime.Symbol)CUP$XPathParser$stack.elementAt(CUP$XPathParser$top-0)).right, RESULT);            }          return CUP$XPathParser$result;          /*. . . . . . . . . . . . . . . . . . . .*/          case 135: // QName ::= NAMESPACE             {              QName RESULT = null;		 RESULT = parser.getQNameIgnoreDefaultNs("namesp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -