XSLT 1.0-在xsi:type属性中指定了未知类型{}

时间:2019-01-17 23:25:54

标签: xslt xslt-1.0

感谢您抽出宝贵时间来查看我的问题。

我有一个看起来像是的xml消息-

 <soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
            <getFunctionResponse xmlns="urn:JadeWebServices/WebService/">
                <getResult xsi:type="WS_getResult">
                    <date>August 2018</date>
                    <ID>100964</ID>
                    <MoreContent>...</MoreContent>
                </getResult>
            </getFunctionResponse>
        </soap:Body>
    </soap:Envelope>

我正在尝试编写XSLT以使内容包装在getResult级别。 getResult标记名称会根据我调用的服务而更改,并且我需要根据名称执行不同的操作。

但是,它引用的xsi:type会使验证失败。当我删除xsi:type属性时,一切似乎都可以正常工作。我似乎无法绕过验证-有指针吗?

===================================== 编辑:基于评论

这是我到目前为止拥有的xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="name(soap:Envelope/soap:Body/*[1]) = 'getFunctionResponse'">
                <Payload>
                    <xsl:value-of select="soap:Envelope/soap:Body/getFunctionResponse/getResult"/>
                </Payload>
                <!--Do some success response related transformation-->
            </xsl:when>
            <xsl:otherwise>
                <Error>
                    <xsl:value-of select="soap:Envelope/soap:Body/getErrorResponse/getResult"/>
                </Error>
                <!--Do some Failure response related transformation-->
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

基本上,我想要实现的是基于soap:Body下直接的节点名称执行不同的转换逻辑。我可以收到5种不同的“类型”响应,但是为了简单起见,我将XSLT缩短为显示两种情况。

================================================ ==编辑:确切错误消息

java.lang.RuntimeException: Validation error: on line 4 column 76 of file:///c:/Users/Desktop/FULL_P~1.XML:
  XTTE1515: Unknown type {WS_getResult} specified in xsi:type attribute

    at com.exln.stylus.CSaxon8Driver.doProcessing(CSaxon8Driver.java:281)
    at com.exln.stylus.CProcessorDriver.process(CProcessorDriver.java:104)
Full_Payload.xml (4, 76)
Validation error: on line 4 column 76 of file:///c:/Users/Desktop/FULL_P~1.XML:   XTTE1515: Unknown type {WS_getResult} specified in xsi:type attribute 

0 个答案:

没有答案
相关问题