aspose file tools*
The moose likes XML and Related Technologies and the fly likes JSPs with xml using an xsd for transformation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JSPs with xml using an xsd for transformation" Watch "JSPs with xml using an xsd for transformation" New topic
Author

JSPs with xml using an xsd for transformation

Luca Zitto
Greenhorn

Joined: Feb 08, 2010
Posts: 23
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>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Please explain why you have an XML-based document in a JSP file.

Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
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
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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

Joined: Apr 16, 2008
Posts: 2187
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
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

I suspect that
contentType="text/xml; charset=utf-8"

has something to do with the browser treating the document as XML.
 
 
subject: JSPs with xml using an xsd for transformation