Solved

XML schema validation error

Posted on 2006-11-23
9
688 Views
Last Modified: 2013-11-19
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
0
Comment
Question by:john8932
  • 4
  • 3
  • 2
9 Comments
 

Author Comment

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

Will probably have more errors later though.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 18004879
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!
0
 
LVL 12

Expert Comment

by:jkmyoung
ID: 18004880
I suggest adding
‹/xs:schema>
to the end of your file.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 12

Expert Comment

by:jkmyoung
ID: 18004888
ignore my post (misinterpreted "last line"). Gertone has it.
0
 

Author Comment

by:john8932
ID: 18004939
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

 
0
 

Author Comment

by:john8932
ID: 18004981
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
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 18005065
([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 ]*
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 18005071
> 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
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 125 total points
ID: 18005110
john8932,

note there is a space after the Z in my character class
 [a-zA-Z ]*

Geert
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question