• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSPs with xml using an xsd for transformation

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,
I have a problem with the following piece of code:

<%@ page language="java" isELIgnored="false"
contentType="text/xml; charset=utf-8" pageEncoding="UTF-8" session="true"%>
then a number of taglib import

then

<content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xxx.com/mpxml"
xsi:schemaLocation="http://xxx.com/mpxml ../xsd/mpxml.xsd"
schemaVersion="0.0.1f"
providerID="" id="" type="014001-GAME">

then some jsp code using xml tags defined in the xsd schema...

when viewing the page I get the following response:

the important part being simply

The XML file specified does not have an associated stylesheet. The document tree is shown below...

The question is: where do I need to put the xsd file in the web-app??? here you can see
xsi:schemaLocation="http://xxx.com/mpxml ../xsd/mpxml.xsd" so I put it in the directory before that where jsp is installed then xsd...
I also tried putting it und WEB-INF, under classes and many other attempts but with no luck

any suggestions?
thanks





<content xsi:schemaLocation="http://xxx.com/mpxml /mpxml.xsd" schemaVersion="0.0.1f" providerID="" id="" type="014001-GAME">

<Game>

<RelatedItems>

<Item>
<Title>
FIFA 11
</Title>

<Icon>
<Image href="display-image;jsessionid=CE1206571340E2F4E9BD91FFB76F1522?id=658127&deviceId=Mozilla%2f5.0+(SymbianOS%2f9.3%3b+Series60%2f3.2+NokiaE72-1%2f"/>
</Icon>

<ShortDescription>
blabla
</ShortDescription>
<Resource href="xxx.jsp;jsessionid=CE"/>
</Item>
</RelatedItems>
</Game>
</content>
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what's wrong with that? You send an XML document to the browser, and the browser displays it. What did you expect to happen?

And what's the purpose of the schema? You seem to think that the browser will use it to transform the XML in some way. Don't know where you got that idea.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please explain why you have an XML-based document in a JSP file.

 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question is what url is used to request the JSP?
The xsd will be looked up relative to that url.

That is not necessarily the same directory as the jsp, because the server may have forwarded/included the jsp.
Anything under WEB-INF is not directly accessible, and so is not the right place for this file if you need it downloaded to the client.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stefan Evans wrote:The question is what url is used to request the JSP?
The xsd will be looked up relative to that url.



Provided, that is, that the browser deems it necessary to validate the XML via its schema. I don't know whether browsers do that (and I'm not going to do a test to see if they do or not) but the normal behaviour of a browser when it receives HTML is that it doesn't much care whether it's well-formed or not. My guess would be that the browser does care whether an XML document is well-formed but not whether it is valid.

However anybody is free to demonstrate that my guess is wrong.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Random non-HTML elements in a HTML file are not considered XML elements by a HTML browser. Most browsers will simply display the content of the elements and will not care if the elements are well-formed or not.

Aside, the contents of the file described above and the reported error do not make any sense.

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect that

contentType="text/xml; charset=utf-8"


has something to do with the browser treating the document as XML.
 
reply
    Bookmark Topic Watch Topic
  • New Topic