0 Replies Latest reply on May 12, 2010 1:34 PM by Luis Esquivel

    Help with XSL Transformation Exception - The processing in struction target matching "[xX][mM][lL]" is not allowed.

    Luis Esquivel Newbie

      Hello,

       

      I have a simple JSP that does a XSL to HTML Transformation and I get the following Exception:  (Note: the exact same code works in JRun, and as a stand alone application.

       

      com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The processing in
      struction target matching "[xX][mM][lL]" is not allowed.
              at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XS
      LTCDTMManager.java:446)
              at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XS
      LTCDTMManager.java:234)
              at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(T
      ransformerImpl.java:525)
              at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transfor
      m(TransformerImpl.java:710)
              at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transfor
      m(TransformerImpl.java:313)
              at org.apache.jsp.xmlhtml_jsp._jspService(xmlhtml_jsp.java:107)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
      .java:369)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
      22)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
      lter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:235)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:191)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
      yAssociationValve.java:190)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:92)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.proce
      ss(SecurityContextEstablishmentValve.java:126)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invok
      e(SecurityContextEstablishmentValve.java:70)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
      onnectionValve.java:158)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:330)
              at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
              at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpPro
      tocol.java:384)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
      7)
              at java.lang.Thread.run(Thread.java:619)

       

      My Code:

       

      //This is a test XML data.  The output html file should just say "test4"

      String sXMLData = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\"?>" +
                "<?xml:stylesheet type=\"text/xsl\" href=\"converter1.xsl\"?>" +
                "<converter>" +
                "<p>test4</p>" +
                "</converter>";
               
            String xmlData = sXMLData.trim();
           
            String sXSLFile = "C:\\J2EEApps\\resources\\xmlrtftools\\xhtml2rtf\\converter1.xsl";     
            String outFile = "C:\\J2EEApps\\Temp\\testHtmlFile.html";

            StreamSource sXSLFileSource  = new StreamSource(sXSLFile);
            StringReader stringReader = new StringReader(xmlData);
            StreamSource sXMLDataSource = new StreamSource(stringReader);
            FileOutputStream fileOutputStream = new FileOutputStream(outFile);
            StreamResult streamResult = new StreamResult(fileOutputStream);

            TransformerFactory tFactory = com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newInstance();
            Transformer transformer = tFactory.newTransformer(sXSLFileSource);
            out.println("<br>" + transformer.getClass());

            com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.
            transformer.transform(sXMLDataSource, streamResult);
        
            fileOutputStream.close();

       

      My converter1.xsl file:

       

      <?xml version="1.0"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:strip-space elements="converter"/>
        <xsl:strip-space elements="p"/>
        <xsl:strip-space elements="list"/>
        <xsl:strip-space elements="item"/>
        <xsl:preserve-space elements="TEXTFORMAT"/>
        <xsl:preserve-space elements="b"/>
        <xsl:preserve-space elements="u"/>
        <xsl:preserve-space elements="i"/>
        <xsl:output method="html" indent="no"/>
        <!-- match our root tag -->
        <xsl:template match="converter">
          <TEXTFORMAT LEADING="2">
            <xsl:apply-templates/>
          </TEXTFORMAT>
        </xsl:template>
        <!-- format spacing between font format tags b u  and i -->
        <xsl:template match="b">
          <b>
            <xsl:apply-templates/>
          </b><xsl:text>&#xa0;</xsl:text>
        </xsl:template>
        <!-- normalize the spaces for our p tags -->
        <xsl:template match="p">
          <xsl:if test="normalize-space(.)">
            <xsl:copy>
              <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
          </xsl:if>
        </xsl:template>
        <xsl:template match="@*">
          <xsl:copy>
            <xsl:apply-templates select="node()"/>
          </xsl:copy>
        </xsl:template>
        <xsl:template match="u">
          <u>
            <xsl:apply-templates/>
          </u><xsl:text>&#xa0;</xsl:text>
        </xsl:template>
        <xsl:template match="i">
          <i>
            <xsl:apply-templates/>
          </i><xsl:text>&#xa0;</xsl:text>
        </xsl:template>
        <!-- font tag formatting and conversion -->
        <xsl:template match="C">
          <TEXTFORMAT LEADING="2">
            <p ALIGN="LEFT">
              <FONT FACE="Arial,Helvetica,sans-serif" SIZE="15" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
                <xsl:apply-templates/>
              </FONT>
            </p>
          </TEXTFORMAT>
        </xsl:template>
        <xsl:template match="FONT">
          <FONT FACE="Arial,Helvetica,sans-serif" SIZE="15" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
            <xsl:apply-templates/>
          </FONT>
        </xsl:template>
        <!-- hyper links -->
        <xsl:template match="link">
          <a>
            <xsl:attribute name="HREF">
              <xsl:value-of select="@url"/>
            </xsl:attribute>
            <xsl:attribute name="TARGET">blank</xsl:attribute>
            <xsl:apply-templates/>
          </a>
        </xsl:template>

        <!-- bullets and list items-->
        <xsl:template match="list">
          <ul>
            <xsl:apply-templates select="item"/>
          </ul>
        </xsl:template>
        <xsl:template match="item">
          <li>
            <xsl:apply-templates select="p"/>
          </li>
        </xsl:template>
      </xsl:stylesheet>

       

      I have made sure there are no spaces before the prolog of the xml file.  I believe it is something within JBoss because the same code works in other environments.

       

      Also, in the run.bat file I added the following jvm option to even get this far:  -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

       

      Thanks in advance to anyone that can help with this!