debugging a java extension?

Hi! I try to debug a stylesheed transformation using Saxon 6.5.5. I wrote a small java extension class as transformation helper. I now receive a Nullpointer from within (it's still in development). Is there a possibility to debug the java class while stepping through the XSLT Debugger? Kind regards, Kai

Hello, The XSLT Debugger does not step into the Java extensions of the XSLT processor. We have this feature logged as an enhancement request but it was not implemented yet. I recommend generating debug output to a text file from the Java class. Regards, Sorin Kai Hackemesser wrote:
Hi!
I try to debug a stylesheed transformation using Saxon 6.5.5. I wrote a small java extension class as transformation helper. I now receive a Nullpointer from within (it's still in development). Is there a possibility to debug the java class while stepping through the XSLT Debugger?
Kind regards, Kai

Hi, Sorin, I tried so - created a Logger: private static Logger log = Logger.getLogger(FlightPlanHelper.class .getName()); static { try { log.addHandler(new FileHandler()); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static String getAddressContent(NodeList addressNodes) { log.info("called getAddressContent"); ..... But the logger never writes a file - I don't get any error message, either. any Idea? Currently using the xalan transformer and the method is called in the xsl. Kai Sorin Ristache schrieb:
Hello,
The XSLT Debugger does not step into the Java extensions of the XSLT processor. We have this feature logged as an enhancement request but it was not implemented yet. I recommend generating debug output to a text file from the Java class.
Regards, Sorin
Kai Hackemesser wrote:
Hi!
I try to debug a stylesheed transformation using Saxon 6.5.5. I wrote a small java extension class as transformation helper. I now receive a Nullpointer from within (it's still in development). Is there a possibility to debug the java class while stepping through the XSLT Debugger?
Kind regards, Kai
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

Is that the org.apache.log4j.Logger class? Do you set a Log4J file appender for FlightPlanHelper and a logging level which includes the INFO level? The file path specified in the file appender is relative to the oXygen start folder. Do you use a Java properties file for setting them? Where is the file located? It should be located in the oXygen install folder or in the lib subfolder of that folder. Regards, Sorin Kai Hackemesser wrote:
Hi, Sorin,
I tried so - created a Logger:
private static Logger log = Logger.getLogger(FlightPlanHelper.class .getName()); static { try { log.addHandler(new FileHandler()); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public static String getAddressContent(NodeList addressNodes) { log.info("called getAddressContent"); .....
But the logger never writes a file - I don't get any error message, either. any Idea? Currently using the xalan transformer and the method is called in the xsl.
Kai
Sorin Ristache schrieb:
Hello,
The XSLT Debugger does not step into the Java extensions of the XSLT processor. We have this feature logged as an enhancement request but it was not implemented yet. I recommend generating debug output to a text file from the Java class.
Regards, Sorin
Kai Hackemesser wrote:
Hi!
I try to debug a stylesheed transformation using Saxon 6.5.5. I wrote a small java extension class as transformation helper. I now receive a Nullpointer from within (it's still in development). Is there a possibility to debug the java class while stepping through the XSLT Debugger?
Kind regards, Kai
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

Sorin Ristache schrieb:
Is that the org.apache.log4j.Logger class? Do you set a Log4J file appender for FlightPlanHelper and a logging level which includes the INFO level? The file path specified in the file appender is relative to the oXygen start folder. Do you use a Java properties file for setting them? Where is the file located? It should be located in the oXygen install folder or in the lib subfolder of that folder.
No, I used the default JDK Logger. This should normally put the file into my home directory, but nothing. Ciao! Kai

Try to specify the full path for the log file name in the logger configuration. Also you can send the logging output to the standard output but you have to start oXygen with the startup script (oxygen.bat on Windows, oxygen.sh on Linux, oxygenMac.sh on Mac OS X) instead of the desktop/menu shortcut in order to see this output. Regards, Sorin Kai Hackemesser wrote:
Sorin Ristache schrieb:
Is that the org.apache.log4j.Logger class? Do you set a Log4J file appender for FlightPlanHelper and a logging level which includes the INFO level? The file path specified in the file appender is relative to the oXygen start folder. Do you use a Java properties file for setting them? Where is the file located? It should be located in the oXygen install folder or in the lib subfolder of that folder.
No, I used the default JDK Logger. This should normally put the file into my home directory, but nothing.
Ciao! Kai

I tried that before I switched to the default logger constructor. But I want to add that I'm using the eclipse plugin, not the standalone oxygen editor. Regards, Kai Sorin Ristache schrieb:
Try to specify the full path for the log file name in the logger configuration. Also you can send the logging output to the standard output but you have to start oXygen with the startup script (oxygen.bat on Windows, oxygen.sh on Linux, oxygenMac.sh on Mac OS X) instead of the desktop/menu shortcut in order to see this output.
Regards, Sorin
Kai Hackemesser wrote:
Sorin Ristache schrieb:
Is that the org.apache.log4j.Logger class? Do you set a Log4J file appender for FlightPlanHelper and a logging level which includes the INFO level? The file path specified in the file appender is relative to the oXygen start folder. Do you use a Java properties file for setting them? Where is the file located? It should be located in the oXygen install folder or in the lib subfolder of that folder.
No, I used the default JDK Logger. This should normally put the file into my home directory, but nothing.
Ciao! Kai
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

Hi, In meantime I found another problem while debugging: It looks like the extension class(es) is hold in cache and doesn't get updated when I change it's source. That makes it complicated to debug. Ciao! Kai Kai Hackemesser schrieb:
I tried that before I switched to the default logger constructor. But I want to add that I'm using the eclipse plugin, not the standalone oxygen editor.
Regards, Kai
Sorin Ristache schrieb:
Try to specify the full path for the log file name in the logger configuration. Also you can send the logging output to the standard output but you have to start oXygen with the startup script (oxygen.bat on Windows, oxygen.sh on Linux, oxygenMac.sh on Mac OS X) instead of the desktop/menu shortcut in order to see this output.
Regards, Sorin

Hello Kai, The cache is refreshed automatically when the timestamp of the jar file/class files used as extension is changed on disk. If you change the source and then compile the new source oXygen uses the new version of the extension by detecting that the timestamp of the cached version is older than the timestamp of the disk version. Regards, Sorin Kai Hackemesser wrote:
Hi,
In meantime I found another problem while debugging: It looks like the extension class(es) is hold in cache and doesn't get updated when I change it's source. That makes it complicated to debug.
Ciao! Kai
Kai Hackemesser schrieb:
I tried that before I switched to the default logger constructor. But I want to add that I'm using the eclipse plugin, not the standalone oxygen editor.
Regards, Kai
Sorin Ristache schrieb:
Try to specify the full path for the log file name in the logger configuration. Also you can send the logging output to the standard output but you have to start oXygen with the startup script (oxygen.bat on Windows, oxygen.sh on Linux, oxygenMac.sh on Mac OS X) instead of the desktop/menu shortcut in order to see this output.
Regards, Sorin
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

That would be the behavior I would expect, but I tried several times and controlled the log output. Even when I commented out my log statements the log showed them again and again. I had to restart Eclipse to get the extension class correctly reloaded. BTW, it is annoying that the configuration of extensions get lost between Eclipse sessions, because I always have to set them up again. Ciao! Kai Sorin Ristache schrieb:
Hello Kai,
The cache is refreshed automatically when the timestamp of the jar file/class files used as extension is changed on disk. If you change the source and then compile the new source oXygen uses the new version of the extension by detecting that the timestamp of the cached version is older than the timestamp of the disk version.
Regards, Sorin
Kai Hackemesser wrote:
Hi,
In meantime I found another problem while debugging: It looks like the extension class(es) is hold in cache and doesn't get updated when I change it's source. That makes it complicated to debug.
Ciao! Kai
Kai Hackemesser schrieb:
I tried that before I switched to the default logger constructor. But I want to add that I'm using the eclipse plugin, not the standalone oxygen editor.
Regards, Kai
Sorin Ristache schrieb:
Try to specify the full path for the log file name in the logger configuration. Also you can send the logging output to the standard output but you have to start oXygen with the startup script (oxygen.bat on Windows, oxygen.sh on Linux, oxygenMac.sh on Mac OS X) instead of the desktop/menu shortcut in order to see this output.
Regards, Sorin
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

Hello, You should set the extensions in a transformation scenario in the Editor perspective and start the debugger with the Debug Scenario action. If you add the extensions in the Debugger perspective using the Edit extensions button then they are not saved. I cannot reproduce the problem of refreshing the extension. Can you send us sample files for reproducing? Regards, Sorin Kai Hackemesser wrote:
That would be the behavior I would expect, but I tried several times and controlled the log output. Even when I commented out my log statements the log showed them again and again. I had to restart Eclipse to get the extension class correctly reloaded. BTW, it is annoying that the configuration of extensions get lost between Eclipse sessions, because I always have to set them up again.
Ciao! Kai

Hello, I attached the extension source. (It's not finished yet ;-) ) A part of the xsl file follows: <xsl:template name="addressesToString"> <xsl:param name="nodes"/> <xsl:value-of select="helper:getAddressContent($nodes)" xmlns:helper="xalan://com.avitech.xslextension.FlightPlanHelper"/> </xsl:template> ... <xsl:variable name="content"> <xsl:call-template name="addressesToString"> <xsl:with-param name="nodes"> <xsl:for-each select="Addresses"> <xsl:copy-of select="."/> </xsl:for-each> <xsl:for-each select="FlightPlanInfo/ExtraAddresses"> <xsl:copy-of select="."/> </xsl:for-each> </xsl:with-param> </xsl:call-template> </xsl:variable> ... Sorin Ristache schrieb:
Hello,
You should set the extensions in a transformation scenario in the Editor perspective and start the debugger with the Debug Scenario action. If you add the extensions in the Debugger perspective using the Edit extensions button then they are not saved.
I cannot reproduce the problem of refreshing the extension. Can you send us sample files for reproducing?
Regards, Sorin
Kai Hackemesser wrote:
That would be the behavior I would expect, but I tried several times and controlled the log output. Even when I commented out my log statements the log showed them again and again. I had to restart Eclipse to get the extension class correctly reloaded. BTW, it is annoying that the configuration of extensions get lost between Eclipse sessions, because I always have to set them up again.
Ciao! Kai
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
package com.avitech.xslextension; import java.io.IOException; import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.crimson.tree.XmlDocument; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class FlightPlanHelper { private static final Logger log = Logger.getLogger(FlightPlanHelper.class .getName()); static { try { log.addHandler(new FileHandler()); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static String getAddressContent(NodeList addressNodes) { log.info("called getAddressContent"); String result; try { // logNodes(addressNodes); StringBuffer addresses = new StringBuffer(); StringBuffer extraAddresses = new StringBuffer(); Node doc = addressNodes.item(0); NodeList list = doc.getChildNodes(); log.info("Elemente:" + String.valueOf(list)); for (int i = 0; i < list.getLength(); i++) { final Node node = list.item(i); if ("Addresses".equals(node.getNodeName())) { if (addresses.length() > 0) { addresses.append(' '); } log.info( "Node type of child: " + node.getFirstChild().getNodeType()); addresses.append(node.getFirstChild().getNodeValue()); } else if ("ExtraAddresses".equals(node.getNodeName())) { if (addresses.length() > 0) { addresses.append(' '); } extraAddresses.append("AD "); log.info( "Node type of child: " + node.getFirstChild().getNodeType()); extraAddresses.append(node.getFirstChild().getNodeValue()); } else { addresses.append("Unkown Node: '" + node.getNodeName() + "' "); } } result = addresses.append((addresses.length() > 0) ? " " : "") .append(extraAddresses.toString()).toString(); } catch (NullPointerException e) { log.log(Level.SEVERE, e.getLocalizedMessage(), e); result = ""; } log.info("Result = '" + result + "'"); return result; } private static void logNodes(NodeList nodes) { for (int i = 0; i < nodes.getLength(); i++) { log.info("Child: " + i); Node node = nodes.item(i); log.info( "Opening type '" + node.getNodeType() + "' node " + String.valueOf(node.getNodeName())); final NamedNodeMap attributes = node.getAttributes(); if (node.getNodeType() == Node.ELEMENT_NODE && attributes != null) { log.info("Attributes: "); for (int a = 0; a < attributes.getLength(); a++) { Node attribute = attributes.item(a); log.info( " " + attribute.getNodeName() + ":" + attribute.getNodeValue()); } } if (node.getChildNodes().getLength() > 0) { log.info("Children: "); logNodes(node.getChildNodes()); } log.info("Closing node " + String.valueOf(node.getNodeName())); } } public static Document splitIntoLines(final String content, final NodeList lineElements) { Document result = new XmlDocument(); Element docRoot = result.createElement("result"); log.info("called splitIntoLines"); int lineIndex = 0; int pointer = 0; try { Document doc = (Document) lineElements.item(0); NodeList lines = doc.getChildNodes(); while (pointer < content.length() && lineIndex < lines.getLength()) { Node line = lines.item(lineIndex); int lineLength = Integer.parseInt(line.getAttributes() .getNamedItem("length").getNodeValue()); log.info( "Line " + lineIndex + " has max length of " + lineLength); // Wir entnehmen dem content einen Substring von maximal // lineLength // Zeichen String subString = content.substring(pointer, Math.min(content .length(), pointer + lineLength)); String lineContent; // Falls der Ausschnitt mitten in einem Wort endet... if (subString.length() == lineLength && !content.endsWith(subString)) { int lastSpacePointer = subString.lastIndexOf(' '); // falls kein Space in der Zeichenkette ist, wird nicht // umgebrochen, sonst wird an der Position des letzten Space // umgebrochen. if (lastSpacePointer == -1) { lastSpacePointer = lineLength; } lineContent = subString.substring(0, lastSpacePointer); } else { lineContent = subString; } log.info( "Line " + lineIndex + " will be filled with '" + lineContent + "'"); line = result.createElement("line"); line.appendChild(result.createTextNode(lineContent)); docRoot.appendChild(line); pointer += lineContent.length(); lineIndex++; } if (pointer >= content.length()) { docRoot.appendChild(result.createElement("overflow")); } } catch (NumberFormatException e) { log.log(Level.SEVERE, e.getLocalizedMessage(), e); } catch (DOMException e) { log.log(Level.SEVERE, e.getLocalizedMessage(), e); } return result; } }

I found that the extension class is reloaded when I use the way you described below. But it doesn't work when I'm working in the Debugger continuously (what I usually do). Sorin Ristache schrieb:
Hello,
You should set the extensions in a transformation scenario in the Editor perspective and start the debugger with the Debug Scenario action. If you add the extensions in the Debugger perspective using the Edit extensions button then they are not saved.
I cannot reproduce the problem of refreshing the extension. Can you send us sample files for reproducing?
Regards, Sorin
Kai Hackemesser wrote:
That would be the behavior I would expect, but I tried several times and controlled the log output. Even when I commented out my log statements the log showed them again and again. I had to restart Eclipse to get the extension class correctly reloaded. BTW, it is annoying that the configuration of extensions get lost between Eclipse sessions, because I always have to set them up again.
Ciao! Kai
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

Hello, What do you mean by working continuously in the Debugger? Do you mean that you update the extension class/jar and you expect that the new version is used in the same debugging session? That does not work, the extension is loaded when the transformation is started. The extension will be refreshed at the next transformation. This is also true for the Editor perspective. Regards, Sorin Kai Hackemesser wrote:
I found that the extension class is reloaded when I use the way you described below. But it doesn't work when I'm working in the Debugger continuously (what I usually do).
Sorin Ristache schrieb:
Hello,
You should set the extensions in a transformation scenario in the Editor perspective and start the debugger with the Debug Scenario action. If you add the extensions in the Debugger perspective using the Edit extensions button then they are not saved.
I cannot reproduce the problem of refreshing the extension. Can you send us sample files for reproducing?
Regards, Sorin
Kai Hackemesser wrote:
That would be the behavior I would expect, but I tried several times and controlled the log output. Even when I commented out my log statements the log showed them again and again. I had to restart Eclipse to get the extension class correctly reloaded. BTW, it is annoying that the configuration of extensions get lost between Eclipse sessions, because I always have to set them up again.
Ciao! Kai

Hello, I mean I'm editing xsl files, xml files (and currently a java class) in the oXygen XSLT Debugger perspective. I have set up the scenario in the XSLT Debugger view and start it from there as needed. I do kind of trial-and-error development in my xsl, so this is the fastest way to produce the results I need. But when I start a new translation the java class which may have changed in the meantime isn't refreshed, but the old one keeps getting used. For each transaction. Until I restart Eclipse. But I'm currently not sure about what I wrote in my last mail, because it still needs a eclipse restart sometimes. Kind regards, Kai Sorin Ristache schrieb:
Hello,
What do you mean by working continuously in the Debugger? Do you mean that you update the extension class/jar and you expect that the new version is used in the same debugging session? That does not work, the extension is loaded when the transformation is started. The extension will be refreshed at the next transformation. This is also true for the Editor perspective.
Regards, Sorin
Kai Hackemesser wrote:
I found that the extension class is reloaded when I use the way you described below. But it doesn't work when I'm working in the Debugger continuously (what I usually do).
Sorin Ristache schrieb:
Hello,
You should set the extensions in a transformation scenario in the Editor perspective and start the debugger with the Debug Scenario action. If you add the extensions in the Debugger perspective using the Edit extensions button then they are not saved.
I cannot reproduce the problem of refreshing the extension. Can you send us sample files for reproducing?
Regards, Sorin
Kai Hackemesser wrote:
That would be the behavior I would expect, but I tried several times and controlled the log output. Even when I commented out my log statements the log showed them again and again. I had to restart Eclipse to get the extension class correctly reloaded. BTW, it is annoying that the configuration of extensions get lost between Eclipse sessions, because I always have to set them up again.
Ciao! Kai
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
participants (2)
-
Kai Hackemesser
-
Sorin Ristache