You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Malachi de AElfweald (JIRA)" <ji...@apache.org> on 2010/09/24 20:10:40 UTC

[jira] Created: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Default namespace not handled by .when(xpath(string))
-----------------------------------------------------

                 Key: CAMEL-3155
                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.4.0
         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
Java version: 1.6.0_17
Java home: C:\Program Files\Java\jdk1.6.0_17\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
            Reporter: Malachi de AElfweald
            Priority: Minor


If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)


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


[jira] Issue Comment Edited: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62109#action_62109 ] 

Claus Ibsen edited comment on CAMEL-3155 at 9/26/10 1:36 AM:
-------------------------------------------------------------

And no I could not find a solution with the XPath API to let it be aware of the default namesapce. There seems to be no good hooks for such kind.

Even if I added what may be a default namespace to the NamespaceContext the xpath would still fail. The only solution I could get working is to use namespace prefixes in the xpath expressions.

And the XPathExpression does not offer any callbacks or hooks to influence the compiling. And I bet doing a string based manipulation of the given String for the namespace is hard because people can use a lot of different combinations.

So if you have a simple expression like
{code}
/foo/bar
{code}

Then it may be possible to manipulate it beforehand and do
{code}
/c:foo/c:bar
{code}

And register c as a namespace with the uri from the XML message.

But when the xpath expression becomes more complex, its much harder.

So I wonder there must be better ways that this?

      was (Author: davsclaus):
    And no I could not find a solution with the XPath API to let it be aware of the default namesapce. There seems to be no good hooks for such kind.

Even if I added what may be a default namespace to the NamespaceContext the xpath would still fail. The only solution I could get working is to use namespace prefixes in the xpath expressions.

And the XPathExpression does not offer any callbacks or hooks to influence the compiling. And I bet doing a string based manipulation of the given String for the namespace is hard because people can use a lot of different combinations.

So if you have a simple expression like
{code}
/foo/bar
{code}

Then it may be possible to manipulate it beforehand and do
{code}
/c:foo/c:/bar
{code}

And register c as a namespace with the uri from the XML message.

But when the xpath expression becomes more complex, its much harder.

So I wonder there must be better ways that this?
  
> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Commented: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62108#action_62108 ] 

Claus Ibsen commented on CAMEL-3155:
------------------------------------

You need to use a namespace in your xpath expression. It can use any kind of prefix, but the uri must match the default namespace from your xml.

See for example
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java

> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Assigned: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-3155:
----------------------------------

    Assignee: Claus Ibsen

> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Resolved: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-3155.
--------------------------------

       Resolution: Working as Designed
    Fix Version/s: 2.6.0

Not possible with the JDK XPath

> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.6.0
>
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Commented: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62091#action_62091 ] 

Claus Ibsen commented on CAMEL-3155:
------------------------------------

See for example
http://www.edankert.com/defaultnamespaces.html

> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Commented: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Malachi de AElfweald (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62106#action_62106 ] 

Malachi de AElfweald commented on CAMEL-3155:
---------------------------------------------

I brought this issue up with the JDOM list back in 2003.

Currently, this is a real hassle because to use xpath and jaxb together in camel, you have to remove the namespace from the string before when(xpath()) then add it back in for each of them that want to process with jaxb.

Do you know of a better way around it?

> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Commented: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62092#action_62092 ] 

Claus Ibsen commented on CAMEL-3155:
------------------------------------

There is not mich you can do as how the XPath works in the JDK in terms of default namespaces and omitting prefixes in the xpath string
http://stackoverflow.com/questions/1730710/xpath-is-there-a-way-to-set-a-default-namespace-for-queries

Anybody aware of a solution to this?

> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Updated: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-3155:
-------------------------------

    Issue Type: Improvement  (was: Bug)

This is how the XPath works in the JDK.

But the other day I thought this was annoying as well, for example if there is only one default namespace in the message.
Then it would be great if the xpath could cater for this anyhow.


> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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


[jira] Commented: (CAMEL-3155) Default namespace not handled by .when(xpath(string))

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62109#action_62109 ] 

Claus Ibsen commented on CAMEL-3155:
------------------------------------

And no I could not find a solution with the XPath API to let it be aware of the default namesapce. There seems to be no good hooks for such kind.

Even if I added what may be a default namespace to the NamespaceContext the xpath would still fail. The only solution I could get working is to use namespace prefixes in the xpath expressions.

And the XPathExpression does not offer any callbacks or hooks to influence the compiling. And I bet doing a string based manipulation of the given String for the namespace is hard because people can use a lot of different combinations.

So if you have a simple expression like
{code}
/foo/bar
{code}

Then it may be possible to manipulate it beforehand and do
{code}
/c:foo/c:/bar
{code}

And register c as a namespace with the uri from the XML message.

But when the xpath expression becomes more complex, its much harder.

So I wonder there must be better ways that this?

> Default namespace not handled by .when(xpath(string))
> -----------------------------------------------------
>
>                 Key: CAMEL-3155
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3155
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.4.0
>         Environment: Apache Maven 3.0-alpha-5 (r883378; 2009-11-23 07:53:41-0800)
> Java version: 1.6.0_17
> Java home: C:\Program Files\Java\jdk1.6.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
>            Reporter: Malachi de AElfweald
>            Assignee: Claus Ibsen
>            Priority: Minor
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> If I do a .choice().when(xpath("//rootnode")) it fails to find any matches unless I preprocess and remove the xmlns="blah" (autogenerated by JAXB on the other end)

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