元素“X:element”的前缀“X”未绑定

The prefix "X" for element "X:element" is not bound

提问人:Mansi Kale 提问时间:8/4/2023 最后编辑:kjhughesMansi Kale 更新时间:8/4/2023 访问量:64

问:

我收到此错误:

TypeError: The prefix "types" for element "types:ReceiveMessageResponse" is not bound.
at com.orchestral.rhapsody.modules.standard.filters.executescript.ExecuteScript.doProcessMessage(ExecuteScript.java:9)

使用此代码:

var next = output.append(input[0]);

var output = 
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/ xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ xmlns:tns=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 xmlns:types=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema'>
  <soap:Body soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
    <types:ReceiveMessageResponse>
      <ReceiveMessageResult href="#id1"/>
    </types:ReceiveMessageResponse>
    <types:GatewayAck id="id1" xsi:type="types:GatewayAck">
      <Code xsi:type="xsd:int">0</Code>
      <Detail xsi:type="xsd:string"/>
      <Source xsi:type="xsd:string"/>
      <UserMsg xsi:type="xsd:string"/>
    </types:GatewayAck>
  </soap:Body>
</soap:Envelope>
next.xml = output;

我尝试再创建一个标签,但没有成功。Types

JavaScript XML xml 命名空间 xsd 验证

评论

0赞 Lenka Šimečková 8/4/2023
这回答了你的问题吗?XML 架构验证错误“前缀未绑定”
1赞 Quentin 8/4/2023
错别字:语法不是——你没有足够的引号。您在问题中输入的代码的语法突出显示了这个问题,这就是为什么以绿色(属性值的一部分)而不是紫色(属性名称)显示的原因。attributeName='value' otherAttributeName='otherValue'attributeName='value otherAttributeName=otherValue'xmlns:types

答:

-1赞 kjhughes 8/4/2023 #1

命名空间前缀,例如必须声明。例如,添加以下声明:types

xmlns:types="http://example.com/types"

文档/消息中的任何公共祖先元素都会将所有带前缀的组件放在命名空间中。typeshttp://example.com/types


更新:根据 @Quentin 的鹰眼,声明就在那里,但许多命名空间 URL 没有正确用引号分隔:

改变

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/
               xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ 
               xmlns:tns=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 
               xmlns:types=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0
               xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
               xmlns:xsd=http://www.w3.org/2001/XMLSchema'>

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'
               xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
               xmlns:tns='http://www.show.scot.nhs.uk/sci/gateway/messaging2.0'
               xmlns:types='http://www.show.scot.nhs.uk/sci/gateway/messaging2.0'
               xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
               xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

注意正确分隔所有命名空间 URL。

评论

0赞 Quentin 8/4/2023
他们有。他们只是打错了字。
1赞 kjhughes 8/4/2023
@Quentin:Arg,你说得对。我在页面内搜索了它,但由于水平滚动而错过了它。答案已更新。谢谢。