1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Realative URI's with spaces in the 'base' URI.....

Discussion in 'HTML, Graphics & Programming' started by Visage, 8 May 2006.

  1. Visage

    PermaBanned

    Joined: 13 Jan 2005

    Posts: 10,708

    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?

    Damn you Microsoft - who needs spaces in pathnames anyway?
     
  2. NathanE

    Capodecina

    Joined: 21 Oct 2002

    Posts: 18,022

    Location: London & Singapore

    "with the space causing a problem"? Can you expand on that a bit?

    It's definately not malformed XML to have a space in an attribute's value.

    It's hard to tell if this is a problem with your XML parser or file I/O method.
     
  3. Dj_Jestar

    Caporegime

    Joined: 18 Oct 2002

    Posts: 28,937

    Location: Back in East London

    urlencode() when writing the XML, then if need be urldecode() it after?
     
  4. Visage

    PermaBanned

    Joined: 13 Jan 2005

    Posts: 10,708

    To summarise, my xml document contains a URI relative to the documents location. If the location is at a location whose path contains no spaces, all is well. If it is at a path that includes spaces, the combination of 'absolute path including spaces' + 'relative path' casuses a problem that obviously is not there where the absolute path does not contain spaces.

    And the XML *is* malformed, as URI's cannot contain spaces.
     
  5. Visage

    PermaBanned

    Joined: 13 Jan 2005

    Posts: 10,708

    The XML is a configuration file, so concepts such as urlencoding arent much use. Cheers for the suggestion though.
     
  6. NathanE

    Capodecina

    Joined: 21 Oct 2002

    Posts: 18,022

    Location: London & Singapore

    Tried replacing the space with a %20?

    Edit: Oh just read post above and get the feeling telling your customers to type %20 instead of space isn't an ideal solution... :o
     
  7. Visage

    PermaBanned

    Joined: 13 Jan 2005

    Posts: 10,708

    Its not so much that - its more that any developer should be able to check the code out from source control, run the build, and it auto-generates lots of Java classes that represent the various xml entities. Obviously saying to developers 'only check code out to paths that dont have spaces in them' isnt the best.

    Ive done some looking around and it seems to be a bug in Sun's compiler - cheers for all your help.