Solved

XML schema validation error

Posted on 2006-11-23
9
673 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
 
LVL 12

Expert Comment

by:jkmyoung
ID: 18004888
ignore my post (misinterpreted "last line"). Gertone has it.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now