This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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
Author

Problem with namespace:: axis with SAXON processor

RajeshOfs Chennai
Greenhorn

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: 499
    
    3
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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: 499
    
    3
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with namespace:: axis with SAXON processor
 
Similar Threads
Instant Saxon (IE and text file)
Cewolf: How to handle the values on y axis
java code to connect Siebel webservice
How can I declare a namespace using Java 1.5
Apache Axis 2 with multiple namespaces