I attached a xsl file, it'll let you re-create those warnings and errors.

>Guoliang,
>
>Thanks! I've added the fix to the code tree.
>
>I can't really tell you why you get the warnings you get.
>Are you able to send me the stylesheets you are compiling,
>or maybe a fraction of the stylesheet (enough to reproduce
>the warnings/errors).
>
>Morten
>
>
>Guoliang Cao wrote:
>
>>I got a NullPointerException when I compile a stylesheet file, so I made a
>>one-line change to this file. Hope it helps.
>>
>>xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralElement.java
>>
>>------- Line 285 ------------
>>- else if (qname.getNamespace().equals(XSLT_URI)) {
>>
>>+ else if (qname.getNamespace()!=null &&
>>qname.getNamespace().equals(XSLT_URI)) {
>>or
>>+ else if (XSLT_URI.equals(qname.getNamespace()) {
>>
>>BTW,  I got a lot of errors like this, Is there anything I can do to get rid
>>of them? Thanks.
>>
>>Warning:
>>  Attribute 'Action' outside of element.
>>  Attribute 'Service' outside of element.
>>  ......
>>Compile errors:
>>  Variable or parameter 'http://www.ispsoft.com:baseTime' is undefined.
>>  Variable or parameter 'http://www.ispsoft.com:Info' is undefined.
>>  Error parsing XPath expression '$Info'.
>>  Required attribute 'select' is missing.
>>  ......
>>

<?xml version="1.0"?>
<xsl:stylesheet xmlns:req='http://www.ispsoft.com'
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    exclude-result-prefixes="req xsl"
    version="1.0">

    <xsl:param name="requestType" select="'Normal'"/>
    <xsl:param name="baseTime" select="300"/>
    <xsl:variable name="myService" select="'Unknown'"/>
    <xsl:variable name="myAction" select="//req:service/@action"/>

    <xsl:template match="/req:request">
    <result>
        <xsl:variable name="_Timeout">300</xsl:variable>
        <xsl:call-template name="addTimeout">
            <xsl:with-param name="timeout" select="number($_Timeout)"/>
        </xsl:call-template>

        <xsl:attribute name="action">
            <xsl:value-of select="$myAction"/>
        </xsl:attribute>

        <xsl:apply-templates select="req:account"/>
    </result>
    </xsl:template>

    <xsl:template match="req:account">
        <xsl:apply-templates select="*"/>
    </xsl:template>

    <xsl:template name="addBaseTimeout">
        <xsl:call-template name="addTimeout">
            <xsl:with-param name="timeout" select="$baseTime"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="addTimeout">
        <xsl:param name="timeout"/>
        <xsl:variable name="hour" select="floor($timeout div 3600)"/>
        <xsl:variable name="minute" select="floor(($timeout - $hour * 3600) div 60)"/>
        <xsl:variable name="second" select="$timeout mod 60"/>
        <xsl:attribute name="Timeout">
            <xsl:if test="$hour > 0">
            <xsl:value-of select="concat('+',$hour,'h')"/>
            </xsl:if>
            <xsl:if test="$minute > 0">
            <xsl:value-of select="concat('+',$minute,'m')"/>
            </xsl:if>
            <xsl:if test="$second > 0">
            <xsl:value-of select="concat('+',$second,'s')"/>
            </xsl:if>
        </xsl:attribute>
    </xsl:template>

    <xsl:template match="req:service[@action='add']">
        <xsl:apply-templates mode="add" select="req:data"/>
    </xsl:template>

    <xsl:template mode="add" match="req:data">
    <xsl:variable name="_info">
        <username>a</username>
    </xsl:variable>
    <operation xmlns="http://www.ispsoft.com/service/Unknown";>
        <xsl:call-template name="addTimeout">
            <xsl:with-param name="timeout" select="$baseTime*(count(//req:data)-1)"/>
        </xsl:call-template>
        <xsl:value-of disable-output-escaping="yes" select="'&lt;![CDATA['"/>
        <xsl:apply-templates mode="addData" select="preceding-sibling::req:data|following-sibling::req:data">
            <xsl:with-param name="_info" select="$_info"/>
        </xsl:apply-templates>
        <xsl:value-of disable-output-escaping="yes" select="']]&gt;'"/>
    </operation>
    </xsl:template>

    <xsl:template mode="addData" match="req:data">
    <xsl:param name="_info"/>
    <addData>
        <xsl:copy-of select="$_info"/>
        <xsl:copy-of select="."/>
    </addData>
    </xsl:template>

    <xsl:template match="*|@*"/>

</xsl:stylesheet>

Reply via email to