Need
– Notepad++: http://notepad-plus-plus.org/
– XML Tool Plug-in: http://sourceforge.net/projects/npp-plugins/files/XML%20Tools/
– XSL, XPATH knowledge
Steps
– Open ejb-jar.xml using Notepad++
– (Limitation of XML plugin?) Trim all attributes from ejb-jar. Example:
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
to
<ejb-jar>
– Open Plugins > XML Tools > XSL Transformation
– In the dialog box, browse and select the XLS file. In below sections, I provided 2 sample XLS file to extract out Name and Class of Entity Bean, Session Bean and Message-driven Bean and format to a CSV or HTML file.
– Click Transform
– A new document will be opened and filled with the transformed content
Sample XSL to extract to CSV file
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:for-each select="/ejb-jar/enterprise-beans/entity"> <xsl:value-of select="ejb-name"/> <xsl:text>,</xsl:text> <xsl:value-of select="ejb-class"/> <xsl:text>,</xsl:text> <xsl:text>Entity Bean</xsl:text> <xsl:text> </xsl:text> </xsl:for-each> <xsl:for-each select="/ejb-jar/enterprise-beans/session"> <xsl:value-of select="ejb-name"/> <xsl:text>,</xsl:text> <xsl:value-of select="ejb-class"/> <xsl:text>,</xsl:text> <xsl:text>Session Bean</xsl:text> <xsl:text> </xsl:text> </xsl:for-each> <xsl:for-each select="/ejb-jar/enterprise-beans/message-driven"> <xsl:value-of select="ejb-name"/> <xsl:text>,</xsl:text> <xsl:value-of select="ejb-class"/> <xsl:text>,</xsl:text> <xsl:text>MDB</xsl:text> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Sample XSL to extract to HTML file
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>EJB names</title> </head> <body> <table> <tr> <td colspan="3"><strong>** ENTITY BEAN ** </strong></td> </tr> <xsl:for-each select="/ejb-jar/enterprise-beans/entity"> <tr> <td><xsl:value-of select="ejb-name"/></td> <td><xsl:value-of select="ejb-class"/></td> <td>Entity Bean</td> </tr> </xsl:for-each> <tr> <td colspan="3"><strong>** SESSION BEAN ** </strong></td> </tr> <xsl:for-each select="/ejb-jar/enterprise-beans/session"> <tr> <td><xsl:value-of select="ejb-name"/></td> <td><xsl:value-of select="ejb-class"/></td> <td>Session Bean</td> </tr> </xsl:for-each> <tr> <td colspan="3"><strong>** MESSAGE-DRIVEN BEAN ** </strong></td> </tr> <xsl:for-each select="/ejb-jar/enterprise-beans/message-driven"> <tr> <td><xsl:value-of select="ejb-name"/></td> <td><xsl:value-of select="ejb-class"/></td> <td>MDB</td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>