0 Replies Latest reply on Nov 15, 2004 8:16 AM by Andreas

    After upgrading from 3.2.3 to 3.2.6, now xslt routines throw

    Andreas Newbie

      Hi, our webhoster forced us to upgrade our jboss 3.2.3 installation to 3.2.6. The deployed application still runs as expected but there are now many xslt related error messages in the server log.

      This is what I see:
      12:44:08,699 INFO [STDOUT] [Error] :99:80: Document root element "xsl:stylesheet", must match DOCTYPE root "stylesheet".
      12:44:08,700 INFO [STDOUT] [Error] :99:80: Element type "xsl:stylesheet" must be declared.
      12:44:08,704 INFO [STDOUT] [Error] :105:27: Element type "xsl:output" must be declared.
      12:44:08,710 INFO [STDOUT] [Error] :107:29: Element type "xsl:template" must be declared.
      12:44:08,712 INFO [STDOUT] [Error] :108:15: Element type "html" must be declared.
      12:44:08,714 INFO [STDOUT] [Error] :109:19: Element type "head" must be declared.
      12:44:08,715 INFO [STDOUT] [Error] :110:49: Element type "xsl:call-template" must be declared.
      12:44:08,717 INFO [STDOUT] [Error] :112:19: Element type "body" must be declared.

      I am not so much into xslt anymore, but maybe some of you have experienced the same problem and can point me to the couse of this problem :-)

      -------------------
      Transomer setup
      -------------------

      try {
       // Step 1: create a DocumentBuilderFactory and configure it
       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      
       // Optional: set various configuration options
       factory.setValidating( false );
       factory.setIgnoringComments( true );
       factory.setIgnoringElementContentWhitespace( true );
       factory.setCoalescing( false );
       factory.setExpandEntityReferences( true );
      
       // Step 2: create a DocumentBuilder that satisfies the constraints
       // specified by the DocumentBuilderFactory
       DocumentBuilder builder = factory.newDocumentBuilder();
       Document document = builder.parse( new ByteArrayInputStream( inputXML.getBytes(encoding) ) );
       DOMSource domsource = new DOMSource( document );
       //
       StreamSource stylesource =
       new StreamSource( new ByteArrayInputStream( mailTemplate.getBytes(encoding) ) );
       StringWriter sw = new StringWriter();
       StreamResult result = new StreamResult( sw );
       //
       TransformerFactory tFactory = TransformerFactory.newInstance();
       Transformer transformer = tFactory.newTransformer( stylesource );
       //
       transformer.setOutputProperty(OutputKeys.METHOD, outputMethod);
       //transformer.setOutputProperty(OutputKeys.METHOD, "xml");
       transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
       transformer.setOutputProperty(OutputKeys.INDENT, "yes");
       transformer.transform( domsource, result );
      
       emailBody = sw.toString();
      }
      


      one of the stylesheets

      <?xml version="1.0" encoding="ISO-8859-1" ?>
      <!DOCTYPE stylesheet [
       <!ENTITY iexcl "¡"> <!-- inverted exclamation mark -->
       <!ENTITY cent "¢"> <!-- cent sign -->
       ...
       many more of them
       ...
       <!ENTITY thorn "þ"> <!-- small thorn, Icelandic -->
       <!ENTITY yuml "ÿ"> <!-- small y, dieresis or umlaut mark -->
       ]>
      <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output
       method="xml"
       doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
       doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
       encoding="ISO-8859-1"
       indent="yes" />
      
       <xsl:template match="/">
       <html>
       <head>
       <xsl:call-template name="head"/>
       </head>
       <body>
       <xsl:call-template name="logo"/>
       <xsl:apply-templates select="order" />
       <xsl:call-template name="footer"/>
       </body>
       </html>
       </xsl:template>
      
       <xsl:template name="head">
       <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
       <title>XY</title>
       <style type="text/css"> some styles here </style>
       </xsl:template>
      
       <xsl:template name="logo">
       <img src="http://domain.com/ui/media/firmnamebanner.gif" alt="firmnamebanner.gif" />
       </xsl:template>
      
       <xsl:template match="order">
       <div style="margin-top: 20px; margin-left: 50px">
       Thank you for contacting XY.
       <br />
       <br />
       <br />
       Text for transfer: <span class="bold"><xsl:value-of select="account" /> (<xsl:value-of select="@id" />)</span>
       <br />
       Amount to transfer: <span class="bold"><xsl:value-of select="ordertotal" /></span>
       Thank you for using XY.
       <br /><br />
       </div>
       </xsl:template>
      
       <xsl:template name="footer">
       <div class='pp_footer'>
       This e-mail is automatically forwarded. Please do not reply on this e-mail since you will not get an answer back.
       </div>
       </xsl:template>
      
      </xsl:stylesheet>