List of usage examples for org.w3c.dom Node DOCUMENT_NODE
short DOCUMENT_NODE
To view the source code for org.w3c.dom Node DOCUMENT_NODE.
Click Source Link
Document
. From source file:org.apache.ode.bpel.rtrep.v1.xpath20.XPath20ExpressionRuntime.java
/** * @see org.apache.ode.bpel.explang.ExpressionLanguageRuntime#evaluate(org.apache.ode.bpel.rtrep.v1.OExpression, org.apache.ode.bpel.explang.EvaluationContext) *//*from ww w . jav a2 s. co m*/ @SuppressWarnings("unchecked") public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException { List result; Object someRes = null; try { someRes = evaluate(cexp, ctx, XPathConstants.NODESET); } catch (Exception e) { someRes = evaluate(cexp, ctx, XPathConstants.STRING); } if (someRes instanceof List) { result = (List) someRes; __log.debug("Returned list of size " + result.size()); if ((result.size() == 1) && !(result.get(0) instanceof Node)) { // Dealing with a Java class Object simpleType = result.get(0); // Dates get a separate treatment as we don't want to call toString on them String textVal; if (simpleType instanceof Date) { textVal = ISO8601DateParser.format((Date) simpleType); } else if (simpleType instanceof DurationValue) { textVal = ((DurationValue) simpleType).getStringValue(); } else { textVal = simpleType.toString(); } // Wrapping in a document Document document = DOMUtils.newDocument(); // Giving our node a parent just in case it's an LValue expression Element wrapper = document.createElement("wrapper"); Text text = document.createTextNode(textVal); wrapper.appendChild(text); document.appendChild(wrapper); result = Collections.singletonList(text); } } else if (someRes instanceof NodeList) { NodeList retVal = (NodeList) someRes; __log.debug("Returned node list of size " + retVal.getLength()); result = new ArrayList(retVal.getLength()); for (int m = 0; m < retVal.getLength(); ++m) { Node val = retVal.item(m); if (val.getNodeType() == Node.DOCUMENT_NODE) { val = ((Document) val).getDocumentElement(); } result.add(val); } } else if (someRes instanceof String) { // Wrapping in a document Document document = DOMUtils.newDocument(); Element wrapper = document.createElement("wrapper"); Text text = document.createTextNode((String) someRes); wrapper.appendChild(text); document.appendChild(wrapper); result = Collections.singletonList(text); } else { result = null; } return result; }
From source file:org.apache.ode.bpel.rtrep.v2.ASSIGN.java
private void copy(OAssign.Copy ocopy) throws FaultException, ExternalVariableModuleException { if (__log.isDebugEnabled()) __log.debug("Assign.copy(" + ocopy + ")"); ScopeEvent se;//from w w w . j a v a2 s. c om // Check for message to message - copy, we can do this efficiently in // the database. if ((ocopy.to instanceof OAssign.VariableRef && ((OAssign.VariableRef) ocopy.to).isMessageRef()) || (ocopy.from instanceof OAssign.VariableRef && ((OAssign.VariableRef) ocopy.from).isMessageRef())) { if ((ocopy.to instanceof OAssign.VariableRef && ((OAssign.VariableRef) ocopy.to).isMessageRef()) && ocopy.from instanceof OAssign.VariableRef && ((OAssign.VariableRef) ocopy.from).isMessageRef()) { final VariableInstance lval = _scopeFrame.resolve(ocopy.to.getVariable()); final VariableInstance rval = _scopeFrame.resolve(((OAssign.VariableRef) ocopy.from).getVariable()); Element lvalue = (Element) fetchVariableData(rval, false); initializeVariable(lval, lvalue); se = new VariableModificationEvent(lval.declaration.name); ((VariableModificationEvent) se).setNewValue(lvalue); } else { // This really should have been caught by the compiler. __log.fatal("Message/Non-Message Assignment, should be caught by compiler:" + ocopy); throw new FaultException(ocopy.getOwner().constants.qnSelectionFailure, "Message/Non-Message Assignment: " + ocopy); } } else { // Conventional Assignment logic. Node rvalue = evalRValue(ocopy.from); Node lvalue = evalLValue(ocopy.to); if (__log.isDebugEnabled()) { __log.debug("lvalue after eval " + lvalue); if (lvalue != null) __log.debug("content " + DOMUtils.domToString(lvalue)); } // Get a pointer within the lvalue. Node lvaluePtr = lvalue; boolean headerAssign = false; if (ocopy.to instanceof OAssign.DirectRef) { OAssign.DirectRef dref = ((OAssign.DirectRef) ocopy.to); Element el = DOMUtils.findChildByName((Element) lvalue, dref.elName); if (el == null) { el = (Element) ((Element) lvalue).appendChild(lvalue.getOwnerDocument() .createElementNS(dref.elName.getNamespaceURI(), dref.elName.getLocalPart())); } lvaluePtr = el; } else if (ocopy.to instanceof OAssign.VariableRef) { OAssign.VariableRef varRef = ((OAssign.VariableRef) ocopy.to); if (varRef.headerPart != null) headerAssign = true; lvaluePtr = evalQuery(lvalue, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location, new EvaluationContextProxy(varRef.getVariable(), lvalue)); } else if (ocopy.to instanceof OAssign.PropertyRef) { OAssign.PropertyRef propRef = ((OAssign.PropertyRef) ocopy.to); lvaluePtr = evalQuery(lvalue, propRef.propertyAlias.part, propRef.propertyAlias.location, new EvaluationContextProxy(propRef.getVariable(), lvalue)); } else if (ocopy.to instanceof OAssign.LValueExpression) { OAssign.LValueExpression lexpr = (OAssign.LValueExpression) ocopy.to; lexpr.setInsertMissingToData(ocopy.insertMissingToData); lvaluePtr = evalQuery(lvalue, null, lexpr.expression, new EvaluationContextProxy(lexpr.getVariable(), lvalue)); if (__log.isDebugEnabled()) __log.debug("lvaluePtr expr res " + lvaluePtr); } // For partner link assignmenent, the whole content is assigned. if (ocopy.to instanceof OAssign.PartnerLinkRef) { OAssign.PartnerLinkRef pLinkRef = ((OAssign.PartnerLinkRef) ocopy.to); PartnerLinkInstance plval = _scopeFrame.resolve(pLinkRef.partnerLink); replaceEndpointRefence(plval, rvalue); se = new PartnerLinkModificationEvent(((OAssign.PartnerLinkRef) ocopy.to).partnerLink.getName()); } else if (ocopy.to.getVariable().type instanceof OPropertyVarType) { // For poperty assignment, the property, the variable that points to it and the correlation set // all have the same name CorrelationSetInstance csetInstance = _scopeFrame.resolve(ocopy.to.getVariable().name); CorrelationKey ckey = new CorrelationKey(csetInstance.declaration.getId(), new String[] { rvalue.getTextContent() }); if (__log.isDebugEnabled()) __log.debug("Writing correlation " + csetInstance.getName() + " using value " + rvalue.getTextContent()); getBpelRuntime().writeCorrelation(csetInstance, ckey); se = new CorrelationSetWriteEvent(csetInstance.declaration.name, ckey); } else { // Sneakily converting the EPR if it's not the format expected by the lvalue if (ocopy.from instanceof OAssign.PartnerLinkRef) { rvalue = getBpelRuntime().convertEndpointReference((Element) rvalue, lvaluePtr); if (rvalue.getNodeType() == Node.DOCUMENT_NODE) rvalue = ((Document) rvalue).getDocumentElement(); } if (headerAssign && lvaluePtr.getParentNode().getNodeName().equals("message") && rvalue.getNodeType() == Node.ELEMENT_NODE) { lvalue = copyInto((Element) lvalue, (Element) lvaluePtr, (Element) rvalue); } else if (rvalue.getNodeType() == Node.ELEMENT_NODE && lvaluePtr.getNodeType() == Node.ELEMENT_NODE) { lvalue = replaceElement((Element) lvalue, (Element) lvaluePtr, (Element) rvalue, ocopy.keepSrcElementName); } else { lvalue = replaceContent(lvalue, lvaluePtr, rvalue.getTextContent()); } final VariableInstance lval = _scopeFrame.resolve(ocopy.to.getVariable()); if (__log.isDebugEnabled()) __log.debug("ASSIGN Writing variable '" + lval.declaration.name + "' value '" + DOMUtils.domToString(lvalue) + "'"); commitChanges(lval, lvalue); se = new VariableModificationEvent(lval.declaration.name); ((VariableModificationEvent) se).setNewValue(lvalue); } } if (ocopy.debugInfo != null) se.setLineNo(ocopy.debugInfo.startLine); sendEvent(se); }
From source file:org.apache.ode.bpel.rtrep.v2.AssignHelper.java
/** * Initializes single variable by using it's 'from-spec' * @param var/*from ww w . j av a 2s.c o m*/ * @author madars.vitolins _at gmail.com, 2009.04.17 */ public void initVar(Variable var) throws FaultException, ExternalVariableModuleException { __log.info("Initializing variable [" + var.name + "]"); // Init variable from another variable if (var.type instanceof OMessageVarType && var.from instanceof OAssign.VariableRef && ((OAssign.VariableRef) var.from).isMessageRef()) { final VariableInstance lval = _scopeFrame.resolve(var); final VariableInstance rval = _scopeFrame.resolve(((OAssign.VariableRef) var.from).getVariable()); Element lvalue = (Element) fetchVariableData(rval, false); initializeVariable(lval, lvalue); } else { Node rvalue = evalRValue(var.from); Node lvalue = evalLValue(var); // Dump r-value if (__log.isDebugEnabled()) { __log.debug("rvalue after eval " + rvalue); if (rvalue != null) __log.debug("content " + DOMUtils.domToString(rvalue)); } // Dump l-value if (__log.isDebugEnabled()) { __log.debug("lvalue after eval " + rvalue); if (lvalue != null) __log.debug("content " + DOMUtils.domToString(lvalue)); } Node lvaluePtr = lvalue; // Sneakily converting the EPR if it's not the format expected by // the lvalue if (var.from instanceof OAssign.PartnerLinkRef) { rvalue = getBpelRuntime().convertEndpointReference((Element) rvalue, lvaluePtr); if (rvalue.getNodeType() == Node.DOCUMENT_NODE) rvalue = ((Document) rvalue).getDocumentElement(); } if (rvalue.getNodeType() == Node.ELEMENT_NODE && lvaluePtr.getNodeType() == Node.ELEMENT_NODE) { lvalue = replaceElement((Element) lvalue, (Element) lvaluePtr, (Element) rvalue, true); } else { lvalue = replaceContent(lvalue, lvaluePtr, rvalue.getTextContent()); } final VariableInstance lval = _scopeFrame.resolve(var); if (__log.isDebugEnabled()) __log.debug("SCOPE initialized variable '" + lval.declaration.name + "' value '" + DOMUtils.domToString(lvalue) + "'"); // Commit changes! commitChanges(lval, lvalue); } }
From source file:org.apache.ode.bpel.rtrep.v2.xpath20.XPath20ExpressionRuntime.java
@SuppressWarnings("unchecked") public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException { List result;//w w w .j ava 2 s .c o m Object someRes = null; try { someRes = evaluate(cexp, ctx, XPathConstants.NODESET); } catch (Exception e) { someRes = evaluate(cexp, ctx, XPathConstants.STRING); } if (someRes instanceof List) { result = (List) someRes; __log.debug("Returned list of size " + result.size()); if ((result.size() == 1) && !(result.get(0) instanceof Node)) { // Dealing with a Java class Object simpleType = result.get(0); // Dates get a separate treatment as we don't want to call toString on them String textVal; if (simpleType instanceof Date) { textVal = ISO8601DateParser.format((Date) simpleType); } else if (simpleType instanceof DurationValue) { textVal = ((DurationValue) simpleType).getStringValue(); } else { textVal = simpleType.toString(); } // Wrapping in a document Document document = DOMUtils.newDocument(); // Giving our node a parent just in case it's an LValue expression Element wrapper = document.createElement("wrapper"); Text text = document.createTextNode(textVal); wrapper.appendChild(text); document.appendChild(wrapper); result = Collections.singletonList(text); } } else if (someRes instanceof NodeList) { NodeList retVal = (NodeList) someRes; __log.debug("Returned node list of size " + retVal.getLength()); result = new ArrayList(retVal.getLength()); for (int m = 0; m < retVal.getLength(); ++m) { Node val = retVal.item(m); if (val.getNodeType() == Node.DOCUMENT_NODE) { val = ((Document) val).getDocumentElement(); } result.add(val); } } else if (someRes instanceof String) { // Wrapping in a document Document document = DOMUtils.newDocument(); Element wrapper = document.createElement("wrapper"); Text text = document.createTextNode((String) someRes); wrapper.appendChild(text); document.appendChild(wrapper); result = Collections.singletonList(text); } else { result = null; } return result; }
From source file:org.apache.ode.bpel.rtrep.v2.xquery10.runtime.XQuery10ExpressionRuntime.java
/** * /*from ww w.ja v a2 s.c o m*/ * @see org.apache.ode.bpel.explang.ExpressionLanguageRuntime#evaluate(org.apache.ode.bpel.o.OExpression, * org.apache.ode.bpel.explang.EvaluationContext) */ public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException { List result; Object someRes = evaluate(cexp, ctx, XPathConstants.NODESET); if (someRes instanceof List) { result = (List) someRes; __log.debug("Returned list of size " + result.size()); if ((result.size() == 1) && !(result.get(0) instanceof Node)) { // Dealing with a Java class Object simpleType = result.get(0); // Dates get a separate treatment as we don't want to call toString on them String textVal; if (simpleType instanceof Date) { textVal = ISO8601DateParser.format((Date) simpleType); } else if (simpleType instanceof DurationValue) { textVal = ((DurationValue) simpleType).getStringValue(); } else { textVal = simpleType.toString(); } // Wrapping in a document Document d = DOMUtils.newDocument(); // Giving our node a parent just in case it's an LValue expression Element wrapper = d.createElement("wrapper"); Text text = d.createTextNode(textVal); wrapper.appendChild(text); d.appendChild(wrapper); result = Collections.singletonList(text); } } else if (someRes instanceof NodeList) { NodeList retVal = (NodeList) someRes; __log.debug("Returned node list of size " + retVal.getLength()); result = new ArrayList(retVal.getLength()); for (int m = 0; m < retVal.getLength(); ++m) { Node val = retVal.item(m); if (val.getNodeType() == Node.DOCUMENT_NODE) { val = ((Document) val).getDocumentElement(); } result.add(val); } } else { result = null; } return result; }
From source file:org.apache.ode.bpel.runtime.ASSIGN.java
private void copy(OAssign.Copy ocopy) throws FaultException, ExternalVariableModuleException { if (__log.isDebugEnabled()) __log.debug("Assign.copy(" + ocopy + ")"); ScopeEvent se;/*from w w w. jav a2 s . co m*/ // Check for message to message - copy, we can do this efficiently in // the database. if ((ocopy.to instanceof VariableRef && ((VariableRef) ocopy.to).isMessageRef()) || (ocopy.from instanceof VariableRef && ((VariableRef) ocopy.from).isMessageRef())) { if ((ocopy.to instanceof VariableRef && ((VariableRef) ocopy.to).isMessageRef()) && ocopy.from instanceof VariableRef && ((VariableRef) ocopy.from).isMessageRef()) { final VariableInstance lval = _scopeFrame.resolve(ocopy.to.getVariable()); final VariableInstance rval = _scopeFrame.resolve(((VariableRef) ocopy.from).getVariable()); Element lvalue = (Element) fetchVariableData(rval, false); initializeVariable(lval, lvalue); se = new VariableModificationEvent(lval.declaration.name); ((VariableModificationEvent) se).setNewValue(lvalue); } else { // This really should have been caught by the compiler. __log.fatal("Message/Non-Message Assignment, should be caught by compiler:" + ocopy); throw new FaultException(ocopy.getOwner().constants.qnSelectionFailure, "Message/Non-Message Assignment: " + ocopy); } } else { // Conventional Assignment logic. Node rvalue = evalRValue(ocopy.from); Node lvalue = evalLValue(ocopy.to); if (__log.isDebugEnabled()) { __log.debug("lvalue after eval " + lvalue); if (lvalue != null) __log.debug("content " + DOMUtils.domToString(lvalue)); } // Get a pointer within the lvalue. Node lvaluePtr = lvalue; boolean headerAssign = false; if (ocopy.to instanceof OAssign.DirectRef) { DirectRef dref = ((DirectRef) ocopy.to); Element el = DOMUtils.findChildByName((Element) lvalue, dref.elName); if (el == null) { el = (Element) ((Element) lvalue).appendChild(lvalue.getOwnerDocument() .createElementNS(dref.elName.getNamespaceURI(), dref.elName.getLocalPart())); } lvaluePtr = el; } else if (ocopy.to instanceof OAssign.VariableRef) { VariableRef varRef = ((VariableRef) ocopy.to); if (varRef.headerPart != null) headerAssign = true; lvaluePtr = evalQuery(lvalue, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location, new EvaluationContextProxy(varRef.getVariable(), lvalue)); } else if (ocopy.to instanceof OAssign.PropertyRef) { PropertyRef propRef = ((PropertyRef) ocopy.to); lvaluePtr = evalQuery(lvalue, propRef.propertyAlias.part, propRef.propertyAlias.location, new EvaluationContextProxy(propRef.getVariable(), lvalue)); } else if (ocopy.to instanceof OAssign.LValueExpression) { LValueExpression lexpr = (LValueExpression) ocopy.to; lexpr.setInsertMissingToData(ocopy.insertMissingToData); lvaluePtr = evalQuery(lvalue, null, lexpr.expression, new EvaluationContextProxy(lexpr.getVariable(), lvalue)); if (__log.isDebugEnabled()) __log.debug("lvaluePtr expr res " + lvaluePtr); } // For partner link assignmenent, the whole content is assigned. if (ocopy.to instanceof OAssign.PartnerLinkRef) { OAssign.PartnerLinkRef pLinkRef = ((OAssign.PartnerLinkRef) ocopy.to); PartnerLinkInstance plval = _scopeFrame.resolve(pLinkRef.partnerLink); replaceEndpointRefence(plval, rvalue); se = new PartnerLinkModificationEvent(((OAssign.PartnerLinkRef) ocopy.to).partnerLink.getName()); } else { // Sneakily converting the EPR if it's not the format expected by the lvalue if (ocopy.from instanceof OAssign.PartnerLinkRef) { rvalue = getBpelRuntimeContext().convertEndpointReference((Element) rvalue, lvaluePtr); if (rvalue.getNodeType() == Node.DOCUMENT_NODE) rvalue = ((Document) rvalue).getDocumentElement(); } Node parentNode = lvaluePtr.getParentNode(); if (headerAssign && parentNode != null && "message".equals(parentNode.getNodeName()) && rvalue.getNodeType() == Node.ELEMENT_NODE) { lvalue = copyInto((Element) lvalue, (Element) lvaluePtr, (Element) rvalue); } else if (rvalue.getNodeType() == Node.ELEMENT_NODE && lvaluePtr.getNodeType() == Node.ELEMENT_NODE) { lvalue = replaceElement((Element) lvalue, (Element) lvaluePtr, (Element) rvalue, ocopy.keepSrcElementName); } else { lvalue = replaceContent(lvalue, lvaluePtr, rvalue.getTextContent()); } final VariableInstance lval = _scopeFrame.resolve(ocopy.to.getVariable()); if (__log.isDebugEnabled()) __log.debug("ASSIGN Writing variable '" + lval.declaration.name + "' value '" + DOMUtils.domToString(lvalue) + "'"); commitChanges(lval, lvalue); se = new VariableModificationEvent(lval.declaration.name); ((VariableModificationEvent) se).setNewValue(lvalue); } } if (ocopy.debugInfo != null) se.setLineNo(ocopy.debugInfo.startLine); sendEvent(se); }
From source file:org.apache.ode.bpel.runtime.AssignHelper.java
/** * Initializes single variable by using it's 'from-spec' * @param var/*ww w. j a va2 s . c om*/ * @author madars.vitolins _at gmail.com, 2009.04.17 */ public void initVar(Variable var) throws FaultException, ExternalVariableModuleException { if (__log.isDebugEnabled()) __log.debug("Initializing variable [" + var.name + "]"); // Init variable from another variable if (var.type instanceof OMessageVarType && var.from instanceof OAssign.VariableRef && ((OAssign.VariableRef) var.from).isMessageRef()) { final VariableInstance lval = _scopeFrame.resolve(var); final VariableInstance rval = _scopeFrame.resolve(((OAssign.VariableRef) var.from).getVariable()); Element lvalue = (Element) fetchVariableData(rval, false); initializeVariable(lval, lvalue); } else { Node rvalue = evalRValue(var.from); Node lvalue = evalLValue(var); // Dump r-value if (__log.isDebugEnabled()) { __log.debug("rvalue after eval " + rvalue); if (rvalue != null) __log.debug("content " + DOMUtils.domToString(rvalue)); } // Dump l-value if (__log.isDebugEnabled()) { __log.debug("lvalue after eval " + rvalue); if (lvalue != null) __log.debug("content " + DOMUtils.domToString(lvalue)); } Node lvaluePtr = lvalue; // Sneakily converting the EPR if it's not the format expected by // the lvalue if (var.from instanceof OAssign.PartnerLinkRef) { rvalue = getBpelRuntimeContext().convertEndpointReference((Element) rvalue, lvaluePtr); if (rvalue.getNodeType() == Node.DOCUMENT_NODE) rvalue = ((Document) rvalue).getDocumentElement(); } if (rvalue.getNodeType() == Node.ELEMENT_NODE && lvaluePtr.getNodeType() == Node.ELEMENT_NODE) { lvalue = replaceElement((Element) lvalue, (Element) lvaluePtr, (Element) rvalue, true); } else { lvalue = replaceContent(lvalue, lvaluePtr, rvalue.getTextContent()); } final VariableInstance lval = _scopeFrame.resolve(var); if (__log.isDebugEnabled()) __log.debug("SCOPE initialized variable '" + lval.declaration.name + "' value '" + DOMUtils.domToString(lvalue) + "'"); // Commit changes! commitChanges(lval, lvalue); } }
From source file:org.apache.ode.bpel.runtime.AssignHelper.java
protected void copy(OAssign.Copy ocopy) throws FaultException, ExternalVariableModuleException { if (__log.isDebugEnabled()) __log.debug("Assign.copy(" + ocopy + ")"); ScopeEvent se;//from w ww. j a v a 2 s . com // Check for message to message - copy, we can do this efficiently in // the database. if ((ocopy.to instanceof VariableRef && ((VariableRef) ocopy.to).isMessageRef()) || (ocopy.from instanceof VariableRef && ((VariableRef) ocopy.from).isMessageRef())) { if ((ocopy.to instanceof VariableRef && ((VariableRef) ocopy.to).isMessageRef()) && ocopy.from instanceof VariableRef && ((VariableRef) ocopy.from).isMessageRef()) { final VariableInstance lval = _scopeFrame.resolve(ocopy.to.getVariable()); final VariableInstance rval = _scopeFrame.resolve(((VariableRef) ocopy.from).getVariable()); Element lvalue = (Element) fetchVariableData(rval, false); initializeVariable(lval, lvalue); se = new VariableModificationEvent(lval.declaration.name); ((VariableModificationEvent) se).setNewValue(lvalue); } else { // This really should have been caught by the compiler. __log.fatal("Message/Non-Message Assignment, should be caught by compiler:" + ocopy); throw new FaultException(ocopy.getOwner().constants.qnSelectionFailure, "Message/Non-Message Assignment: " + ocopy); } } else { // Conventional Assignment logic. Node rvalue = evalRValue(ocopy.from); Node lvalue = evalLValue(ocopy.to); if (__log.isDebugEnabled()) { __log.debug("lvalue after eval " + lvalue); if (lvalue != null) __log.debug("content " + DOMUtils.domToString(lvalue)); } // Get a pointer within the lvalue. Node lvaluePtr = lvalue; boolean headerAssign = false; if (ocopy.to instanceof OAssign.DirectRef) { DirectRef dref = ((DirectRef) ocopy.to); Element el = DOMUtils.findChildByName((Element) lvalue, dref.elName); if (el == null) { el = (Element) ((Element) lvalue).appendChild(lvalue.getOwnerDocument() .createElementNS(dref.elName.getNamespaceURI(), dref.elName.getLocalPart())); } lvaluePtr = el; } else if (ocopy.to instanceof OAssign.VariableRef) { VariableRef varRef = ((VariableRef) ocopy.to); if (varRef.headerPart != null) headerAssign = true; lvaluePtr = evalQuery(lvalue, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location, new EvaluationContextProxy(varRef.getVariable(), lvalue)); } else if (ocopy.to instanceof OAssign.PropertyRef) { PropertyRef propRef = ((PropertyRef) ocopy.to); lvaluePtr = evalQuery(lvalue, propRef.propertyAlias.part, propRef.propertyAlias.location, new EvaluationContextProxy(propRef.getVariable(), lvalue)); } else if (ocopy.to instanceof OAssign.LValueExpression) { LValueExpression lexpr = (LValueExpression) ocopy.to; lexpr.setInsertMissingToData(ocopy.insertMissingToData); lvaluePtr = evalQuery(lvalue, null, lexpr.expression, new EvaluationContextProxy(lexpr.getVariable(), lvalue)); if (__log.isDebugEnabled()) __log.debug("lvaluePtr expr res " + lvaluePtr); } // For partner link assignmenent, the whole content is assigned. if (ocopy.to instanceof OAssign.PartnerLinkRef) { OAssign.PartnerLinkRef pLinkRef = ((OAssign.PartnerLinkRef) ocopy.to); PartnerLinkInstance plval = _scopeFrame.resolve(pLinkRef.partnerLink); replaceEndpointRefence(plval, rvalue); se = new PartnerLinkModificationEvent(((OAssign.PartnerLinkRef) ocopy.to).partnerLink.getName()); } else { // Sneakily converting the EPR if it's not the format expected by the lvalue if (ocopy.from instanceof OAssign.PartnerLinkRef) { rvalue = getBpelRuntimeContext().convertEndpointReference((Element) rvalue, lvaluePtr); if (rvalue.getNodeType() == Node.DOCUMENT_NODE) rvalue = ((Document) rvalue).getDocumentElement(); } Node parentNode = lvaluePtr.getParentNode(); if (headerAssign && parentNode != null && "message".equals(parentNode.getNodeName()) && rvalue.getNodeType() == Node.ELEMENT_NODE) { lvalue = copyInto((Element) lvalue, (Element) lvaluePtr, (Element) rvalue); } else if (rvalue.getNodeType() == Node.ELEMENT_NODE && lvaluePtr.getNodeType() == Node.ELEMENT_NODE) { lvalue = replaceElement((Element) lvalue, (Element) lvaluePtr, (Element) rvalue, ocopy.keepSrcElementName); } else { lvalue = replaceContent(lvalue, lvaluePtr, rvalue.getTextContent()); } final VariableInstance lval = _scopeFrame.resolve(ocopy.to.getVariable()); if (__log.isDebugEnabled()) __log.debug("ASSIGN Writing variable '" + lval.declaration.name + "' value '" + DOMUtils.domToString(lvalue) + "'"); commitChanges(lval, lvalue); se = new VariableModificationEvent(lval.declaration.name); ((VariableModificationEvent) se).setNewValue(lvalue); } } if (ocopy.debugInfo != null) se.setLineNo(ocopy.debugInfo.startLine); sendEvent(se); }
From source file:org.apache.ode.utils.DOMUtils.java
/** * This method traverses the DOM and grabs namespace declarations * on parent elements with the intent of preserving them for children. <em>Note * that the DOM level 3 document method {@link Element#getAttribute(java.lang.String)} * is not desirable in this case, as it does not respect namespace prefix * bindings that may affect attribute values. (Namespaces in DOM are * uncategorically a mess, especially in the context of XML Schema.)</em> * @param el the starting element/* w ww .jav a2 s .c o m*/ * @return a {@link Map} containing prefix bindings. */ public static Map<String, String> getParentNamespaces(Element el) { HashMap<String, String> pref = new HashMap<String, String>(); Map<String, String> mine = getMyNamespaces(el); Node n = el.getParentNode(); while (n != null && n.getNodeType() != Node.DOCUMENT_NODE) { if (n instanceof Element) { Element l = (Element) n; NamedNodeMap nnm = l.getAttributes(); int len = nnm.getLength(); for (int i = 0; i < len; ++i) { Attr a = (Attr) nnm.item(i); if (isNSAttribute(a)) { String key = getNSPrefixFromNSAttr(a); String uri = a.getValue(); // prefer prefix bindings that are lower down in the tree. if (pref.containsKey(key) || mine.containsKey(key)) continue; pref.put(key, uri); } } } n = n.getParentNode(); } return pref; }
From source file:org.apache.ode.utils.DOMUtils.java
/** * Convert a DOM node to a stringified XML representation. *///from w ww .j ava 2s . c om static public String domToString(Node node) { if (node == null) { throw new IllegalArgumentException("Cannot stringify null Node!"); } String value = null; short nodeType = node.getNodeType(); if (nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE || nodeType == Node.DOCUMENT_FRAGMENT_NODE) { // serializer doesn't handle Node type well, only Element DOMSerializerImpl ser = new DOMSerializerImpl(); ser.setParameter(Constants.DOM_NAMESPACES, Boolean.TRUE); ser.setParameter(Constants.DOM_WELLFORMED, Boolean.FALSE); ser.setParameter(Constants.DOM_VALIDATE, Boolean.FALSE); // create a proper XML encoding header based on the input document; // default to UTF-8 if the parent document's encoding is not accessible String usedEncoding = "UTF-8"; Document parent = node.getOwnerDocument(); if (parent != null) { String parentEncoding = parent.getXmlEncoding(); if (parentEncoding != null) { usedEncoding = parentEncoding; } } // the receiver of the DOM DOMOutputImpl out = new DOMOutputImpl(); out.setEncoding(usedEncoding); // we write into a String StringWriter writer = new StringWriter(4096); out.setCharacterStream(writer); // out, ye characters! ser.write(node, out); writer.flush(); // finally get the String value = writer.toString(); } else { value = node.getNodeValue(); } return value; }