Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with namespace:: axis with SAXON processor

 
RajeshOfs Chennai
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have problem with following XSL, while doing SAXON processing.

<xsl:variable name="uri" select="string(namespace::*[name() = $prefix])"/>

SAXON, not able to process the above line and giving exception:
net.sf.saxon.trans.XPathException: Axis step namespace::namespace() cannot be used here: the context item is undefined.

I found out, namespace:: axis has been deprecated.

Please help me in , how can we write the above line without using namespace:: axis.

Thanks in Advance!!
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quite independent of whether namespace axis be deprecated or not, the xpath itself is not clear and that's the problem. I guess you want to find what kind of uri associated with a certain prefix? The question itself is not very generic to xml recommendation as the prefix is something allowed at the caprice of those authoring the document.

But, if you really want to take a look of it, you can still do something like this.

I would not be too enthusiatic with that, but it serves the intention of knowing what can be done and what cannot.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's pretty clear to me that your XSLT processor does support the namespace axis, otherwise it would just say it doesn't support it. But it doesn't say that. It says this instead:
the context item is undefined

So if it were me, I would be putting in some code which defines the context item as my first step.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed if insist on using namespace axis, now that I see better what you mean, you can do this.

That would show the same results as the first post. It is important to note that the same prefix can well be associated with different uri.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic