Project

Profile

Help

How to get NamespaceResolver in JavaExtFunc

Added by Anonymous about 18 years ago

Legacy ID: #3917718 Legacy Poster: Torsten Knodt (torsknod)

Hello, I'm really new to saxon so perhaps this is a silly question. I'm currently trying to write a java class with static methods to be used as java extension functions in a stylesheet. In those functions I need the current namespace declarations. I tried to get them using XPathContext.getOrigin().getInstructionInfo().getNamespaceResolver() but always get a null NamespaceResolver. The XPathContext comes from the first argument of my methods. Can anyone give me a suggestion? Thanks in advance Torsten


Replies (1)

RE: How to get NamespaceResolver in JavaExtFu - Added by Anonymous about 18 years ago

Legacy ID: #3917822 Legacy Poster: Michael Kay (mhkay)

Sorry, this information isn't available to "ordinary" extension functions. Those Saxon functions that need information from the static context (such as Base URI or the namespace context) use a lower-level interface that allows them to pick up this information at compile time and save it for use later. If you want to make this work, you could (a) create a subclass of ExtensionFunctionClass, (b) call configuration.getExtensionFunctionFactory().setExtensionFunctionClass([your subclass]), (c) in your subclass, implement the method checkArguments(StaticContext env), which is called at compile time: your implementation can access the namespace context from env and save it somewhere for use at run-time. Michael Kay

    (1-1/1)

    Please register to reply