Link to home
Start Free TrialLog in
Avatar of john8932
john8932

asked on

XML schema validation error

Hello,

I am new to XML and schemas.

I have an XML file with elements I want to restrict i.e. the element "element4" should be an integer between 0 and 400 inclusive.

I have tried to change the XSD to do this and it gives a validation error referring to this line(s):

  <xs:element name="element4"/>
    <xs:simpletype>
      <xs:restriction base="xs:integer">
        <xs:minInclusive value="0"/>
        <xs:maxInclusive value="400"/>
      </xs:restriction>
    </xs:simpletype>  
  </xs:element>

It refers to the last line and says this:

XML Schema Validator
Well Formed: INVALID
Schema Validation: INCOMPLETE

The following errors were found:
The element type "xs:schema" must be terminated by the matching end-tag "‹/xs:schema>".

Thank you
John
Avatar of john8932
john8932

ASKER

Oops I just realised the / should not be in:
<xs:element name="element4"/>

Will probably have more errors later though.
Avatar of Gertone (Geert Bormans)
Hi john8932,
> <xs:element name="element4"/>

you are closing the xs:element too soon
this line should say
<xs:element name="element4"> (the / has to leave)

the wellformedness parser then correctly sys you have an open xs:schema element
when you try to close the xs:element again (whilst it was already closed)

note you also have a case error in simpleType

Cheers!
I suggest adding
‹/xs:schema>
to the end of your file.
ignore my post (misinterpreted "last line"). Gertone has it.
Thanks for the replies.

This is my next error:
XML Schema Validator

Well Formed: VALID
Schema Validation: INVALID

The following errors were found:
Validation       9, 73       cvc-pattern-valid: Value 'his Soho implementation friends defining worn' is not facet-valid with respect to pattern '([a-z][A-Z])*' for type 'null'.

Validation       9, 73       cvc-type.3.1.3: The value 'his Soho implementation friends defining worn' of element 'element3' is not valid.

Validation       27, 55       cvc-pattern-valid: Value 'beauty Mediterranean and away' is not facet-valid with respect to pattern '([a-z][A-Z])*' for type 'null'.

Validation       27, 55       cvc-type.3.1.3: The value 'beauty Mediterranean and away' of element 'element3' is not valid.


Im trying to make it so that the element in my XML file is only uppercase and lowercase and spaces are allowed.

This is the code I use:

<xs:element name="element3">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="([a-z][A-Z])*"/>
      </xs:restriction>
    </xs:simpleType>  
  </xs:element>  

Cheers

 
Oh by the way the random text in the elements was generated by my teacher and not me therefore blame him for randomness.

Also a side question is:

Can you generate XML from XSD? Like it would just produce random XML from XSD - what program would do this?

Thank you
John
([a-z][A-Z])* is a pattern that expects an XML string like this "aAbBfTgY", plus the spaces are not allowed
you should use [a-zA-Z ]*
> Can you generate XML from XSD? Like it would just produce random XML from XSD - what program would do this?

any XML IDE would give you that functionality
download www.oxygenxml.com or www.stylusstudio.com for test

There are some commandline tools that do that as well,
but it is important that you can control some things like
- what to do with choices
- what to do with optional elements and maxOccur="unbounded"
- etc...

cheers
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial