You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by "Bill Harts (JIRA)" <ji...@apache.org> on 2009/06/10 14:22:07 UTC

[jira] Created: (SYNAPSE-557) XPath doesn't return attribute value

XPath doesn't return attribute value
------------------------------------

                 Key: SYNAPSE-557
                 URL: https://issues.apache.org/jira/browse/SYNAPSE-557
             Project: Synapse
          Issue Type: Bug
          Components: Core
            Reporter: Bill Harts


Problem:
An XPath expression in my synapse.xml configuration file is unable to retrieve an XML attribute from a message.  Example:

<log level="custom">
  <property name="sessID"  expression="//cfl:LoginResponse/cfl:LoginResponseData/@sessionID" xmlns:cfl="http:www.test.com/cfl" />
</log>

The message body is:
 <soapenv:Body>
  <cfl:LoginResponse xmlns:cfl="http://www.test.com/cfl">
   <cfl:LoginResponseData sessionID="250446AD43C0EEF3ED2F3172F8FA0A3D" statusCode="0"/>
  </cfl:LoginResponse>
 </soapenv:Body>

In this case the log mediator always returns null for the sessID variable.

Cause:
After poking around in a bunch of modules I believe that these XPath expressions are being handled in module synapseXPath.java.  Specifically there is a call in stringValueOf(MessageContext synCtx) to BaseXPath.evaluate() which returns a List of element pointers retrieved by the XPath expression.  The function then correctly checks each element to to determine if it is of type OMTextImpl, OMElementImpl or OMDocumentImpl but when an attribute has been found evaluate() returns an attribute of type DocumentNavigator$OMAttributeEx.  It appears that there is no code in stringValueOf() to handle this type of pointer.

Solution:
I added the following code to synapseXpath.java::stringValueOf at line 206:

                    ...
                    } else if (o instanceof OMAttributeEx) {
                        textValue.append( ((OMAttributeEx)o).getAttributeValue());
                   }
                   ...

Also, since the type OMAttributeEx is an inner class of type DocumentNavigator I needed to add an import statement in SynapseXPath.java:

import org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx;

Unfortunately, OMAtributeEx is defined as private to class DocumentNavigator so I had to declare class and constructor OMAttributeEx as public in the module DocumentNavigator.java in the Axiom project module axiom-api.jar.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Updated: (SYNAPSE-557) XPath doesn't return attribute value

Posted by "Bill Harts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SYNAPSE-557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bill Harts updated SYNAPSE-557:
-------------------------------

    Attachment: changes.patch

Changes to SynapseXPath.java to fix the XPath attribute problem.  Needs to be applied to the codebase.

Bill


> XPath doesn't return attribute value
> ------------------------------------
>
>                 Key: SYNAPSE-557
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-557
>             Project: Synapse
>          Issue Type: Bug
>          Components: Core
>            Reporter: Bill Harts
>         Attachments: changes.patch
>
>
> Problem:
> An XPath expression in my synapse.xml configuration file is unable to retrieve an XML attribute from a message.  Example:
> <log level="custom">
>   <property name="sessID"  expression="//ns:LoginResponse/ns:LoginResponseData/@sessionID" xmlns:ns="http://www.test.com/ns" />
> </log>
> The message body is:
>  <soapenv:Body>
>   <ns:LoginResponse xmlns:ns="http://www.test.com/ns">
>    <ns:LoginResponseData sessionID="250446AD43C0EEF3ED2F3172F8FA0A3D" statusCode="0"/>
>   </ns:LoginResponse>
>  </soapenv:Body>
> In this case the log mediator always returns null for the sessID variable.
> Cause:
> After poking around in a bunch of modules I believe that these XPath expressions are being handled in module synapseXPath.java.  Specifically there is a call in stringValueOf(MessageContext synCtx) to BaseXPath.evaluate() which returns a List of element pointers retrieved by the XPath expression.  The function then correctly checks each element to to determine if it is of type OMTextImpl, OMElementImpl or OMDocumentImpl but when an attribute has been found evaluate() returns an attribute of type DocumentNavigator$OMAttributeEx.  It appears that there is no code in stringValueOf() to handle this type of pointer.
> Solution:
> I added the following code to synapseXpath.java::stringValueOf at line 206:
>                     ...
>                     } else if (o instanceof OMAttributeEx) {
>                         textValue.append( ((OMAttributeEx)o).getAttributeValue());
>                    }
>                    ...
> Also, since the type OMAttributeEx is an inner class of type DocumentNavigator I needed to add an import statement in SynapseXPath.java:
> import org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx;
> Unfortunately, OMAtributeEx is defined as private to class DocumentNavigator so I had to declare class and constructor OMAttributeEx as public in the module DocumentNavigator.java in the Axiom project module axiom-api.jar.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Resolved: (SYNAPSE-557) XPath doesn't return attribute value

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SYNAPSE-557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Veithen resolved SYNAPSE-557.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.3

Committed the patch. Thanks for contributing!

> XPath doesn't return attribute value
> ------------------------------------
>
>                 Key: SYNAPSE-557
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-557
>             Project: Synapse
>          Issue Type: Bug
>          Components: Core
>            Reporter: Bill Harts
>            Assignee: Andreas Veithen
>             Fix For: 1.3
>
>         Attachments: changes.patch
>
>
> Problem:
> An XPath expression in my synapse.xml configuration file is unable to retrieve an XML attribute from a message.  Example:
> <log level="custom">
>   <property name="sessID"  expression="//ns:LoginResponse/ns:LoginResponseData/@sessionID" xmlns:ns="http://www.test.com/ns" />
> </log>
> The message body is:
>  <soapenv:Body>
>   <ns:LoginResponse xmlns:ns="http://www.test.com/ns">
>    <ns:LoginResponseData sessionID="250446AD43C0EEF3ED2F3172F8FA0A3D" statusCode="0"/>
>   </ns:LoginResponse>
>  </soapenv:Body>
> In this case the log mediator always returns null for the sessID variable.
> Cause:
> After poking around in a bunch of modules I believe that these XPath expressions are being handled in module synapseXPath.java.  Specifically there is a call in stringValueOf(MessageContext synCtx) to BaseXPath.evaluate() which returns a List of element pointers retrieved by the XPath expression.  The function then correctly checks each element to to determine if it is of type OMTextImpl, OMElementImpl or OMDocumentImpl but when an attribute has been found evaluate() returns an attribute of type DocumentNavigator$OMAttributeEx.  It appears that there is no code in stringValueOf() to handle this type of pointer.
> Solution:
> I added the following code to synapseXpath.java::stringValueOf at line 206:
>                     ...
>                     } else if (o instanceof OMAttributeEx) {
>                         textValue.append( ((OMAttributeEx)o).getAttributeValue());
>                    }
>                    ...
> Also, since the type OMAttributeEx is an inner class of type DocumentNavigator I needed to add an import statement in SynapseXPath.java:
> import org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx;
> Unfortunately, OMAtributeEx is defined as private to class DocumentNavigator so I had to declare class and constructor OMAttributeEx as public in the module DocumentNavigator.java in the Axiom project module axiom-api.jar.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Updated: (SYNAPSE-557) XPath doesn't return attribute value

Posted by "Bill Harts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SYNAPSE-557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bill Harts updated SYNAPSE-557:
-------------------------------

    Description: 
Problem:
An XPath expression in my synapse.xml configuration file is unable to retrieve an XML attribute from a message.  Example:

<log level="custom">
  <property name="sessID"  expression="//ns:LoginResponse/ns:LoginResponseData/@sessionID" xmlns:ns="http://www.test.com/ns" />
</log>

The message body is:
 <soapenv:Body>
  <ns:LoginResponse xmlns:ns="http://www.test.com/ns">
   <ns:LoginResponseData sessionID="250446AD43C0EEF3ED2F3172F8FA0A3D" statusCode="0"/>
  </ns:LoginResponse>
 </soapenv:Body>

In this case the log mediator always returns null for the sessID variable.

Cause:
After poking around in a bunch of modules I believe that these XPath expressions are being handled in module synapseXPath.java.  Specifically there is a call in stringValueOf(MessageContext synCtx) to BaseXPath.evaluate() which returns a List of element pointers retrieved by the XPath expression.  The function then correctly checks each element to to determine if it is of type OMTextImpl, OMElementImpl or OMDocumentImpl but when an attribute has been found evaluate() returns an attribute of type DocumentNavigator$OMAttributeEx.  It appears that there is no code in stringValueOf() to handle this type of pointer.

Solution:
I added the following code to synapseXpath.java::stringValueOf at line 206:

                    ...
                    } else if (o instanceof OMAttributeEx) {
                        textValue.append( ((OMAttributeEx)o).getAttributeValue());
                   }
                   ...

Also, since the type OMAttributeEx is an inner class of type DocumentNavigator I needed to add an import statement in SynapseXPath.java:

import org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx;

Unfortunately, OMAtributeEx is defined as private to class DocumentNavigator so I had to declare class and constructor OMAttributeEx as public in the module DocumentNavigator.java in the Axiom project module axiom-api.jar.  

  was:
Problem:
An XPath expression in my synapse.xml configuration file is unable to retrieve an XML attribute from a message.  Example:

<log level="custom">
  <property name="sessID"  expression="//cfl:LoginResponse/cfl:LoginResponseData/@sessionID" xmlns:cfl="http:www.test.com/cfl" />
</log>

The message body is:
 <soapenv:Body>
  <cfl:LoginResponse xmlns:cfl="http://www.test.com/cfl">
   <cfl:LoginResponseData sessionID="250446AD43C0EEF3ED2F3172F8FA0A3D" statusCode="0"/>
  </cfl:LoginResponse>
 </soapenv:Body>

In this case the log mediator always returns null for the sessID variable.

Cause:
After poking around in a bunch of modules I believe that these XPath expressions are being handled in module synapseXPath.java.  Specifically there is a call in stringValueOf(MessageContext synCtx) to BaseXPath.evaluate() which returns a List of element pointers retrieved by the XPath expression.  The function then correctly checks each element to to determine if it is of type OMTextImpl, OMElementImpl or OMDocumentImpl but when an attribute has been found evaluate() returns an attribute of type DocumentNavigator$OMAttributeEx.  It appears that there is no code in stringValueOf() to handle this type of pointer.

Solution:
I added the following code to synapseXpath.java::stringValueOf at line 206:

                    ...
                    } else if (o instanceof OMAttributeEx) {
                        textValue.append( ((OMAttributeEx)o).getAttributeValue());
                   }
                   ...

Also, since the type OMAttributeEx is an inner class of type DocumentNavigator I needed to add an import statement in SynapseXPath.java:

import org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx;

Unfortunately, OMAtributeEx is defined as private to class DocumentNavigator so I had to declare class and constructor OMAttributeEx as public in the module DocumentNavigator.java in the Axiom project module axiom-api.jar.  


Saliya Ekanayake has pointed out that OMAttributeEx implements the OMAttribute interface so we can actually check for instanceof OMAttribute.  This way we don't have to change the access modifiers in Axis2 and don't need an additional import.  Changed code:

                    ...
                    } else if (o instanceof OMAttribute) {
                        textValue.append( ((OMAttribute)o).getAttributeValue());
                   }
                   ...

I will submit a patch file.

Bill

> XPath doesn't return attribute value
> ------------------------------------
>
>                 Key: SYNAPSE-557
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-557
>             Project: Synapse
>          Issue Type: Bug
>          Components: Core
>            Reporter: Bill Harts
>
> Problem:
> An XPath expression in my synapse.xml configuration file is unable to retrieve an XML attribute from a message.  Example:
> <log level="custom">
>   <property name="sessID"  expression="//ns:LoginResponse/ns:LoginResponseData/@sessionID" xmlns:ns="http://www.test.com/ns" />
> </log>
> The message body is:
>  <soapenv:Body>
>   <ns:LoginResponse xmlns:ns="http://www.test.com/ns">
>    <ns:LoginResponseData sessionID="250446AD43C0EEF3ED2F3172F8FA0A3D" statusCode="0"/>
>   </ns:LoginResponse>
>  </soapenv:Body>
> In this case the log mediator always returns null for the sessID variable.
> Cause:
> After poking around in a bunch of modules I believe that these XPath expressions are being handled in module synapseXPath.java.  Specifically there is a call in stringValueOf(MessageContext synCtx) to BaseXPath.evaluate() which returns a List of element pointers retrieved by the XPath expression.  The function then correctly checks each element to to determine if it is of type OMTextImpl, OMElementImpl or OMDocumentImpl but when an attribute has been found evaluate() returns an attribute of type DocumentNavigator$OMAttributeEx.  It appears that there is no code in stringValueOf() to handle this type of pointer.
> Solution:
> I added the following code to synapseXpath.java::stringValueOf at line 206:
>                     ...
>                     } else if (o instanceof OMAttributeEx) {
>                         textValue.append( ((OMAttributeEx)o).getAttributeValue());
>                    }
>                    ...
> Also, since the type OMAttributeEx is an inner class of type DocumentNavigator I needed to add an import statement in SynapseXPath.java:
> import org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx;
> Unfortunately, OMAtributeEx is defined as private to class DocumentNavigator so I had to declare class and constructor OMAttributeEx as public in the module DocumentNavigator.java in the Axiom project module axiom-api.jar.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Assigned: (SYNAPSE-557) XPath doesn't return attribute value

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SYNAPSE-557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Veithen reassigned SYNAPSE-557:
---------------------------------------

    Assignee: Andreas Veithen

> XPath doesn't return attribute value
> ------------------------------------
>
>                 Key: SYNAPSE-557
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-557
>             Project: Synapse
>          Issue Type: Bug
>          Components: Core
>            Reporter: Bill Harts
>            Assignee: Andreas Veithen
>         Attachments: changes.patch
>
>
> Problem:
> An XPath expression in my synapse.xml configuration file is unable to retrieve an XML attribute from a message.  Example:
> <log level="custom">
>   <property name="sessID"  expression="//ns:LoginResponse/ns:LoginResponseData/@sessionID" xmlns:ns="http://www.test.com/ns" />
> </log>
> The message body is:
>  <soapenv:Body>
>   <ns:LoginResponse xmlns:ns="http://www.test.com/ns">
>    <ns:LoginResponseData sessionID="250446AD43C0EEF3ED2F3172F8FA0A3D" statusCode="0"/>
>   </ns:LoginResponse>
>  </soapenv:Body>
> In this case the log mediator always returns null for the sessID variable.
> Cause:
> After poking around in a bunch of modules I believe that these XPath expressions are being handled in module synapseXPath.java.  Specifically there is a call in stringValueOf(MessageContext synCtx) to BaseXPath.evaluate() which returns a List of element pointers retrieved by the XPath expression.  The function then correctly checks each element to to determine if it is of type OMTextImpl, OMElementImpl or OMDocumentImpl but when an attribute has been found evaluate() returns an attribute of type DocumentNavigator$OMAttributeEx.  It appears that there is no code in stringValueOf() to handle this type of pointer.
> Solution:
> I added the following code to synapseXpath.java::stringValueOf at line 206:
>                     ...
>                     } else if (o instanceof OMAttributeEx) {
>                         textValue.append( ((OMAttributeEx)o).getAttributeValue());
>                    }
>                    ...
> Also, since the type OMAttributeEx is an inner class of type DocumentNavigator I needed to add an import statement in SynapseXPath.java:
> import org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx;
> Unfortunately, OMAtributeEx is defined as private to class DocumentNavigator so I had to declare class and constructor OMAttributeEx as public in the module DocumentNavigator.java in the Axiom project module axiom-api.jar.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org