Select to view content in your preferred language

Get contents of MXD without connecting to SDE

540
3
04-08-2010 04:58 PM
KevinNetherton
Emerging Contributor
I am trying to get a list of the layers in a bunch of mxds that reference SDE data sources.  The catch is I don't want to have to login to the SDE server to get this information.  I just want to identify whether a mxd contains layers that reference SDE feature classes.

Using java I have come up with:

String mxdPath = "mymxd.mxd";
MapDocument mapDocument = new MapDocument();
mapDocument.open(mxdPath,"");
int mapCnt = mapDocument.getMapCount();
int mapIncr = 0;
while (mapIncr < mapCnt ) {
    Map map = (Map)mapDocument.getMap(mapIncr);
    etc....
}


Then from here I get the layers from the map etc.  The problem is I get a pop asking for SDE credentials when I call the getMap method.

Anyone know of a way around this???
0 Kudos
3 Replies
RichardWatson
Deactivated User
I am sure that this is not what you are looking for but mxd files are OLE structured storage.  That means that you can read the information from the underlying storages and streams.  There are several GUI utlities which show the contents including one that comes with Visual Studio 6, one that you can download from Microsoft, and I believe that ESRI provides one as well.  The problem that you will have is that you have to reverse engineer how to read the information you seek.

At the recent Developer Summit, I asked ESRI about utilities they might have to read/parse mxd files and was told that they did not provide this.  My problem was that I wanted to read an mxd in order to read information previously persisted by an extension.

Good luck!
0 Kudos
KevinNetherton
Emerging Contributor
I knew there must be a way to do this.

Turns out if you open your document using a mapserver object instead of a mapdocument object, you can scan the contents of the mxd file without having to connect to the data sources.  The code demonstrating what this looks like in a simple example is attached.
0 Kudos
RichardWatson
Deactivated User
I tried to open your zip file w/o success.  Can you repost it or better yet email it to me?

Thanks,

rwatson@telcordia.com
0 Kudos