Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie XML schema validation question

 
Steve Janvrin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic