This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes XSLT: Transformer Configuration Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "XSLT: Transformer Configuration Exception" Watch "XSLT: Transformer Configuration Exception" New topic
Author

XSLT: Transformer Configuration Exception

Sonu KumarGupta
Greenhorn

Joined: Jun 26, 2007
Posts: 3
Hi,

I am getting this error


<LogAction>
<refNo><![CDATA[CHQFW000GG7B361->2]]></refNo>
<exname><![CDATA[javax.servlet.ServletException]]></exname>
<pageMessage><![CDATA[javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.]]></pageMessage>
<mailMessage><![CDATA[javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
javax.servlet.ServletException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:639)
at com.ibm._jsp._makePayment._jspService(_makePayment.java:108)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:117)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:171)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor.handleRequest(JSPExtensionProcessor.java:230)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:250)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1896)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1701)
at com.cfc.ice.struts.servlet.IceActionServlet.process(IceActionServlet.java:215)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:250)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1896)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1701)
at com.cfc.ice.struts.servlet.IceActionServlet.process(IceActionServlet.java:215)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:250)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1896)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1701)
at com.cfc.ice.struts.servlet.IceActionServlet.process(IceActionServlet.java:215)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

]]></mailMessage>
<errorcode><![CDATA[]]></errorcode>
<subject><![CDATA[javax.servlet.ServletException]]></subject>
<timestamp><![CDATA[26/Jun/2007:17:06:53-404]]></timestamp>
<stacktrace><![CDATA[javax.servlet.ServletException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:639)
at com.ibm._jsp._makePayment._jspService(_makePayment.java:108)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:117)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:171)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor.handleRequest(JSPExtensionProcessor.java:230)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:250)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1896)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1701)
at com.cfc.ice.struts.servlet.IceActionServlet.process(IceActionServlet.java:215)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:250)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1896)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1701)
at com.cfc.ice.struts.servlet.IceActionServlet.process(IceActionServlet.java:215)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:250)
at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1896)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1701)
at com.cfc.ice.struts.servlet.IceActionServlet.process(IceActionServlet.java:215)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

]]></stacktrace>
</LogAction>

Can anyone help me.....
Help will be higly appreciated
[ June 26, 2007: Message edited by: Bear Bibeault ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
The key is:
The markup in the document preceding the root element must be well-formed.]

Whatever your character stream source is, it is not correct XML. Examine the exact text carefully - it could be as simple as a blank line, XML is very picky about document starts.

Bill
Sonu KumarGupta
Greenhorn

Joined: Jun 26, 2007
Posts: 3
Thanks Bill for Your Reply

Actually my XML is embedded in JSP and it is using XSL, which is also embedded in JSP.

My XML looks like this. In fact it is JSP
<%@ page contentType="text/html;charset=ISO-8859-1" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tag-struts.tld" prefix="tags" %>

<tags:xslt xsl="makePayment.jsp" name="userAcctInfo" property="acctNumber">
<html:form method="POST" action="/makePaymentSummaryAction.do">
<environment.country><bean:write name="environment.country"/></environment.country>
<environment.language><bean:write name="environment.language"/></environment.language>
<environment.brand><bean:write name="environment.brand"/></environment.brand>

<%@ include file="includes/header.jsp" %>

<%@ include file="includes/nav_left.jsp" %>
<footer>true</footer>


<inputMode><bean:write name="paymentForm" property="inputMode"/></inputMode>

<instruction><![CDATA[<tags:property property="payment.text.makePayment.instructions"/>]]></instruction>
<instructionTrk><![CDATA[<tags:property property="payment.text.makePayment.instructionsOne"/>
<br/><br/><tags:property property="payment.text.makePayment.cuttofftimeOne"/> <tags:property property="companyName.text.trade"/> <tags:property property="payment.text.makePayment.cuttofftimeTwo"/>
<br/><br/><tags:property property="payment.text.makePayment.instructionsTwo"/>
]]></instructionTrk>
<requiredText><tags:property property="payment.text.required"/></requiredText>

<paymentLink><![CDATA[<tags:url scheme="https"/><tags:property property="navLeft.link.paymentProfile"/>]]></paymentLink>

<paymentLinkText><tags:property property="payment.text.makePayment.instructionsLinkText"/></paymentLinkText>

<errors><![CDATA[<tags:errors style="healey" anchors="true" fields="payment.paymentAmt;payment.paymentDate;"/>]]></errors>

<paymentFields>

<paymentAmountLabel><tags:property property="payment.text.paymentAmount"/></paymentAmountLabel>
<paymentCurrencyText><tags:property property="payment.text.currency"/></paymentCurrencyText>
<paymentAmountField><![CDATA[<tags:text property="payment.paymentAmt" size="12" maxlength="12" anchor="true" errorsign="true"/> <font color="#000000"><tags:property property="payment.text.amountExample"/></font>]]></paymentAmountField>


<paymentDateLabel><tags:property property="payment.text.paymentDate"/></paymentDateLabel>
<paymentDateMonthField><![CDATA[<tags:text property="payment.paymentMonth" size="2" maxlength="2" anchor="false" errorsign="false"/>]]></paymentDateMonthField>
<paymentDateDayField><![CDATA[<tags:text property="payment.paymentDay" size="2" maxlength="2" anchor="false" errorsign="false"/>]]></paymentDateDayField>
<paymentDateYearField><![CDATA[<tags:text property="payment.paymentYear" size="4" maxlength="4" anchor="false" errorsign="false"/>
<tags:errorsign property="payment.paymentDate"/>
<a name="payment.paymentDate"/>
<font color="#000000"><tags:property property="payment.text.dateExample"/></font>]]></paymentDateYearField>

<accountNumberLabel><tags:property property="payment.text.accountNumber"/></accountNumberLabel>
<accountNumberValue><bean:write name="userAcctInfo" property="acctNumber"/></accountNumberValue>

<bankNameLabel><tags:property property="payment.text.bankName"/></bankNameLabel>
<bankNameValue><bean:write name="bankProfile" property="bankName"/></bankNameValue>

<bankAcctTypeLabel><tags:property property="payment.text.bankAcctType.label"/></bankAcctTypeLabel>
<bankAcctTypeValue><bean:write name="bankProfile" property="acctDescription"/></bankAcctTypeValue>

<bankRoutingNumberLabel><tags:property property="payment.text.bankRoutingNumber"/></bankRoutingNumberLabel>
<bankRoutingNumberValue><tags:ext-maskwrite name="bankProfile" property="routingNum" maskingCharacter="x" unMaskedDigits="4"/></bankRoutingNumberValue>

<bankAcctNumberLabel><tags:property property="payment.text.bankAcctNumber"/></bankAcctNumberLabel>
<bankAcctNumberValue><tags:ext-maskwrite name="bankProfile" property="acctNum" maskingCharacter="x" unMaskedDigits="4"/></bankAcctNumberValue>

<emailLabel><tags:property property="payment.text.email"/></emailLabel>
<emailValue><bean:write name="bankProfile" property="email"/></emailValue>

</paymentFields>


</html:form>
</tags:xslt>


MY XSL looks like this, which is also JSP

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY raquo "�">
<!ENTITY nbsp " ">
<!ENTITY copy "�">
<!ENTITY reg "�">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xslutput method="html" indent="yes" encoding="ISO-8859-1"/>
<jsp:include page="includes/header.jsp"/>
<jsp:include page="includes/nav_left.jsp"/>
<jsp:include page="includes/footer.jsp"/>
<jsp:include page="includes/template.jsp"/>
<jsp:include page="includes/paymentFields.jsp"/>

<xsl:template match="form">
<xsl:text/>
<script language="javascript"><![CDATA[
function init(){
selectMenu('makePayment');
}

function getElement( name ) {
for ( var w = 0; w < document.paymentForm.elements.length; w++ ) {
if ( document.paymentForm.elements[ w ].name == name ) {
return document.paymentForm.elements[ w ];
}
}
return null;
}

function submitForm() {

getElement( "inputMode" ).value = "insert";
document.paymentForm.submit();

}

]]></script>
<xsl:element name="form">
<xsl:attribute name="name">paymentForm</xsl:attribute>
<xsl:attribute name="method">POST</xsl:attribute>
<xsl:attribute name="action"><xsl:value-of select="/form/header/https"/>/makePaymentSummaryAction.do</xsl:attribute>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">environment.country</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="environment.country"/></xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">environment.language</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="environment.language"/></xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">environment.brand</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="environment.brand"/></xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">inputMode</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="inputMode"/></xsl:attribute>
</xsl:element>

<table width="750" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top">
<td>
<table cellspacing="0" cellpadding="0" border="0">
<tr><td><div id="shadeImg"></div></td></tr>
</table>
<table border="0" width="540" style="margin: 0 0 0 10px;" cellspacing="0" cellpadding="0">
<tr><td colspan="2"><img src="resources/images/spacer.gif" height="22"/></td></tr>
<tr>
<td align="left"><img src="resources/images/makePaymentPayBill.gif"/></td>
<td align="right" valign="center"><img src="resources/images/step.gif"/><img src="resources/images/spacer.gif" width="8"/><img src="resources/images/oneSelected.gif"/><img src="resources/images/spacer.gif" width="8"/><img src="resources/images/two.gif"/><img src="resources/images/spacer.gif" width="8"/><img src="resources/images/three.gif"/></td>
</tr>
<tr><td colspan="2"><img src="resources/images/spacer.gif" height="12"/></td></tr>
<tr><td colspan="2"><img src="resources/images/dotline.gif"/></td></tr>
</table>


<table border="0" width="500" style="margin: 0 0 0 10px;" cellspacing="0" cellpadding="0">
<tr><td><img src="resources/images/spacer.gif" height="19"/></td></tr>
<tr>
<td class="peHomeText">
<xsl:value-of disable-output-escaping="yes" select="instruction"/><xsl:text>  </xsl:text>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="paymentLink"/></xsl:attribute>
<xsl:value-of select="paymentLinkText"/>
</xsl:element>
<br/><br/>
<font color="red">*</font><xsl:value-of select="requiredText"/>
</td>
</tr>
</table>
<table border="0" width="500" style="margin: 0 0 0 10px;" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" width="525">
<table width="525">
<tr>
<td width="3"><img src="resources/images/spacer.gif" height="1" width="3"/></td>
<td width="519">
<!-- START ERRORS -->
<span class="bodyfont"><xsl:value-of disable-output-escaping="yes" select="errors"/></span>
<!-- END ERRORS -->
</td>
<td><img src="resources/images/spacer.gif" height="1" width="3"/></td>
</tr>
</table>
</td>
</tr>
</table>

<table border="0" width="500" style="margin: 0 0 0 10px;" cellspacing="0" cellpadding="0">

<xsl:apply-templates select="paymentFields"/>

</table>

<table border="0" width="500" style="margin: 0 0 0 10px;" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" align="left">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td><img src="resources/images/spacer.gif" height="15"/></td></tr>
<tr>
<td align="left">
<span class="con"><a href="javascript:submitForm();"></a></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:element>
</xsl:template>


</xsl:stylesheet>


Can you check this and see what the error is. We are using custom tag library. If i add <%@ taglib uri="/WEB-INF/tag-struts.tld" prefix="tags" %> to my XSL then it gives the error which i have posted otherwise it gives tags:property is not bound.

Your help will higly appreciated
Thanks
Sonu KumarGupta
Greenhorn

Joined: Jun 26, 2007
Posts: 3
output characters, thus creating a character stream that does not
constitute legal XML. Try capturing the actual output streams and
you will see what I mean.

Personally, if I have to create XML like this I create a template
that has the structure of a valid XML document with place-holders
where values have to be plugged in. Manipulating XML is hard
enough without mixing in JSP syntax.

----------------------
Even quicker than capturing the output, look at the Java source code
which the JSP processor creates. I bet you will be surprised at
what it is writing.
----------------------

As you have replied this. I am not getting what do you want to say. Is that, there is a problem in the JSP Which constitutes my XML or other JSP which constitutes my XSL. Please tell me completely where is the error as i am struggling with this error for almost 20 days.

Your answer will be higly appreciated

Thanks and Regards
Nitin
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I am saying that trying to write a valid XML document with JSP is full of possibilities for error due to the way JSP outputs literal text from the script document. This error:

The markup in the document preceding the root element must be well-formed.


specifically says that the Transformer is not seeing valid XML input. It could be from either the XML or the XSL generator. Look at the Java servlet which to JSP gets converted to - I am betting that the content of the initial statements which you expect to be writing valid XML are in fact writing some text that comes at the start of your JSP, thus creating invalid XML.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XSLT: Transformer Configuration Exception