This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Problem with namespace:: axis with SAXON processor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem with namespace:: axis with SAXON processor" Watch "Problem with namespace:: axis with SAXON processor" New topic

Problem with namespace:: axis with SAXON processor

RajeshOfs Chennai

Joined: Jun 21, 2011
Posts: 1

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

Joined: Jan 18, 2011
Posts: 554
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

Joined: Oct 14, 2005
Posts: 19351

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

Joined: Jan 18, 2011
Posts: 554
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.
rocket mass heater kickstarter
subject: Problem with namespace:: axis with SAXON processor