switch (dtm.getNodeType(contextNode)) countMatchPattern = new XPath(dtm.getNodeName(contextNode), this, resolver, XPath.MATCH, support.getErrorListener()); break; countMatchPattern = new XPath("@" + dtm.getNodeName(contextNode), this, this, XPath.MATCH, support.getErrorListener()); break; case DTM.CDATA_SECTION_NODE : countMatchPattern = new XPath("text()", this, this, XPath.MATCH, support.getErrorListener()); break; case DTM.COMMENT_NODE : countMatchPattern = new XPath("comment()", this, this, XPath.MATCH, support.getErrorListener()); break; case DTM.DOCUMENT_NODE : countMatchPattern = new XPath("/", this, this, XPath.MATCH, support.getErrorListener()); break; case DTM.PROCESSING_INSTRUCTION_NODE : countMatchPattern = new XPath("pi(" + dtm.getNodeName(contextNode) + ")", this, this, XPath.MATCH, support.getErrorListener()); break;
private XObject eval(String expression, Object contextItem) throws javax.xml.transform.TransformerException { org.apache.xpath.XPath xpath = new org.apache.xpath.XPath( expression, null, prefixResolver, org.apache.xpath.XPath.SELECT ); org.apache.xpath.XPathContext xpathSupport = null; // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 // expressions. if ( functionResolver != null ) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( functionResolver, featureSecureProcessing ); xpathSupport = new org.apache.xpath.XPathContext(jep, false); } else { xpathSupport = new org.apache.xpath.XPathContext(false); } XObject xobj = null; xpathSupport.setVarStack(new JAXPVariableStack(variableResolver)); // If item is null, then we will create a a Dummy contextNode if ( contextItem instanceof Node ) { xobj = xpath.execute (xpathSupport, (Node)contextItem, prefixResolver ); } else { xobj = xpath.execute ( xpathSupport, DTM.NULL, prefixResolver ); } return xobj; }
/** * Set the "select" attribute. * * @param xpath The XPath expression for the "select" attribute. */ public void setSelect(XPath xpath) { m_selectExpression = xpath.getExpression(); // The following line is part of the codes added to fix bug#16889 // Store xpath which will be needed when firing Selected Event m_xpath = xpath; }
/** * Construct an XPath object. * * @param expr The Expression object. * * @throws javax.xml.transform.TransformerException if syntax or other error. */ public XPath(Expression expr) { this.setExpression(expr); initFunctionTable(); }
/** * Process an expression string into an XPath. * * @param str A non-null reference to a valid or invalid match pattern string. * * @return A non-null reference to an XPath object that represents the string argument. * * @throws javax.xml.transform.TransformerException if the pattern can not be processed. * @see <a href="http://www.w3.org/TR/xslt#patterns">Section 5.2 Patterns in XSLT Specification</a> */ XPath createMatchPatternXPath(String str, ElemTemplateElement owningTemplate) throws javax.xml.transform.TransformerException { ErrorListener handler = m_stylesheetProcessor.getErrorListener(); XPath xpath = new XPath(str, owningTemplate, this, XPath.MATCH, handler, m_funcTable); // Visit the expression, registering namespaces for any extension functions it includes. xpath.callVisitors(xpath, new ExpressionVisitor(getStylesheetRoot())); return xpath; }
xctxt.pushNamespaceContext(namespaceContext); xctxt.pushCurrentNodeAndExpression(contextNode, contextNode); te.setLocator(this.getLocator()); ErrorListener el = xctxt.getErrorListener(); if(null != el) // defensive, should never happen. msg = XSLMessages.createXPATHMessage( XPATHErrorResources.ER_XPATH_ERROR, null); TransformerException te = new TransformerException(msg, getLocator(), e); ErrorListener el = xctxt.getErrorListener();
int sourceNode = xctxt.getCurrentNode(); XObject value = m_selectExpression.execute(xctxt, sourceNode, this); int type = value.getType(); String s; case XObject.CLASS_NUMBER : case XObject.CLASS_STRING : s = value.str(); DTMIterator nl = value.iter(); DTM dtm = xctxt.getDTMManager().getDTM(pos); short t = dtm.getNodeType(pos); for (int child = dtm.getFirstChild(pos); child != DTM.NULL; child = dtm.getNextSibling(child)) throw new TransformerException(se);
xctxt.pushNamespaceContext(this); int current = xctxt.getCurrentNode(); xctxt.pushCurrentNodeAndExpression(current, current); Expression expr = m_selectExpression.getExpression(); throw new TransformerException(se); TransformerException te = new TransformerException(re); te.setLocator(this); throw te;
/** * @see org.w3c.dom.xpath.XPathResult#getBooleanValue() */ public boolean getBooleanValue() throws XPathException { if (getResultType() != BOOLEAN_TYPE) { String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_BOOLEAN, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)}); throw new XPathException(XPathException.TYPE_ERR,fmsg); // "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a boolean." } else { try { return m_resultObj.bool(); } catch (TransformerException e) { // Type check above should prevent this exception from occurring. throw new XPathException(XPathException.TYPE_ERR,e.getMessage()); } } }
xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext(); else throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); xctxt.pushContextNodeList(contextNodes); xctxt.pushCurrentNode(contextNode); XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(), xctxt.getNamespaceContext(), XPath.SELECT); result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num();
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_SINGLENODE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)}); throw new XPathException(XPathException.TYPE_ERR,fmsg); result = m_resultObj.nodeset(); } catch (TransformerException te) { throw new XPathException(XPathException.TYPE_ERR,te.getMessage());
String idIs = XSLMessages.createMessage(((null != template.getName()) ? "nameIs" : "matchPatternIs"), null); Object[] msgArgs = new Object[]{ new Integer(loopCount), idIs, ((null != template.getName()) ? template.getName().toString() : template.getMatch().getPatternString()) }; String msg = XSLMessages.createMessage("recursionTooDeep", msgArgs); throw new TransformerException(msg);
XObject r1 = k.m_selectPat.execute(m_execContext, n1.m_node, k.m_namespaceContext); XObject r2 = k.m_selectPat.execute(m_execContext, n2.m_node, k.m_namespaceContext); n1Num = r1.num(); n2Num = r2.num(); XObject r1 = k.m_selectPat.execute(m_execContext, n1.m_node, k.m_namespaceContext); XObject r2 = k.m_selectPat.execute(m_execContext, n2.m_node, k.m_namespaceContext); n1String = k.m_col.getCollationKey(r1.str()); n2String = k.m_col.getCollationKey(r2.str()); DTM dtm = support.getDTM(n1.m_node); // %OPT% result = dtm.isNodeAfter(n1.m_node, n2.m_node) ? -1 : 1;
throws javax.xml.transform.TransformerException DTM dtm = xctxt.getDTM(context); while (DTM.NULL != context) if (fromMatchPattern.getMatchScore(xctxt, context) != XPath.MATCH_SCORE_NONE) if (countMatchPattern.getMatchScore(xctxt, context) != XPath.MATCH_SCORE_NONE) int prevSibling = dtm.getPreviousSibling(context); context = dtm.getParent(context); context = dtm.getLastChild(prevSibling);
int sourceNode = xctxt.getCurrentNode(); XObject test = m_test.execute(xctxt, sourceNode, this); transformer.getTraceManager().fireTraceEvent(this); if (test.bool()) else if (m_test.bool(xctxt, sourceNode, this))
(KeyDeclaration) keyDecls.elementAt(keyDeclIdx); XObject xuse = keyDeclaration.getUse().execute(xctxt, currentNode, ki.getPrefixResolver()); if (xuse.getType() != xuse.CLASS_NODESET) { XMLString exprResult = xuse.xstr(); addValueInRefsTable(xctxt, exprResult, currentNode); } else { DTM dtm = xctxt.getDTM(currentNodeInUseClause); XMLString exprResult = dtm.getStringValue(currentNodeInUseClause); addValueInRefsTable(xctxt, exprResult, currentNode);
XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(), xctxt.getNamespaceContext(), XPath.SELECT); return dynamicXPath.execute(xctxt, myContext.getContextNode(), xctxt.getNamespaceContext()); throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); //"Invalid context passed to evaluate "
XPath xpath = new XPath(xpathQuery, null, customPrefixResolver, XPath.SELECT, null); int ctxtNode = xpathContext.getDTMHandleFromNode(node); XObject xresult = xpath.execute(xpathContext, ctxtNode, customPrefixResolver); if (xresult instanceof XNodeSet) { NodeListModel result = new NodeListModel(node); result.xpathSupport = this; NodeIterator nodeIterator = xresult.nodeset(); Node n; do { return new SimpleScalar(xresult.toString());
int nodeHandler = ((DTMNodeProxy) sourceNode).getDTMNodeNumber(); locator = ((DTMNodeProxy) sourceNode).getDTM().getSourceLocatorFor( nodeHandler); + ev.m_attributeName + "='" + ev.m_xpath.getPatternString() + "': "); } else { if (ev.m_selection.getType() == ev.m_selection.CLASS_NODESET) { m_pw.println(); org.apache.xml.dtm.DTMIterator nl = ev.m_selection.iter(); while (DTM.NULL != pos) { DTM dtm = ev.m_processor.getXPathContext().getDTM(pos); m_pw.print(" "); m_pw.print(Integer.toHexString(pos)); m_pw.print(": "); m_pw.println(dtm.getNodeName(pos)); pos = clone.nextNode(); m_pw.println(ev.m_selection.str());
XPath myxpath = new XPath(fileNameExpr, elem, xctxt.getNamespaceContext(), XPath.SELECT); XObject xobj = myxpath.execute(xctxt, context.getContextNode(), elem); fileName = xobj.str(); if((null == fileName) || (fileName.length() == 0))