[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Using Java in XSLT to determine font metrics
> I think I found the method getFontMetrics(font) in Java class > java.awt.Graphics > http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html You would be less likely to confuse your readers if you changed the namespace prefix from FontMetrics to Graphics. > > I added -TJ as a parameter but I'm not convinced <oXygen/> is > paying attention to it. > > My error message now seems to be the result of my incorrect > use of the method: > > Error in call to extension function {public > java.awt.FontMetrics java.awt.Graphics.getFontMetrics()}: > Cannot convert supplied XPath value to the required type for > the extension function. > > I have tried several values for $font as well as placing the > font name directly in the parameter list with the same result. The method is not static, so you will need to create an instance of java.awt.Graphics and supply it as your first argument. Since it is an abstract class, you can't do this directly: presumably there is a static factory method somewhere. The second argument needs to be an instance of java.awt.Font, whereas you are supplying a string. Note that when the Java logic starts to become complex and to involve several intermediate steps, it's often best to write the method you actually want in user-written Java code to hide the complexity, so that it becomes a single function call from the stylesheet. Michael Kay http://www.saxonica.com/
|
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
|