Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How do you validate XML with Schema in Eclipse?(It seems Eclipse does not find the XSD file (but it gives no error).)
How do you validate XML with Schema in Eclipse? [message #530129] Wed, 28 April 2010 11:05 Go to next message
Eclipse UserFriend
I am trying to validate an XML file against it's XML Schema (*.xsd) in the Eclipse GUI , but I cannot get it to work.

When I right-click the xml-file and select "Validate", it gives me no validation error at all and says "Validation success" (or something along those lines). I am pretty sure it is not using the xsd-file at all Mad

For this example, I used the files here: http://www.w3schools.com/Schema/schema_example.asp

I created two files (shiporder.xml and shiporder.xsd) into a new project in Eclipse and messed up some tags in the xml file.

I have tried all types of permutations with schema location attributes and even using the Schema catalog, but nothing seems to work.

Here is the XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<XXX_shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
  <XXX_orderperson>John Smith</XXX_orderperson>
  <shipto>
    <name>Ola Nordmann</name>
    <address>Langgt 23</address>
    <city>4000 Stavanger</city>
    <country>Norway</country>
  </shipto>
  <item>
    <title>Empire Burlesque</title>
    <note>Special Edition</note>
    <quantity>1</quantity>
    <price>10.90</price>
  </item>
</XXX_shiporder>
(Note the messed up tags just to (supposedly) trigger the validation error)

Here is the XSD:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="shiporder">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="orderperson" type="xs:string"/>
      <xs:element name="shipto">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="address" type="xs:string"/>
            <xs:element name="city" type="xs:string"/>
            <xs:element name="country" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="item" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="title" type="xs:string"/>
            <xs:element name="note" type="xs:string" minOccurs="0"/>
            <xs:element name="quantity" type="xs:positiveInteger"/>
            <xs:element name="price" type="xs:decimal"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="orderid" type="xs:string" use="required"/>
  </xs:complexType>
</xs:element>
</xs:schema>


I would expect it to say "No definition for element XXX_xxxx" found or something like that. But no... SUCCESS. Yeah right!

This is with Eclipse Build id: 20100218-1602
Re: How do you validate XML with Schema in Eclipse? [message #530244 is a reply to message #530129] Thu, 29 April 2010 00:04 Go to previous messageGo to next message
Eclipse UserFriend
On 28/04/10 8:35 PM, martin.wickman@gmail.com wrote:
> I am trying to validate an XML file against it's XML Schema (*.xsd) in
> the Eclipse GUI , but I cannot get it to work.
> When I right-click the xml-file and select "Validate", it gives me no
> validation error at all and says "Validation success" (or something
> along those lines). I am pretty sure it is not using the xsd-file at all :x
> For this example, I used the files here:
> http://www.w3schools.com/Schema/schema_example.asp

I remember a preference pane that allows you to set the locations and
resolvers for the schemas. Anyways, this is not the right newsgroup.
Post this question in the WTP newsgroups. You might get better answers
there.

- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: How do you validate XML with Schema in Eclipse? [message #530255 is a reply to message #530244] Thu, 29 April 2010 02:47 Go to previous message
Eclipse UserFriend
Ok thanks, I'll post in the other group then.
Previous Topic:Compiling Source
Next Topic:Java Development User's Guide delivered with Eclipse 3.5.2 missing content.
Goto Forum:
  


Current Time: Fri Mar 21 04:35:38 EDT 2025

Powered by FUDForum. Page generated in 0.02030 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top