1 Reply Latest reply: Jul 1, 2014 7:29 AM by jtahlborn RSS

    xml parsing using XSLT .

    ibney

      I have use below code to parse the xml using xslt i am getting below error. Please help me to resolve this.

       

       

      package com;

       

      import java.io.ByteArrayOutputStream;

      import java.io.File;

      import java.io.*;

      import java.io.IOException;

       

       

      import javax.xml.transform.Source;

      import javax.xml.transform.Transformer;

      import javax.xml.transform.TransformerFactory;

      import javax.xml.transform.stream.StreamResult;

      import javax.xml.transform.stream.StreamSource;

       

       

       

       

      public class TestXSLT {

       

       

       

       

              public static void main(String[] args)throws IOException  {

           

                    

                      String InputXmlFileName = args[0];

                      String InputXsltFileName = args[1];

                      String OutputCsvFineName =args[2];

                      BufferedWriter out = new BufferedWriter(new FileWriter(OutputCsvFineName));

                      String returnHtml;

              try {

                  Source xmlSource = new StreamSource(new File(InputXmlFileName));

                  Source xsltSource = new StreamSource(new File(InputXsltFileName));

       

       

       

       

                  TransformerFactory factory = TransformerFactory.newInstance();

                  Transformer transformer = factory.newTransformer(xsltSource);

                  ByteArrayOutputStream bOut = new ByteArrayOutputStream();

                  transformer.transform(xmlSource, new StreamResult(bOut));

       

       

       

       

                  bOut.close();

                  returnHtml = bOut.toString();

                  out.write(returnHtml);

                  out.close();

               // System.err.println(returnHtml);

              } catch (Exception e) {

                      e.printStackTrace();

                  System.err.println("Exception occurred: " + e);

              }

              }

       

      }

       

       

       

      I am getting below error .Please help me this issue..

       

      ERROR:  'No more DTM IDs are available'

      javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available

        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:716)

        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)

        at com.TestXSLT.main(TestXSLT.java:34)

      Caused by: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available

        at com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault.addDTM(DTMManagerDefault.java:146)

        at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:416)

        at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:234)

        at com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl.getResultTreeFrag(SAXImpl.java:1832)

        at com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter.getResultTreeFrag(DOMAdapter.java:434)

        at MACSXML_Parts.template$dot$0()

        at MACSXML_Parts.applyTemplates()

        at MACSXML_Parts.applyTemplates()

        at MACSXML_Parts.transform()

        at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:603)

        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:709)

        ... 2 more

      ---------

      com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available

        at com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault.addDTM(DTMManagerDefault.java:146)

        at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:416)

        at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:234)

        at com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl.getResultTreeFrag(SAXImpl.java:1832)

        at com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter.getResultTreeFrag(DOMAdapter.java:434)

        at MACSXML_Parts.template$dot$0()

        at MACSXML_Parts.applyTemplates()

        at MACSXML_Parts.applyTemplates()

        at MACSXML_Parts.transform()

        at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:603)

        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:709)

        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)

        at com.TestXSLT.main(TestXSLT.java:34)

      Exception occurred: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available