为什么会出现以下异常“非静态Java函数的第一个参数”?

问题描述 投票:0回答:3

我收到此异常:

致命错误:'非静态Java函数***的第一个参数不是有效的对象引用。'

当我尝试使用xml-maven-plugin转换XML文档时会发生这种情况。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>xml-maven-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <goals>
                <goal>transform</goal>
           </goals>
        </execution>
    </executions>
    <configuration>
        <transformationSets>
            <transformationSet>
                <dir>target/generated/wsdl</dir>
                <stylesheet>src/test/resources/transform/my-transformation.xsl</stylesheet> 
                <includes>   
                    <include>**/*.xsd</include>
                </includes>
                <outputDir>target/generated/wsdl</outputDir>
            </transformationSet>
         </transformationSets>
    </configuration>
</plugin>

错误消息

 [INFO] --- xml-maven-plugin:1.0:transform (transform--xsd) @ my-pom ---
 Warning:  org.apache.xerces.parsers.SAXParser: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.
 Warning:  org.apache.xerces.parsers.SAXParser: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
 Warning:  org.apache.xerces.parsers.SAXParser: Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized.
 ERROR:  'The first argument to the non-static Java function 'isTheRightElement' is not a valid object reference.'
 FATAL ERROR:  'The first argument to the non-static Java function 'isTheRightElement' is not a valid object reference.'

XSL转换文件的内容

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://mysite/mycreate" xmlns:xalan="http://xml.apache.org/xslt" xmlns:mytag="http://andreas/ps-transformations" version="2.0">
<xsl:strip-space elements="*"/> 
<xsl:output method="xml" indent="yes" xalan:indent-amount="4"/>

<xsl:variable name="myAnnotations" select="document('element-list.xml')"/>

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="xs:element">     
    <xsl:param name="myValue" select="normalize-space(mytag:isTheRightElement(@class))"/>

    <xsl:choose>
        <xsl:when test="$myValue=''">
            <xsl:copy> 
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:when>
        <xsl:otherwise>
             <xsl:copy> 
                <xsl:apply-templates select="@*|node()"/>
                <xsl:element name="xs:annotation"> 
                    <xsl:element name="xs:documentation">
                        <xsl:value-of select="$elementValue"/>
                    </xsl:element>
                </xsl:element> 
            </xsl:copy>
        </xsl:otherwise>
      </xsl:choose>
</xsl:template> 

<xsl:function name="myTag:isTheRightElement">
    <xsl:param name="class"/>  
       <xsl:for-each select="$myAnnotations/elementList/element">
            <xsl:if test="lower-case(@class) = 'something'">
               <xsl:value-of select="text()"/>           
            </xsl:if>
         </xsl:for-each> 
    </xsl:function>    
</xsl:stylesheet>
xslt xml-parsing xslt-2.0
3个回答
0
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.