|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: java extension element and xsl variable problem
I asked the following question around this time last week and after
searching the net, dredging newsgroups and posting I finally got my
answer. There seemed like a few people who had the same question.
Wierdly the only place I found my answer was not even in the xalan
samples but by getting the actual xalan source and seeing how they do
it. They really should have an example showing the rest of the world. +
commenting all methods in their API doc with 'for advance use only' is
quite annoying. I want to use the bloody thing I don't want to be told
I'm too childish to be allowed near the API. If their is anyone out
there on the Xalan doc team. Shame on you. 'Not yet documented' would be
a more realistic and less intimidating solution.
Anyway my guess was right one must dynamically evaluate the XPath expression. This is how they do it for a filename... not tricky but without examples or sufficent API doc it shows how 10 lines of code can consume alomost 20 hours of work. private String getFilename(XSLProcessorContext context, ElemExtensionCall elem) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, javax.xml.transform.TransformerException { String fileName; String fileNameExpr = ((ElemExtensionCall)elem).getAttribute ("select", context.getContextNode(), context.getTransformer()); if(null != fileNameExpr) { org.apache.xpath.XPathContext xctxt = context.getTransformer().getXPathContext(); XPath myxpath = new XPath(fileNameExpr, elem, xctxt.getNamespaceContext(), XPath.SELECT); XObject xobj = myxpath.execute(xctxt, context.getContextNode(), elem); fileName = xobj.str(); if((null == fileName) || (fileName.length() == 0)) { fileName = elem.getAttribute ("file", context.getContextNode(), context.getTransformer()); } } else { fileName = elem.getAttribute ("file", context.getContextNode(), context.getTransformer()); } if(null == fileName) { context.getTransformer().getMsgMgr().error(elem, elem, context.getContextNode(), XSLTErrorResources.ER_REDIRECT_COULDNT_GET_FILENAME); //"Redirect extension: Could not get filename - file or select attribute must return vald string."); } return fileName; } Hi list -- ______________________________________________________________ / \ & Keith Lynch Mail $ klynch [BT] genigraph.fr & & & & GENIGRAPH URL $ http://www.genigraph.fr & & 104, rue Castagnary Tel $ +33 1 45 33 64 63 & & F-75015 PARIS - FRANCE Fax $ +33 1 45 33 89 63 & \ / //////////////////////////////////////////////////////////////
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








