L
L
lilota2014-06-22 12:51:31
XSD
lilota, 2014-06-22 12:51:31

How to fix xml schema error?


it is not possible to describe an attribute that is a hexadecimal number, always starts with W and contains numbers from 0-9 and the letters a,b,c,d,e,f and does not start with 0
here is the xml itself

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pi314, 2014-06-22
@lilota

In short, something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:ns="http://meinMuseum.de" targetNamespace="http://meinMuseum.de"
  elementFormDefault="qualified" attributeFormDefault="unqualified"
  xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1">

  <xs:simpleType name="RestrictedString4to20">
    <xs:restriction base="xs:string">
      <xs:minLength value="4" />
      <xs:maxLength value="20" />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Autor">
    <xs:simpleContent>
      <xs:extension base="ns:RestrictedString4to20">
        <xs:attribute name="id" type="xs:positiveInteger" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:simpleType name="EvenInteger">
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="0" />
      <xs:assertion test="$value mod 2 = 0" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="HexBinary">
    <xs:restriction base="xs:string">
      <xs:pattern value="W[1-9a-f]+[0-9a-f]*" />
      <xs:length value="10" />
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="museum">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="werk" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="type">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:enumeration value="Buch" />
                    <xs:enumeration value="Multimedia" />
                    <xs:enumeration value="Zeitung" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>

              <xs:element name="autor" maxOccurs="unbounded"
                minOccurs="0" type="ns:Autor" />

              <xs:element name="jahre" maxOccurs="unbounded">
                <xs:simpleType>
                  <xs:union>
                    <xs:simpleType>
                      <xs:restriction base="xs:integer">
                        <xs:minInclusive value="-100" />
                        <xs:maxInclusive value="2012" />
                      </xs:restriction>
                    </xs:simpleType>
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:enumeration value="AB" />
                        <xs:enumeration value="BC" />
                        <xs:enumeration value="after2000" />
                        <xs:enumeration value="unknown" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:union>
                </xs:simpleType>
              </xs:element>

              <xs:element name="referenz" maxOccurs="unbounded"
                minOccurs="0">
                <xs:complexType>
                  <xs:attribute name="refid" type="ns:HexBinary"
                    use="required" />
                </xs:complexType>
              </xs:element>

              <xs:element name="bearbeiter" type="ns:EvenInteger" />
            </xs:sequence>

            <xs:attribute name="bezeichner" type="ns:HexBinary"
              use="required" />
            <xs:attribute name="erfassung" use="optional" type="xs:date" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

PS I hope it's not in Berlin TU that they ask this :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question