Hi....
Am getting Folowing Exception while parsing the XSL file. Am using java 1.4 and MSXML4.2 SP2 parser andSDK.
but when I installed SQLServer2005, with that MSXML 6.0 Parser is Installed.
It is working fine before instalation of SQLServer2005.
java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.compiler.FunctionCall.translate(FunctionCall.java:826)
at com.sun.org.apache.xalan.internal.xsltc.compiler.ValueOf.translate(ValueOf.java:114)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.translateContents(SyntaxTreeNode.java:490)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XslAttribute.translate(XslAttribute.java:252)
..................
Compiler warnings:
file:///F:/Data/JRun4/servers/ABC/MainXSL.xsl: line 155: Attribute 'LenderBranchIdentifier' outside of element.
file:///F:/Data/JRun4/servers/ABC/MainXSL.xsl: line 156: Attribute 'LenderRegistrationIdentifier' outside of element.
..........
ERROR: 'null'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:753)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:548)
at com.ls.lsglobal.common.CLOUTSQLXML.TransXml2Xml(CLOUTSQLXML.java:274)
And My XSL is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.5" xmlns:lsjava1="com.ls.lsglobal.common" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="lsjava1" >
<xslutput method="xml" indent="yes" encoding="utf-8" doctype-system="MyRequest.1.3.DTD"/>
<xsl:template match="/" >
<REQUEST_GROUP>
<TRANSMITTAL_DATA>
<xsl:if test="AppraisedVal!=''">
<xsl:attribute name="AppraisedValueAmount"><xsl:value-of select="AppraisedVal"/></xsl:attribute>
</xsl:if>
<xsl:if test="StatedVal!=''">
<xsl:attribute name="EstimatedValueAmount"><xsl:value-of select="StatedVal"/></xsl:attribute>
</xsl:if>
<xsl:for-each select="ROOT/AppMain/MyLoop/Liab">
<xsl:if test=" normalize-space(LiabTypCd) = 'SMG' and (normalize-space(PresFutTypCd) = 'BOTH' or normalize-space(PresFutTypCd) = 'PRES') and PresLienPos='1' and normalize-space(RefCd) != 'LOAN'">
<xsl:attribute name="CurrentFirstMortgageHolderType"><xsl:value-of select="LiabId"/></xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:attribute name="LenderBranchIdentifier">0001</xsl:attribute>
<xsl:attribute name="LenderRegistrationIdentifier"><xsl:value-of select="ROOT/AppMain/MyNum"/></xsl:attribute>
</TRANSMITTAL_DATA>
</REQUEST_GROUP>
...............
</xsl:template>
</xsl:stylesheet>
And My Java Code is
public String TransXml2Xml(String xmlInFile, String xslFile, String xmlOutFile) throws Exception
{
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringElementContentWhitespace(true);
Document document;
File stylesheet = new File(xslFile);
File dataInfile = new File(xmlInFile);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(dataInfile);
System.err.println("-->AVC:::xslFile="xslFile" xmlInFile="xmlInFile" xmlOutFile="+xmlOutFile);
StreamSource stylesource = new StreamSource(stylesheet);
TransformerFactory t=TransformerFactory.newInstance();
Transformer transformer = t.newTransformer(stylesource);
DOMSource source = new DOMSource(document);
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(new File(xmlOutFile));
transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT , "yes");
transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
if(strCLUTDTD_PATH.equals(""))
{
java.util.Properties props = new java.util.Properties();
java.io.FileInputStream fis = new java.io.FileInputStream("DataFileBasePath.properties");
props.load(fis);
fis.close();
strCLUTDTD_PATH = checkNull(props.get("CLUTREQDTD_PATH"));
}
transformer.setOutputProperty(javax.xml.transform.OutputKeys.DOCTYPE_SYSTEM , strCLUTDTD_PATH);
transformer.transform(source, result);
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
return "";
}
can any one know what solution for this problem. It is very help full for me.
Am getting Folowing Exception while parsing the XSL file. Am using java 1.4 and MSXML4.2 SP2 parser andSDK.
but when I installed SQLServer2005, with that MSXML 6.0 Parser is Installed.
It is working fine before instalation of SQLServer2005.
java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.compiler.FunctionCall.translate(FunctionCall.java:826)
at com.sun.org.apache.xalan.internal.xsltc.compiler.ValueOf.translate(ValueOf.java:114)
at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.translateContents(SyntaxTreeNode.java:490)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XslAttribute.translate(XslAttribute.java:252)
..................
Compiler warnings:
file:///F:/Data/JRun4/servers/ABC/MainXSL.xsl: line 155: Attribute 'LenderBranchIdentifier' outside of element.
file:///F:/Data/JRun4/servers/ABC/MainXSL.xsl: line 156: Attribute 'LenderRegistrationIdentifier' outside of element.
..........
ERROR: 'null'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:753)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:548)
at com.ls.lsglobal.common.CLOUTSQLXML.TransXml2Xml(CLOUTSQLXML.java:274)
And My XSL is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.5" xmlns:lsjava1="com.ls.lsglobal.common" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="lsjava1" >
<xslutput method="xml" indent="yes" encoding="utf-8" doctype-system="MyRequest.1.3.DTD"/>
<xsl:template match="/" >
<REQUEST_GROUP>
<TRANSMITTAL_DATA>
<xsl:if test="AppraisedVal!=''">
<xsl:attribute name="AppraisedValueAmount"><xsl:value-of select="AppraisedVal"/></xsl:attribute>
</xsl:if>
<xsl:if test="StatedVal!=''">
<xsl:attribute name="EstimatedValueAmount"><xsl:value-of select="StatedVal"/></xsl:attribute>
</xsl:if>
<xsl:for-each select="ROOT/AppMain/MyLoop/Liab">
<xsl:if test=" normalize-space(LiabTypCd) = 'SMG' and (normalize-space(PresFutTypCd) = 'BOTH' or normalize-space(PresFutTypCd) = 'PRES') and PresLienPos='1' and normalize-space(RefCd) != 'LOAN'">
<xsl:attribute name="CurrentFirstMortgageHolderType"><xsl:value-of select="LiabId"/></xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:attribute name="LenderBranchIdentifier">0001</xsl:attribute>
<xsl:attribute name="LenderRegistrationIdentifier"><xsl:value-of select="ROOT/AppMain/MyNum"/></xsl:attribute>
</TRANSMITTAL_DATA>
</REQUEST_GROUP>
...............
</xsl:template>
</xsl:stylesheet>
And My Java Code is
public String TransXml2Xml(String xmlInFile, String xslFile, String xmlOutFile) throws Exception
{
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringElementContentWhitespace(true);
Document document;
File stylesheet = new File(xslFile);
File dataInfile = new File(xmlInFile);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(dataInfile);
System.err.println("-->AVC:::xslFile="xslFile" xmlInFile="xmlInFile" xmlOutFile="+xmlOutFile);
StreamSource stylesource = new StreamSource(stylesheet);
TransformerFactory t=TransformerFactory.newInstance();
Transformer transformer = t.newTransformer(stylesource);
DOMSource source = new DOMSource(document);
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(new File(xmlOutFile));
transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT , "yes");
transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
if(strCLUTDTD_PATH.equals(""))
{
java.util.Properties props = new java.util.Properties();
java.io.FileInputStream fis = new java.io.FileInputStream("DataFileBasePath.properties");
props.load(fis);
fis.close();
strCLUTDTD_PATH = checkNull(props.get("CLUTREQDTD_PATH"));
}
transformer.setOutputProperty(javax.xml.transform.OutputKeys.DOCTYPE_SYSTEM , strCLUTDTD_PATH);
transformer.transform(source, result);
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
return "";
}
can any one know what solution for this problem. It is very help full for me.