List of usage examples for org.w3c.dom Node getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.Document.java
/** * Create a new HTML element with the given tag name. * * @param tagName the tag name/*from w w w.ja v a2 s.c o m*/ * @return the new HTML element, or NOT_FOUND if the tag is not supported */ @JsxFunction public Object createElement(String tagName) { Object result = NOT_FOUND; try { final BrowserVersion browserVersion = getBrowserVersion(); // FF3.6 supports document.createElement('div') or supports document.createElement('<div>') // but not document.createElement('<div name="test">') // IE9- supports also document.createElement('<div name="test">') // FF4+ and IE11 don't support document.createElement('<div>') if (browserVersion.hasFeature(BrowserVersionFeatures.JS_DOCUMENT_CREATE_ELEMENT_STRICT) && (tagName.contains("<") || tagName.contains(">"))) { LOG.info("createElement: Provided string '" + tagName + "' contains an invalid character; '<' and '>' are not allowed"); throw Context.reportRuntimeError("String contains an invalid character"); } else if (tagName.startsWith("<") && tagName.endsWith(">")) { tagName = tagName.substring(1, tagName.length() - 1); final Matcher matcher = TAG_NAME_PATTERN.matcher(tagName); if (!matcher.matches()) { LOG.info("createElement: Provided string '" + tagName + "' contains an invalid character"); throw Context.reportRuntimeError("String contains an invalid character"); } } final SgmlPage page = getPage(); final org.w3c.dom.Node element = page.createElement(tagName); if (element instanceof BaseFrameElement) { ((BaseFrameElement) element).markAsCreatedByJavascript(); } else if (element instanceof HtmlInput) { ((HtmlInput) element).markAsCreatedByJavascript(); } else if (element instanceof HtmlImage) { ((HtmlImage) element).markAsCreatedByJavascript(); } else if (element instanceof HtmlKeygen) { ((HtmlKeygen) element).markAsCreatedByJavascript(); } else if (element instanceof HtmlRp) { ((HtmlRp) element).markAsCreatedByJavascript(); } else if (element instanceof HtmlRt) { ((HtmlRt) element).markAsCreatedByJavascript(); } else if (element instanceof HtmlUnknownElement) { ((HtmlUnknownElement) element).markAsCreatedByJavascript(); } final Object jsElement = getScriptableFor(element); if (jsElement == NOT_FOUND) { if (LOG.isDebugEnabled()) { LOG.debug("createElement(" + tagName + ") cannot return a result as there isn't a JavaScript object for the element " + element.getClass().getName()); } } else { result = jsElement; } } catch (final ElementNotFoundException e) { // Just fall through - result is already set to NOT_FOUND } return result; }
From source file:XMLDocumentWriter.java
/** * Output the specified DOM Node object, printing it using the specified * indentation string//from ww w. ja v a 2 s . com */ public void write(Node node, String indent) { // The output depends on the type of the node switch (node.getNodeType()) { case Node.DOCUMENT_NODE: { // If its a Document node Document doc = (Document) node; out.println(indent + "<?xml version='1.0'?>"); // Output header Node child = doc.getFirstChild(); // Get the first node while (child != null) { // Loop 'till no more nodes write(child, indent); // Output node child = child.getNextSibling(); // Get next node } break; } case Node.DOCUMENT_TYPE_NODE: { // It is a <!DOCTYPE> tag DocumentType doctype = (DocumentType) node; // Note that the DOM Level 1 does not give us information about // the the public or system ids of the doctype, so we can't output // a complete <!DOCTYPE> tag here. We can do better with Level 2. out.println("<!DOCTYPE " + doctype.getName() + ">"); break; } case Node.ELEMENT_NODE: { // Most nodes are Elements Element elt = (Element) node; out.print(indent + "<" + elt.getTagName()); // Begin start tag NamedNodeMap attrs = elt.getAttributes(); // Get attributes for (int i = 0; i < attrs.getLength(); i++) { // Loop through them Node a = attrs.item(i); out.print(" " + a.getNodeName() + "='" + // Print attr. name fixup(a.getNodeValue()) + "'"); // Print attr. value } out.println(">"); // Finish start tag String newindent = indent + " "; // Increase indent Node child = elt.getFirstChild(); // Get child while (child != null) { // Loop write(child, newindent); // Output child child = child.getNextSibling(); // Get next child } out.println(indent + "</" + // Output end tag elt.getTagName() + ">"); break; } case Node.TEXT_NODE: { // Plain text node Text textNode = (Text) node; String text = textNode.getData().trim(); // Strip off space if ((text != null) && text.length() > 0) // If non-empty out.println(indent + fixup(text)); // print text break; } case Node.PROCESSING_INSTRUCTION_NODE: { // Handle PI nodes ProcessingInstruction pi = (ProcessingInstruction) node; out.println(indent + "<?" + pi.getTarget() + " " + pi.getData() + "?>"); break; } case Node.ENTITY_REFERENCE_NODE: { // Handle entities out.println(indent + "&" + node.getNodeName() + ";"); break; } case Node.CDATA_SECTION_NODE: { // Output CDATA sections CDATASection cdata = (CDATASection) node; // Careful! Don't put a CDATA section in the program itself! out.println(indent + "<" + "![CDATA[" + cdata.getData() + "]]" + ">"); break; } case Node.COMMENT_NODE: { // Comments Comment c = (Comment) node; out.println(indent + "<!--" + c.getData() + "-->"); break; } default: // Hopefully, this won't happen too much! System.err.println("Ignoring node: " + node.getClass().getName()); break; } }
From source file:net.sourceforge.pmd.lang.ast.AbstractNode.java
private static <T> void findDescendantsOfType(final Node node, final Class<T> targetType, final List<T> results, final boolean crossFindBoundaries) { for (int i = 0; i < node.jjtGetNumChildren(); i++) { final Node child = node.jjtGetChild(i); if (targetType.isAssignableFrom(child.getClass())) { results.add(targetType.cast(child)); }// w w w . j a va 2 s.com if (crossFindBoundaries || !child.isFindBoundary()) { findDescendantsOfType(child, targetType, results, crossFindBoundaries); } } }
From source file:net.sourceforge.pmd.lang.ast.AbstractNode.java
private static <T> T getFirstDescendantOfType(final Class<T> descendantType, final Node node) { final int n = node.jjtGetNumChildren(); for (int i = 0; i < n; i++) { final Node n1 = node.jjtGetChild(i); if (descendantType.isAssignableFrom(n1.getClass())) { return descendantType.cast(n1); }/*from www .j a va 2 s . com*/ if (!n1.isFindBoundary()) { final T n2 = getFirstDescendantOfType(descendantType, n1); if (n2 != null) { return n2; } } } return null; }
From source file:nl.nn.adapterframework.parameters.Parameter.java
private Object transform(Source xmlSource, ParameterResolutionContext prc) throws ParameterException, TransformerException, IOException { TransformerPool pool = getTransformerPool(); if (TYPE_NODE.equals(getType()) || TYPE_DOMDOC.equals(getType())) { DOMResult transformResult = new DOMResult(); pool.transform(xmlSource, transformResult, prc.getValueMap(paramList)); Node result = transformResult.getNode(); if (result != null && TYPE_NODE.equals(getType())) { result = result.getFirstChild(); }// www. j a va 2 s . c o m if (log.isDebugEnabled()) { if (result != null) log.debug("Returning Node result [" + result.getClass().getName() + "][" + result + "]: " + ToStringBuilder.reflectionToString(result)); } return result; } else { return pool.transform(xmlSource, prc.getValueMap(paramList)); } }
From source file:openblocks.yacodeblocks.BlockSaveFileTest.java
private String describeNode(Node node) { if (node instanceof Element) { return "<" + node.getNodeName() + "> element"; } else if (node instanceof Attr) { return node.getNodeName() + " attribute of the " + describeNode(((Attr) node).getOwnerElement()); } else if (node instanceof Text) { return describeNode(node.getParentNode()); }// w w w .ja va2 s. com throw new IllegalArgumentException( "node must an Element, an Attr, or a Text: " + node.getClass().getName()); }
From source file:org.apache.cocoon.util.jxpath.DOMFactory.java
private void addDOMElement(Node parent, int index, String tag) { int pos = tag.indexOf(':'); String prefix = null;//from w w w.j a v a2s . c o m if (pos != -1) { prefix = tag.substring(0, pos); } String uri = null; Node child = parent.getFirstChild(); int count = 0; while (child != null) { if (child.getNodeName().equals(tag)) { count++; } child = child.getNextSibling(); } Document doc = parent.getOwnerDocument(); if (doc != null) { uri = getNamespaceURI((Element) parent, prefix); } else { if (parent instanceof Document) { doc = (Document) parent; if (prefix != null) { throw new RuntimeException("Cannot map non-null prefix " + "when creating a document element"); } } else { // Shouldn't happen (must be a DocumentType object) throw new RuntimeException("Node of class " + parent.getClass().getName() + " has null owner document " + "but is not a Document"); } } // Keep inserting new elements until we have index + 1 of them while (count <= index) { Node newElement = doc.createElementNS(uri, tag); parent.appendChild(newElement); count++; } }
From source file:org.apache.ode.bpel.rtrep.v1.ASSIGN.java
/** * Get the r-value. There are several possibilities: * <ul>//from w w w . ja v a 2 s.com * <li>a message is selected - an element representing the whole message is * returned.</li> * <li>a (element) message part is selected - the element is returned. * </li> * <li>a (typed) message part is select - a wrapper element is returned. * </li> * <li>an attribute is selected - an attribute node is returned. </li> * <li>a text node/string expression is selected - a text node is returned. * </li> * </ul> * * @param from * * @return Either {@link Element}, {@link org.w3c.dom.Text}, or * {@link org.w3c.dom.Attr} node representing the r-value. * * @throws FaultException * DOCUMENTME * @throws UnsupportedOperationException * DOCUMENTME * @throws IllegalStateException * DOCUMENTME */ private Node evalRValue(OAssign.RValue from) throws FaultException, ExternalVariableModuleException { if (__log.isDebugEnabled()) __log.debug("Evaluating FROM expression \"" + from + "\"."); Node retVal; if (from instanceof DirectRef) { OAssign.DirectRef dref = (OAssign.DirectRef) from; sendVariableReadEvent(_scopeFrame.resolve(dref.variable)); Node data = fetchVariableData(_scopeFrame.resolve(dref.variable), false); retVal = DOMUtils.findChildByName((Element) data, dref.elName); } else if (from instanceof OAssign.VariableRef) { OAssign.VariableRef varRef = (OAssign.VariableRef) from; sendVariableReadEvent(_scopeFrame.resolve(varRef.variable)); Node data = fetchVariableData(_scopeFrame.resolve(varRef.variable), false); retVal = evalQuery(data, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location, getEvaluationContext()); } else if (from instanceof OAssign.PropertyRef) { OAssign.PropertyRef propRef = (OAssign.PropertyRef) from; sendVariableReadEvent(_scopeFrame.resolve(propRef.variable)); Node data = fetchVariableData(_scopeFrame.resolve(propRef.variable), false); retVal = evalQuery(data, propRef.propertyAlias.part, propRef.propertyAlias.location, getEvaluationContext()); } else if (from instanceof OAssign.PartnerLinkRef) { OAssign.PartnerLinkRef pLinkRef = (OAssign.PartnerLinkRef) from; PartnerLinkInstance pLink = _scopeFrame.resolve(pLinkRef.partnerLink); Node tempVal = pLinkRef.isMyEndpointReference ? getBpelRuntime().fetchMyRoleEndpointReferenceData(pLink) : getBpelRuntime().fetchPartnerRoleEndpointReferenceData(pLink); if (__log.isDebugEnabled()) __log.debug("RValue is a partner link, corresponding endpoint " + tempVal.getClass().getName() + " has value " + DOMUtils.domToString(tempVal)); retVal = tempVal; } else if (from instanceof OAssign.Expression) { OExpression expr = ((OAssign.Expression) from).expression; List<Node> l = getBpelRuntime().getExpLangRuntime().evaluate(expr, getEvaluationContext()); if (l.size() == 0) { String msg = __msgs.msgRValueNoNodesSelected(expr.toString()); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg, new Throwable("ignoreMissingFromData")); } else if (l.size() > 1) { String msg = __msgs.msgRValueMultipleNodesSelected(expr.toString()); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } retVal = (Node) l.get(0); } else if (from instanceof OAssign.Literal) { Element literalRoot = ((OAssign.Literal) from).getXmlLiteral().getDocumentElement(); assert literalRoot.getLocalName().equals("literal"); // We'd like a single text node... literalRoot.normalize(); retVal = literalRoot.getFirstChild(); // Adjust for whitespace before an element. if (retVal != null && retVal.getNodeType() == Node.TEXT_NODE && retVal.getTextContent().trim().length() == 0 && retVal.getNextSibling() != null) { retVal = retVal.getNextSibling(); } if (retVal == null) { // Special case, no children --> empty TII retVal = literalRoot.getOwnerDocument().createTextNode(""); } else if (retVal.getNodeType() == Node.ELEMENT_NODE) { // Make sure there is no more elements. Node x = retVal.getNextSibling(); while (x != null) { if (x.getNodeType() == Node.ELEMENT_NODE) { String msg = __msgs.msgLiteralContainsMultipleEIIs(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } x = x.getNextSibling(); } } else if (retVal.getNodeType() == Node.TEXT_NODE) { // Make sure there are no elements following this text node. Node x = retVal.getNextSibling(); while (x != null) { if (x.getNodeType() == Node.ELEMENT_NODE) { String msg = __msgs.msgLiteralContainsMixedContent(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } x = x.getNextSibling(); } } if (retVal == null) { String msg = __msgs.msgLiteralMustContainTIIorEII(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } } else { String msg = __msgs.msgInternalError("Unknown RVALUE type: " + from); if (__log.isErrorEnabled()) __log.error(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } // Now verify we got something. if (retVal == null) { String msg = __msgs.msgEmptyRValue(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } // Now check that we got the right thing. switch (retVal.getNodeType()) { case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: case Node.ELEMENT_NODE: case Node.CDATA_SECTION_NODE: break; default: String msg = __msgs.msgInvalidRValue(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } return retVal; }
From source file:org.apache.ode.bpel.rtrep.v2.ASSIGN.java
/** * Get the r-value. There are several possibilities: * <ul>// w ww . ja va 2 s.c o m * <li>a message is selected - an element representing the whole message is * returned.</li> * <li>a (element) message part is selected - the element is returned. * </li> * <li>a (typed) message part is select - a wrapper element is returned. * </li> * <li>an attribute is selected - an attribute node is returned. </li> * <li>a text node/string expression is selected - a text node is returned. * </li> * </ul> * * @param from * * @return Either {@link Element}, {@link org.w3c.dom.Text}, or * {@link org.w3c.dom.Attr} node representing the r-value. * * @throws FaultException * DOCUMENTME * @throws UnsupportedOperationException * DOCUMENTME * @throws IllegalStateException * DOCUMENTME */ private Node evalRValue(OAssign.RValue from) throws FaultException, ExternalVariableModuleException { if (__log.isDebugEnabled()) __log.debug("Evaluating FROM expression \"" + from + "\"."); Node retVal; if (from instanceof OAssign.DirectRef) { OAssign.DirectRef dref = (OAssign.DirectRef) from; sendVariableReadEvent(_scopeFrame.resolve(dref.variable)); Node data = fetchVariableData(_scopeFrame.resolve(dref.variable), false); retVal = DOMUtils.findChildByName((Element) data, dref.elName); } else if (from instanceof OAssign.VariableRef) { OAssign.VariableRef varRef = (OAssign.VariableRef) from; sendVariableReadEvent(_scopeFrame.resolve(varRef.variable)); Node data = fetchVariableData(_scopeFrame.resolve(varRef.variable), false); retVal = evalQuery(data, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location, getEvaluationContext()); } else if (from instanceof OAssign.PropertyRef) { OAssign.PropertyRef propRef = (OAssign.PropertyRef) from; sendVariableReadEvent(_scopeFrame.resolve(propRef.variable)); Node data = fetchVariableData(_scopeFrame.resolve(propRef.variable), false); retVal = evalQuery(data, propRef.propertyAlias.part, propRef.propertyAlias.location, getEvaluationContext()); } else if (from instanceof OAssign.PartnerLinkRef) { OAssign.PartnerLinkRef pLinkRef = (OAssign.PartnerLinkRef) from; PartnerLinkInstance pLink = _scopeFrame.resolve(pLinkRef.partnerLink); Node tempVal = pLinkRef.isMyEndpointReference ? getBpelRuntime().fetchMyRoleEndpointReferenceData(pLink) : getBpelRuntime().fetchPartnerRoleEndpointReferenceData(pLink); if (__log.isDebugEnabled()) __log.debug("RValue is a partner link, corresponding endpoint " + tempVal.getClass().getName() + " has value " + DOMUtils.domToString(tempVal)); retVal = tempVal; } else if (from instanceof OAssign.Expression) { OExpression expr = ((OAssign.Expression) from).expression; List<Node> l = getBpelRuntime().getExpLangRuntime().evaluate(expr, getEvaluationContext()); if (l.size() == 0) { String msg = __msgs.msgRValueNoNodesSelected(expr.toString()); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg, new Throwable("ignoreMissingFromData")); } else if (l.size() > 1) { String msg = __msgs.msgRValueMultipleNodesSelected(expr.toString()); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } retVal = l.get(0); } else if (from instanceof OAssign.Literal) { Element literalRoot = ((OAssign.Literal) from).getXmlLiteral().getDocumentElement(); assert literalRoot.getLocalName().equals("literal"); // We'd like a single text node... literalRoot.normalize(); retVal = literalRoot.getFirstChild(); // Adjust for whitespace before an element. if (retVal != null && retVal.getNodeType() == Node.TEXT_NODE && retVal.getTextContent().trim().length() == 0 && retVal.getNextSibling() != null) { retVal = retVal.getNextSibling(); } if (retVal == null) { // Special case, no children --> empty TII retVal = literalRoot.getOwnerDocument().createTextNode(""); } else if (retVal.getNodeType() == Node.ELEMENT_NODE) { // Make sure there is no more elements. Node x = retVal.getNextSibling(); while (x != null) { if (x.getNodeType() == Node.ELEMENT_NODE) { String msg = __msgs.msgLiteralContainsMultipleEIIs(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } x = x.getNextSibling(); } } else if (retVal.getNodeType() == Node.TEXT_NODE) { // Make sure there are no elements following this text node. Node x = retVal.getNextSibling(); while (x != null) { if (x.getNodeType() == Node.ELEMENT_NODE) { String msg = __msgs.msgLiteralContainsMixedContent(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } x = x.getNextSibling(); } } if (retVal == null) { String msg = __msgs.msgLiteralMustContainTIIorEII(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } } else { String msg = __msgs.msgInternalError("Unknown RVALUE type: " + from); if (__log.isErrorEnabled()) __log.error(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } // Now verify we got something. if (retVal == null) { String msg = __msgs.msgEmptyRValue(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } // Now check that we got the right thing. switch (retVal.getNodeType()) { case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: case Node.ELEMENT_NODE: case Node.CDATA_SECTION_NODE: break; default: String msg = __msgs.msgInvalidRValue(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg); } return retVal; }
From source file:org.apache.ode.bpel.rtrep.v2.AssignHelper.java
/** * Get the r-value. There are several possibilities: * <ul>//from w w w .j a v a2 s. c om * <li>a message is selected - an element representing the whole message is * returned.</li> * <li>a (element) message part is selected - the element is returned. * </li> * <li>a (typed) message part is select - a wrapper element is returned. * </li> * <li>an attribute is selected - an attribute node is returned. </li> * <li>a text node/string expression is selected - a text node is returned. * </li> * </ul> * (madars.vitolins _at gmail.com - 2009.04.17 - moved from ASSIGN here) * @param from * * @return Either {@link Element}, {@link org.w3c.dom.Text}, or * {@link org.w3c.dom.Attr} node representing the r-value. * * @throws FaultException * DOCUMENTME * @throws UnsupportedOperationException * DOCUMENTME * @throws IllegalStateException * DOCUMENTME */ public Node evalRValue(OAssign.RValue from) throws FaultException, ExternalVariableModuleException { if (__log.isDebugEnabled()) __log.debug("Evaluating FROM expression \"" + from + "\"."); Node retVal; if (from instanceof OAssign.DirectRef) { OAssign.DirectRef dref = (OAssign.DirectRef) from; sendVariableReadEvent(_scopeFrame.resolve(dref.variable)); Node data = fetchVariableData(_scopeFrame.resolve(dref.variable), false); retVal = DOMUtils.findChildByName((Element) data, dref.elName); } else if (from instanceof OAssign.VariableRef) { OAssign.VariableRef varRef = (OAssign.VariableRef) from; sendVariableReadEvent(_scopeFrame.resolve(varRef.variable)); Node data = fetchVariableData(_scopeFrame.resolve(varRef.variable), false); retVal = evalQuery(data, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location, getEvaluationContext()); } else if (from instanceof OAssign.PropertyRef) { OAssign.PropertyRef propRef = (OAssign.PropertyRef) from; sendVariableReadEvent(_scopeFrame.resolve(propRef.variable)); Node data = fetchVariableData(_scopeFrame.resolve(propRef.variable), false); retVal = evalQuery(data, propRef.propertyAlias.part, propRef.propertyAlias.location, getEvaluationContext()); } else if (from instanceof OAssign.PartnerLinkRef) { OAssign.PartnerLinkRef pLinkRef = (OAssign.PartnerLinkRef) from; PartnerLinkInstance pLink = _scopeFrame.resolve(pLinkRef.partnerLink); Node tempVal = pLinkRef.isMyEndpointReference ? getBpelRuntime().fetchMyRoleEndpointReferenceData(pLink) : getBpelRuntime().fetchPartnerRoleEndpointReferenceData(pLink); if (__log.isDebugEnabled()) __log.debug("RValue is a partner link, corresponding endpoint " + tempVal.getClass().getName() + " has value " + DOMUtils.domToString(tempVal)); retVal = tempVal; } else if (from instanceof OAssign.ContextRef) { OAssign.ContextRef ctxRef = (OAssign.ContextRef) from; ContextData cdata = getBpelRuntime().fetchContextData(_scopeFrame.resolve(ctxRef.partnerLink)); retVal = evalQuery(cdata.toXML(ctxRef.contexts), null, ctxRef.location, getEvaluationContext()); } else if (from instanceof OAssign.Expression) { OExpression expr = ((OAssign.Expression) from).expression; List<Node> l = getBpelRuntime().getExpLangRuntime().evaluate(expr, getEvaluationContext()); if (l.size() == 0) { String msg = __msgs.msgRValueNoNodesSelected(expr.toString()); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg, new Throwable("ignoreMissingFromData")); } else if (l.size() > 1) { String msg = __msgs.msgRValueMultipleNodesSelected(expr.toString()); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg); } retVal = l.get(0); } else if (from instanceof OAssign.Literal) { Element literalRoot = ((OAssign.Literal) from).getXmlLiteral().getDocumentElement(); assert literalRoot.getLocalName().equals("literal"); // We'd like a single text node... literalRoot.normalize(); retVal = literalRoot.getFirstChild(); // Adjust for whitespace before an element. if (retVal != null && retVal.getNodeType() == Node.TEXT_NODE && retVal.getTextContent().trim().length() == 0 && retVal.getNextSibling() != null) { retVal = retVal.getNextSibling(); } if (retVal == null) { // Special case, no children --> empty TII retVal = literalRoot.getOwnerDocument().createTextNode(""); } else if (retVal.getNodeType() == Node.ELEMENT_NODE) { // Make sure there is no more elements. Node x = retVal.getNextSibling(); while (x != null) { if (x.getNodeType() == Node.ELEMENT_NODE) { String msg = __msgs.msgLiteralContainsMultipleEIIs(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg); } x = x.getNextSibling(); } } else if (retVal.getNodeType() == Node.TEXT_NODE) { // Make sure there are no elements following this text node. Node x = retVal.getNextSibling(); while (x != null) { if (x.getNodeType() == Node.ELEMENT_NODE) { String msg = __msgs.msgLiteralContainsMixedContent(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg); } x = x.getNextSibling(); } } if (retVal == null) { String msg = __msgs.msgLiteralMustContainTIIorEII(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg); } } else { String msg = __msgs.msgInternalError("Unknown RVALUE type: " + from); if (__log.isErrorEnabled()) __log.error(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg); } // Now verify we got something. if (retVal == null) { String msg = __msgs.msgEmptyRValue(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg); } // Now check that we got the right thing. switch (retVal.getNodeType()) { case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: case Node.ELEMENT_NODE: case Node.CDATA_SECTION_NODE: break; default: String msg = __msgs.msgInvalidRValue(); if (__log.isDebugEnabled()) __log.debug(from + ": " + msg); throw new FaultException(getOActivity().getOwner().constants.qnSelectionFailure, msg); } return retVal; }