1

我从第三方供应商处收到以下 XML 消息。我无法控制传入的消息。我已将其缩减为最简单的形式,同时仍会产生错误。XML 消息:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header/>
    <soap:Body/>
</soap:Envelope>

我正在使用的 xsl 文件是:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:import-schema
        namespace="http://schemas.xmlsoap.org/soap/envelope/"
        schema-location="http://schemas.xmlsoap.org/soap/envelope/" />

    <xsl:template match="/">
        <xsl:text>Help</xsl:text>
    </xsl:template>

</xsl:stylesheet>

当我尝试使用用于 XSLT 2.0 的 IBM 处理器并选中“启用验证”框在 Eclipse 中运行转换时,在 xml 验证期间出现以下错误:

cvc-elt.1.a: Cannot find the declaration of element 'soap:Envelope'

即使我无法控制传入的消息,是否有任何方法可以进行此通过验证?如果我确实可以控制传入的消息,我会这样做,它会很好地工作:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/
                            http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header/>
    <soap:Body/>
</soap:Envelope>
4

1 回答 1

1

I don't know the details of the IBM XSLT 2.0 processor, but it seems clear from the symptoms that the validation phase on the source document doesn't have access to the schema declared using xsl:import-schema in the stylesheet; you will have to look in the documentation for some other way of telling the validation process where to find a suitable schema.

于 2013-03-14T10:12:11.383 回答