http://forums.overclockers.co.uk/showthread.php?t=17572829

P

pauljwilliams

Im trying to use an xml file that has a reference within it to an xsd
file in a schemaLocation element.

The xsd file is in the same directory as the xml file, so i've simply
got:

Code:

<jxb:bindings schemaLocation="protocol.xsd" node="/xs:schema">



All works fine....until my source root is located in a path that has
spaces in it. In other words, if the two files reside in c:/code, for
example, all is well - the schemaLocation obviously gets internally
tranlated to c:/code/protocol.xsd.

But if i then copy the code into "c:/My Code", for example, the xml
becomes ill formed, as scemaLocation becomes "c:/My Code/protocol.xsd",
with the space causing a problem.

Any thoughts on how to get around this? Is there a way to specify a URL
encoded path that will be correct wherever i locate my source tree?
 
P

pauljwilliams

Apologies for the thread title BTW - I should check what I'm cutting
and pasting......
 
J

Joseph Kesselman

All works fine....until my source root is located in a path that has
spaces in it.

That's a problem with the specific tool (probably the specific parser)
you're using. Complain to their support channel.
 
R

Richard Tobin

<jxb:bindings schemaLocation="protocol.xsd" node="/xs:schema">
All works fine....until my source root is located in a path that has
spaces in it. In other words, if the two files reside in c:/code, for
example, all is well - the schemaLocation obviously gets internally
tranlated to c:/code/protocol.xsd.

If you were to treat the filename as a relative file: URL (which would
then get absolutised to file:///c:/code/protocol), you could use
%20 in the URL instead of spaces, e.g. file:///c:/My%20Code

Whether this works depends on whether your application can handle URLs
instead of filenames.
But if i then copy the code into "", for example, the xml
becomes ill formed, as scemaLocation becomes "c:/My Code/protocol.xsd",
with the space causing a problem.

It's not ill-formed XML, it's just something your application doesn't
like.

Incidentally, you would have a similar problem with the standard
xsi:schemaLocation attribute, which uses spaces as separators. But
the location in that case is a URL anyway, so you could use %20.

-- Richard
 
P

pauljwilliams

Thanks for your responses. Im using xjc, as part of Sun JAXB toolkit,
to generate Java classes based on an XML schema. I'll have a look for a
solution.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,828
Messages
2,569,736
Members
45,518
Latest member
vlonesshirt

Latest Threads

Top