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

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

    Hi,
    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.

    Code:
    var ctx:XMLApplicationContext = new XMLApplicationContext();
    ctx.addConfigLocation("file:///someDir/someDir2/myconfig.xml");
    ctx.load();


    Contents of myconfig.xml

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

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

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

    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.
    Code:
    <import file="file:///someDir/someDir2/myOtherSubConfig.xml"/>
    UPDATE:
    The top of my config XML had this:
    Code:
    <objects xmlns="http://www.pranaframework.org/objects" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pranaframework.org/objects http://www.pranaframework.org/schema/objects/spring-actionscript-objects.xsd">
    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 @ http://www.pranaframework.org/schema...pt-objects.xsd

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

  • #2
    Hi,

    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!

    regards,
    Christophe

    Comment


    • #3
      Chris,

      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, 10:31 AM.

      Comment

      Working...
      X