Solved

XML schema validation error

Posted on 2006-11-23
9
728 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

635 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