Announcement Announcement Module
No announcement yet.
AIR or swf2exe application, how to use IMPORT element? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • AIR or swf2exe application, how to use IMPORT element?

    i am using Spring AS for apps that are not just in the web-browser but on the desktop (both AIR and within swf2exe apps like MDM Zinc). I need to load a config XML file that does "imports" of other relative files to the main config file. I am having issues where the import element does not seem to work.

    Anyways, I've been constructing the context as follows.

    var ctx:XMLApplicationContext = new XMLApplicationContext();

    Contents of myconfig.xml

    <object id="myObject" class="my.package.MyObject"/>
    <import file="myOtherSubConfig.xml"/>

    Contents of myOtherSubConfig.xml which lives in the same directory as myconfig.xml above.

    <object id="myOtherObject" class="my.package.MyOtherObject"/>

    After booting up Spring AS, I can successfully retrieve "myObject" however "myOtherObject" is null. I have also tried specifying the following with no success either.
    <import file="file:///someDir/someDir2/myOtherSubConfig.xml"/>
    The top of my config XML had this:
    <objects xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    When the above header is in the objects tag the e4x "xml.descendants("import")" call within XMLObjectFactory._addImportLocationsIfAny() yields zero results. When I remove all the xmlns/schema info OUT of the <objects> tag. The xml.descendants("import") works fine. I took this example "objects" element declaration right out of the the first annotation within the Spring/Prana XSD file @

    Is this an E4X bug or something else?
    Last edited by borfnorton; Jan 22nd, 2009, 06:55 PM.

  • #2

    I just looked into this and it seems that the unit tests were not correctly checking this. The import failed, but the tests passed since we checked in a wrong way.

    The E4X query doesn't seem to work and I don't know why actually, so I have fixed this with a workaround. The fix and the updated tests are all committed to SVN. If you need a new build, just run "build.bat release" from the "ant" folder and you'll get a new build in the "antbuild" folder.

    Thanks for reporting!



    • #3

      a) the patch above fixes the issue. When my objects element has all the schema xsi info in it, now the imports are pulled in properly thanks. I think this is an e4x bug because in my testing, e4x would fail to retrieve any descendants/children by name when that xsi/schema info was in the objects element.

      c) another note/suggestion. When calling addConfigLocation() with a "path to xml file" it is not apparent that the call requires you to pass a valid URI path to a file/location (file://) because internally it uses UrlRequest, maybe change the docs on this or better, check for a passed "absolute path" and if it appears to be a local path to something on disk, automatically URI prefix it for the caller.
      Last edited by borfnorton; Jan 23rd, 2009, 11:31 AM.