Solved

XML schema validation error

Posted on 2006-11-23
9
713 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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 …

751 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