• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Invalid xpath expression

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Xalan extension function to call a java function like this:




But i keep getting this error, regardless of what xpath expression i use.




Any clues?




 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Weird. That is valid XPath syntax. What happens if you try a differernt selector, //* for example?
 
Dennis Zandvliet
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry the errormessage is a bit misleading, it was thrown by wrapper method of



This is the original error:



This selector //* also give the same error.


formnode.getNodeType() gives type ELEMENT;


I've also tried this:





Also give the same error:

 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we clarify your throwaway remark about "Xalan extension function"?

If I understand this right, you have an XSL transformation. And from that you're calling Java methods. And from those Java methods you're calling this code that you have shown us. And the intent of the XPath is that it should be operating on the nodes of the XML document that is being transformed? Is that correct?

I can certainly see how that would be a stretch to make that scheme work, if that's actually what you are trying to do, but I don't have anything helpful to say about it at the moment. Except that you might have a look at just what it is you're trying to apply the XPath expression to. A little debugging, that is. Do you actually have a Node object? Things like that.
 
Dennis Zandvliet
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Can we clarify your throwaway remark about "Xalan extension function"?

If I understand this right, you have an XSL transformation. And from that you're calling Java methods. And from those Java methods you're calling this code that you have shown us. And the intent of the XPath is that it should be operating on the nodes of the XML document that is being transformed? Is that correct?



Yes, almost correct, the nodes are not from XML document itself but generated in the xslt and bind to a variable which is than passed to the java method.

Something like this:
When, in the Java method, I convert the node-tree to a string I get a xml document, with all the expected elements. So I'm sure the node is not empty.



Paul Clapham wrote:Can we clarify your throwaway remark about "Xalan extension function"?
Do you actually have a Node object? Things like that.



Yes, because when i do formnode.getNodeType() it gives type ELEMENT;
Also all the other methods work, like getChildNodes() etc.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah... you're generating the nodes in the XSLT. So perhaps they don't belong to any document, and calling getOwnerDocument returns something peculiar?
 
Dennis Zandvliet
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Ah... you're generating the nodes in the XSLT. So perhaps they don't belong to any document, and calling getOwnerDocument returns something peculiar?



Yes i was also thinking in this direction. But it this the case
1) How can i make them part of a proper created en initialised DOM document?
2) How is it possible that the nodes are not part of a document, because according to Sun's documentation nodes are always part of an document?
3) How come that after this call

Document doc = formnode.getOwnerDocument();

I can call al the other regular methods like getElementsByTagName() on this class?

I'ts very late here, i'm gonna try it tomorrow

Thanks
 
My, my, aren't you a big fella. Here, have a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic