user3073182
user3073182

Reputation: 17

How to transform xml file to another file using xslt ? The code should be in java

I am getting fatal error: The prefix "xsl" for element "xsl:stylesheet" is not bound.

ERROR: 'The prefix "xsl" for element "xsl:stylesheet" is not bound.' FATAL ERROR: 'Could not compile stylesheet' javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source) at com.quicklyjava.JavaXSLT.main(JavaXSLT.java:20)

<xsl:stylesheet version="1.0"> 
 <xsl:template match="/">
  <html>
   <body>
    <h1>Movies</h1>
    <table border="3">
     <tr bgcolor="grey">
    <th>Genre</th>
    <th>Title</th>
    <th>Director</th>
    <th>Price</th>
     </tr>
   <xsl:for-each select="movies/movie">
     <tr>
    <td>
        <xsl:value-of select="@genre"/>
    </td>
    <td>
        <xsl:value-of select="title"/>
    </td>
    <td>
        <xsl:value-of select="director"/>
    </td>
    <td>
        <xsl:value-of select="price"/>
    </td>
      </tr>
   </xsl:for-each>
   </table>
   </body>
  </html>
</xsl:template>
</xsl:stylesheet>

Upvotes: 1

Views: 1416

Answers (1)

Yurii
Yurii

Reputation: 4911

I suppose you're missing the xsl namespace declaration:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Upvotes: 2

Related Questions