aspose file tools*
The moose likes XML and Related Technologies and the fly likes Newbie XML schema validation question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Newbie XML schema validation question" Watch "Newbie XML schema validation question" New topic
Author

Newbie XML schema validation question

Steve Janvrin
Greenhorn

Joined: Feb 10, 2005
Posts: 9
Can someone tell me why the xsi:schemaLocation below is flagged as invalid by XMLspy, given that the entire file is copied line for line out of the Head First Servlets & JSP book, page 77? I've also copied this line (starting at http) into a browser and it get to the xsd fine.

Thanks,

Steve Janvrin.


<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>

<servlet-name>Ch3 Beer</servlet-name>

<servlet-class>com.example.web.BeerSelect</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Ch3 Beer</servlet-name>

<url-pattern>/SelectBeer.do</url-pattern>

</servlet-mapping>

</web-app>
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Originally posted by Steve Janvrin:
Can someone tell me why the xsi:schemaLocation below is flagged as invalid by XMLspy, given that the entire file is copied line for line out of the Head First Servlets & JSP book, page 77? I've also copied this line (starting at http) into a browser and it get to the xsd fine.

[snip]
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
[snip]


A schemalocation attribute is used to map a namespace to a schema document. hence, the value of this attribute is atleast two values seperated by whitespace. The first value is the namespace name (which is missing in this definition) and the second part is the URL to schema document location.

Based on that you should change the above schemalocation attribute to the following:

xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

Hope this helps.

- m

ps: Please consider reporting this error to the HeadFirst team. I am sure they would want to add this to their errata list, in case they have not come across this already.

ps.1.: If you are interested in learning XML Schema, I would highly recommend Definitive XmL schema by Priscilla Walmsley.
[ April 02, 2005: Message edited by: Madhav Lakkapragada ]

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Newbie XML schema validation question
 
Similar Threads
HFS: Problems with running SelectBeer.do servlet
Error on my first aplication
Head First question
Regarding to exercise in Head first Servlets & JSP
HTTP Status 404 Error