title: How Could I transform XML into XSL without getting error, using JAVA xml API
body: <p>I tried to convert XML file into HTML using XSLT format but i got an error</p>
  
  <pre><code>RROR:  'Namespace prefix 'vuln' is undeclared.'
  FATAL ERROR:  'Could not compile stylesheet' 
  </code></pre>
  
  <p>The XML file started with </p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;?xml-stylesheet type="text/xsl" version ="2.0" href="nvdXSLT.xsl"?&gt;
  &lt;nvd xmlns:cpe-lang="http://cpe.mitre.org/language/2.0" 
   xmlns:scapcore="http://scap.nist.gov/schema/scap-core/0.1" 
   xmlns:vuln="http://scap.nist.gov/schema/vulnerability/0.4" 
   xmlns:cvss="http://scap.nist.gov/schema/cvss-v2/0.2" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:patch="http://scap.nist.gov/schema/patch/0.1" 
   xmlns="http://scap.nist.gov/schema/feed/vulnerability/2.0" &gt;
     &lt;entry id="CVE-2007-5333"&gt;
     &lt;vuln:vulnerable-software-list&gt;
       &lt;vuln:product&gt;cpe:/a:apache_software_foundation:tomcat:4.1.34&lt;/vuln:product&gt;
       &lt;vuln:product&gt;cpe:/a:apache_software_foundation:tomcat:4.1.37&lt;/vuln:product&gt;
       &lt;vuln:product&gt;cpe:/a:apache:tomcat:4.1.24&lt;/vuln:product&gt;
       &lt;vuln:product&gt;cpe:/a:apache:tomcat:5.5.5&lt;/vuln:product&gt;
       &lt;vuln:product&gt;cpe:/a:apache:tomcat:5.5.2&lt;/vuln:product&gt;
     &lt;/vuln:vulnerable-software-list&gt;
     &lt;vuln:cve-id&gt;CVE-2007-5333&lt;/vuln:cve-id&gt;
     &lt;vuln:published-datetime&gt;2008-02-11T20:00:00.000-05:00&lt;/vuln:published-datetime&gt;
     &lt;vuln:last-modified-datetime&gt;2014-03-15T23:16:41.310-04:00&lt;/vuln:last-modified-datetime&gt;
    &lt;/entry&gt;
   &lt;/nvd&gt;
  </code></pre>
  
  <p>And i created XSL transformer to transform the xml content into organized format and display the output on html format javax.xml.transform API.
  The XSL file as follow:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"           
     xmlns:vuln="http://scap.nist.gov/schema/vulnerability/0.4" 
     xmlns:cvss="http://scap.nist.gov/schema/cvss-v2/0.2"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:patch="http://scap.nist.gov/schema/patch/0.1"
     xmlns="http://scap.nist.gov/schema/feed/vulnerability/2.0"&gt;
     &lt;xsl:output method="html" encoding="UTF-8" indent="yes"/&gt;
  &lt;xsl:template match="/"&gt;
      &lt;!-- TODO: Auto-generated template --&gt;
      &lt;html&gt;
      &lt;body&gt;
      &lt;h1&gt;Parsing NVD XML file&lt;/h1&gt;
      &lt;table border="1"&gt;
                &lt;tr&gt;
                   &lt;th&gt;hasAffectedProducts&lt;/th&gt;       
                &lt;/tr&gt;
      &lt;xsl:for-each select="nvd/entry"&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;xsl:for-each select="/vuln:vulnerable-software-list"&gt;&lt;xsl:value-of select="vuln:product" /&gt;&lt;/xsl:for-each&gt;&lt;/td&gt;
                   &lt;/tr&gt;
              &lt;td&gt;&lt;xsl:value-of select="vuln:cve-id" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;xsl:value-of select="vuln:published-datetime" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;xsl:value-of select="vuln:last-modified-datetime"/&gt;&lt;/td&gt;
           .....
  </code></pre>
  
  <p>The JAVA API that I used to do transformation </p>
  
  <pre><code>  public void transform(String dataXML, String inputXSL, String outputHTML)
          throws TransformerConfigurationException, TransformerException {
  
      TransformerFactory factory = TransformerFactory.newInstance();
      StreamSource xslStream = new StreamSource(inputXSL);
      Transformer transformer = factory.newTransformer(xslStream);
      StreamSource in = new StreamSource(dataXML);
      StreamResult out = new StreamResult(outputHTML);
      transformer.transform(in, out);
      System.out.println("The generated HTML file is:" + outputHTML);
  
  }
  </code></pre>
  
  <p>Simply, received XML file and XSL file and create output file int HTML format. </p>