BTW, what's the proper method for getting new code approved (by the
community?)?
ObjectOrange wrote:
>
> Actually, I added these two:
>
> public void setAttributeWithValue(String xpath, String value) throws
> DOMException {
> Element msgXML = getContent();
> if(msgXML!=null) {
> Attr attribute = msgXML.getAttributeNode(xpath);
> if(attribute==null)
> throw new DOMException(DOMException.NOT_FOUND_ERR,
> "Attribute not found in message with xpath: "+xpath);
> else
> attribute.setValue(value);
> }
> }
>
> public void setAttributeWithAttribute(String xpathToSet, String
> xpathValue) throws DOMException {
> Element msgXML = getContent();
> if(msgXML!=null) {
> Attr attributeToSet = msgXML.getAttributeNode(xpathToSet);
> Attr attributeValue = msgXML.getAttributeNode(xpathValue);
> String faultMsg = "";
> boolean fault = false;
> if(attributeToSet==null) {
> fault = true;
> faultMsg = "Attribute not found in message with xpath:
> "+xpathToSet+"/n";
> }
> if(attributeValue==null) {
> fault = true;
> faultMsg += "Attribute not found in message with xpath:
> "+xpathValue+"/n";
> }
> if(fault)
> throw new DOMException(DOMException.NOT_FOUND_ERR,
> faultMsg);
> else
> attributeToSet.setValue(attributeValue.getValue());
> }
> }
>
>
> ObjectOrange wrote:
>>
>> I added the following code to the Message class:
>>
>> public void setAttribute(String xpath, String value) throws DOMException
>> {
>> Element msgXML = getContent();
>> if(msgXML!=null) {
>> Attr attribute = msgXML.getAttributeNode(xpath);
>> if(attribute==null)
>> throw new DOMException(DOMException.NOT_FOUND_ERR,
>> "Attribute not found in message with xpath: "+xpath);
>> else
>> attribute.setValue(value);
>> }
>> }
>>
>> Does this work for everyone? If so, how do I (or can someone) add this to
>> our latest build?
>>
>>
>> lhe77 wrote:
>>>
>>> Brian,
>>>
>>> actually you can have to logic in your drl file.
>>> Just get the internal NormalizedMessage of the exchange and convert the
>>> content to DOM document using SourceTransformer. Then change the
>>> attribute in
>>> that document and put it back to the message content. That should do the
>>> trick.
>>>
>>> For details have a look at the drools engine source:
>>> http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-
>>> drools/trunk/src/main/java/org/apache/servicemix/drools/
>>>
>>> Regards
>>> Lars
>>>
>>>
>>> Am Donnerstag 23 Oktober 2008 14:11:25 schrieb ObjectOrange:
>>>> Thx Lars!
>>>>
>>>> So, code and load a new 'helper' class that provides a
>>>> setXMLAttribute()
>>>> method?
>>>>
>>>> Does using these 'helper' classes interfere with the BRMS web
>>>> application
>>>> in managing the DRL files?
>>>>
>>>> lhe77 wrote:
>>>> > Brian,
>>>> >
>>>> > of course you can change the content of the message. Just retrieve
>>>> the
>>>> > MessageExchange's InMsg (Normalized Message) and use getContent() to
>>>> get
>>>> > the
>>>> > content of the message.
>>>> > Useful class here to convert the content to DOM document or String is
>>>> the
>>>> > SourceTransformer class.
>>>> >
>>>> > Regards
>>>> > Lars
>>>> >
>>>> > Am Mittwoch 22 Oktober 2008 18:15:36 schrieb ObjectOrange:
>>>> >> Hello,
>>>> >>
>>>> >> I've noticed in the examples for this component the use of XPath for
>>>> >> condition evaluation. Is there a way to update the XML within a
>>>> >> Normalized
>>>> >> Message perhaps setting an XML attribute to a new value using the
>>>> >> current code or would this be a new feature?
>>>> >>
>>>> >> Thx!
>>>> >>
>>>> >> Brian
>>>
>>>
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/ServiceMix-Drools-SE%3A-XPath-XML-Attribute-Updates-Support-tp20114382p20192303.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.