0

I need to validate an xml string against an xsd model. I cannot find out what is wrong. Here is the xsd model.

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace = "http://www.ludd21.com/KPartModel"
xmlns = "http://www.ludd21.com/KPartModel"
elementFormDefault="qualified"
>
<xs:element  name ="verticalBorder">
      <xs:complexType>
        <xs:sequence>
          <xs:element name = "segment" type= "vertical-line"/>
        </xs:sequence>
      </xs:complexType>
      </xs:element >

<xs:complexType name = "vertical-line">
      <xs:attribute name= "start" type = "point" use = "required"/>
      <xs:attribute name= "end" type = "point" use = "required"/>
      <!--startX = endX!-->
      <xs:assert id = "test-vertical-line" test = "(@start[0] = @end[0])"/>
    </xs:complexType>
<xs:simpleType name = "point">
        <xs:restriction>
          <xs:simpleType>
            <xs:list itemType = "decimal4digits"/>
          </xs:simpleType>
          <xs:length value = "2"/>
        </xs:restriction>
    </xs:simpleType>
       
    <xs:simpleType name ="decimal4digits">
        <xs:restriction base = "xs:decimal">
            <xs:fractionDigits value="4"/>
        </xs:restriction>
    </xs:simpleType>
  </xs:schema>

and here is the xml. I get an error on the XPath assertion. It looks like the O index does not exist

<ns0:kPartModel xmlns:ns0="http://www.ludd21.com/KPartModel"> 
 <ns0:segment start="17.7319 0.0000" end="17.7319 -11.8291" />
</ns0:kPartModel>
piscvau
  • 33
  • 1
  • 3
  • Lots of issues here. I suggest that you first get your XSD in order without the `assert`. Then, make sure you're using a processor that supports XSD 1.1; `assert` won't work in XSD 1.0. Finally, learn more about XPath as `@start[0]` is not doing what you think it's doing. – kjhughes Feb 03 '23 at 15:58

0 Answers0