XSLT Exception: FATAL ERROR: 'Could not compile stylesheet'

Discussion in 'Java' started by vinnuavc, Jul 25, 2008.

  1. vinnuavc

    vinnuavc

    Joined:
    Jul 25, 2008
    Messages:
    1
    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" >
    <xsl:eek:utput 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.
     
    vinnuavc, Jul 25, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. z-man
    Replies:
    5
    Views:
    16,503
    z-man
    Apr 14, 2006
  2. =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

    Stylesheet referanse i stylesheet

    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=, Jul 3, 2004, in forum: XML
    Replies:
    3
    Views:
    586
    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
    Jul 4, 2004
  3. Steven An
    Replies:
    1
    Views:
    509
    Martin Honnen
    Nov 23, 2004
  4. David Blickstein
    Replies:
    3
    Views:
    1,046
    David Blickstein
    Aug 2, 2005
  5. David Blickstein
    Replies:
    14
    Views:
    6,362
    Harrie
    Oct 16, 2005
Loading...

Share This Page