开发者

How to create a valid schema in a WSDL that restrict to <|<=|>|>=

开发者 https://www.devze.com 2022-12-31 20:18 出处:网络
This is what I have in my schema section of my WSDL to specify the field has to be comparison operators

This is what I have in my schema section of my WSDL to specify the field has to be comparison operators

                <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:pattern value="&lt;|&gt;|&lt;=|&gt开发者_运维技巧;=|="/>
                        </xsd:restriction>
                </xsd:simpleType>

SoapUI complains about this part of the WSDL, I tried to set the value to something with non special characters and the WSDL is valid. So I tried to replace that whole long string to be value=">gt;" and it valid but value="<lt;" is not valid, and value=">" is also not valid. My question is, why does the WSDL validation need > to be double escaped?

The main question is, how to provide a valid less than side within the pattern value.


This might actually be a bug in SoapUI. I tried using the following schema and XML with Apache Xalan (in Java):

Schema:

<schema xmlns="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.foo.com/"
  xmlns:tns="http://www.foo.com/"
  elementFormDefault="qualified">

  <element name="foo">
    <simpleType>
      <restriction base="string">
        <pattern value="&lt;|&gt;|&lt;=|&gt;=|="/>
      </restriction>
    </simpleType>
  </element>

</schema>

Sample XML:

<foo xmlns='http://www.foo.com/'>&gt;</foo>

and it validates fine. When I try this instead:

<foo xmlns='http://www.foo.com/'>abc</foo>

I get the following error, as expected: cvc-pattern-valid: Value 'abc' is not facet-valid with respect to pattern '<|>|<=|>=|=' for type '#AnonType_foo'.

My recommendation is to try using an enum instead. For example:

<simpleType>
  <restriction base="string">
    <enumeration value="&lt;" />
    <enumeration value="&gt;" />
    <enumeration value="&lt;=" />
    <enumeration value="&gt;=" />
    <enumeration value="=" />
  </restriction>
</simpleType>

And see if SoapUI likes this better. Hope this helps!


I think I solved my own problem, why would you define in your schema that one of the allowable value is

                        <xsd:restriction base="xsd:string">
                            <xsd:pattern value="=|&amp;gt;|&amp;gt;=|&amp;lt;|&amp;lt;=|&amp;lt;&amp;gt;|[Ii][Nn]|[Nn][Oo][Tt] [Ii][Nn]|[Ll][Ii][Kk][Ee]"/>
                        </xsd:restriction>
0

精彩评论

暂无评论...
验证码 换一张
取 消