Menu

#4 parseXlink and windows paths with spaces

version_Beta_x.x.x
open
5
2012-09-14
2002-12-18
No

This bug report is based upon jATLASv2.0b4

parseXlink cannot handle windows paths which include spaces.

Exception in thread "main" java.lang.IllegalArgumentException: file:/C:/a_projects/ATLAS/ATLAS
AWB/data/test.aif#Anc3 is not a valid XLink.
at gov.nist.atlas.ref.RefResolverChooser.parseXLink(Unknown Source)
at gov.nist.atlas.ref.RefResolverChooser.chooseRefResolverFor(Unknown Source)
at gov.nist.atlas.ref.ATLASRef.<init>(Unknown Source)
at gov.nist.atlas.ref.ATLASRef.createATLASRef(Unknown Source)
at gov.nist.atlas.ref.ATLASRef.createAnchorRef(Unknown Source)
at gov.nist.atlas.ref.ATLASRef.createAnchorRef(Unknown Source)
at org.mitre.jawb.atlas.JAWB.newTag(JAWB.java:192)
at org.mitre.jawb.atlas.JAWB.newTag(JAWB.java:164)
at org.mitre.jawb.atlas.PhraseTaggingTest.main(PhraseTaggingTest.java:110)

the URL generated from the string "file:/C:/a_projects/ATLAS/ATLAS AWB/data/test.aif" works to create
the .aif file using AIFXMLExport:

  AIFXMLExport export = new AIFXMLExport(aifURL);
  export.save(theCorpus);

At one point Christophe suggested I change the string to "file:///c:/...." but this still got converted to
"file:/C:/..." when I converted it to a URL to pass into the constructor for AIFXMLExport.

The failure occurs when trying to create new AnchorRef's for the corpus after loading it in from the AIF file
using CorporaManager.loadCorpus (with the same URL as above)

Discussion

  • Christophe Laprun

    Logged In: YES
    user_id=27100

    Will investigate the issue.

     
  • Robyn Kozierok

    Robyn Kozierok - 2002-12-18

    Logged In: YES
    user_id=671742

    I believe the issue is actually that new URL(urlString) does not ensure that the URL it creates is legal in terms of
    characters that need to be escaped. So this may not really be an ATLAS bug, except in its willingness to create
    the file with the illegal URL but then can't work with it like that.

    URL aifURL = new File (aifString).toURI().toURL();

    seems to do the right thing, convoluted though it is....

     
  • Christophe Laprun

    Logged In: YES
    user_id=27100

    I looked at existing bugs in Java and found a reference to
    similar problems. See bug ID #4466485. Seems like using URIs
    is the way to go. I'll try to fix this in jATLAS ASAP.

     
  • Robyn Kozierok

    Robyn Kozierok - 2002-12-18

    Logged In: YES
    user_id=671742

    oops, I spoke too soon -- that creates a URL/URI with the space changed to %20, but that URL does not work for
    creating the file in AIFXMLExport.... I get a FileNotFoundException

    aifString is C:/a_projects/ATLAS/ATLAS AWB/data/test.aif
    java.io.FileNotFoundException: C:\a_projects\ATLAS\ATLAS%20AWB\data\test.aif (The system cannot find the
    path specified)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:176)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
    at gov.nist.atlas.io.xml.XMLExport.save(Unknown Source)
    at org.mitre.jawb.atlas.JAWB.saveAsAIF(JAWB.java:257)
    at org.mitre.jawb.atlas.PhraseTaggingTest.main(PhraseTaggingTest.java:93)
    Exception in thread "main" java.lang.NullPointerException
    at gov.nist.atlas.io.xml.XMLExport.save(Unknown Source)
    at org.mitre.jawb.atlas.JAWB.saveAsAIF(JAWB.java:257)
    at org.mitre.jawb.atlas.PhraseTaggingTest.main(PhraseTaggingTest.java:93)

    So, it seems that the URL doesn't work with the spaces escaped, because in XMLExport, you do:
    new File(url.getFile())
    but getFile doesn't turn the escaped spaces back into spaces

    So.... if we send a URL with the spaces escaped, XMLExport won't work
    and if we send a URL without the spaces escaped, parseXlink won't work

     
  • Christophe Laprun

    Logged In: YES
    user_id=27100

    I suspected as much from what was said in the discussion
    with respect to Java's bug ID #4466485. I will need some
    time to sort this out.

     

Log in to post a comment.