Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating internal links within xml documents

Status
Not open for further replies.

Tve

Programmer
May 22, 2000
166
FR
Ok here goes...

By the nature of my question, you will understand I am new to XML.

I an trying to create an configuration file in xml format instead og the plain old *.ini

I have projects, that should be associated to a specfic version of an application. So my idee was to define applications and then define projects, linking a specific project to a specific application

Below is a first brainstorming:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<applications>
<application name="MYEXE1" version="1.0">
<variable name="EXEDIR">C:\programs\myexe1</variable>
</application>
<application name="MYEXE2" version="2.0">
<variable name="EXEDIR">C:\programs\myexe2</variable>
</application>
</applications>
<projects>
<project name="Sample" code="SAM" number="01234">
<application>MYEXE1</application>
<variable name="VAR1">C:\programs\myexe1\lib</variable>
</project>
</projects>
</configuration>

So , I would link to point project "Sample" to application MYEXE1 and then be able to use variables from that project. If I use a environment analogy, end up with something similar to
<variable name="VAR1">%EXEDIR%\lib</variable>

I'm poking around on the net, but between XPOINTER, XPATH & XLINK I'm not sure what to use.

Any help would really be appreciated.





AD AUGUSTA PER ANGUSTA

Thierry
 
I'm a little confused... You spoke of specific versions of applications, then only use the application name to choose the application. What if two applications have the same name, but different versions? The many versions of Word for Windows come to mind... I might use a key number to differentiate between them so you're not storing the name and the version both in the project.
Code:
...
  <applications>
    <application name="MYEXE1" version="1.0">
      <variable name="EXEDIR">C:\programs\myexe1</variable>
    </application>
    <application name="MYEXE1" version="2.0">
      <variable name="EXEDIR">C:\programs\myexe2</variable>
    </application>
  </applications>
...

I wouldn't put any info contained in the application tag in the project tag.

Instead, I'd do something like:
Code:
    <project name="Sample" code="SAM" number="01234">
      <application>MYEXE1</application>
      <variable name="VAR1">lib</variable>
    </project>

You could then build the full path from the "EXEDIR" and "VAR1," which I assume is the gist of your problem.

What language are you using to scan your xml and pick out the particular bits you need?
 
Miros,

You did get problem right and I appreciate your feedback. The only thing that annoys me with your layout of entry "VAR1" is the fact that it forces the location always under MYEXE1.

Example: Assuming a directory located at \\myserver\myshare\mod. Of course, user could hardcode the path every time (as shown it red), but I beleive it would be a prefered method to declare it once (for example in blue), then recall it. In reality, my application will need about 10 -> 20 variables per project

Code:
/<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <applications>
    <application name="MYEXE1" version="1.0">
      <variable name="EXEDIR">C:\programs\myexe1</variable>
      [COLOR=blue]<variable name="customdir>\\myserver\myshare\mod</variable>[/color]
    </application>
    <application name="MYEXE2" version="2.0">
      <variable name="EXEDIR">C:\programs\myexe2</variable>
    </application>
  </applications>
  <projects>
    <project name="Sample" code="SAM" number="01234">
      <application>MYEXE1</application>
      <variable name="VAR1">[COLOR=#ff0000]\\myserver\myshare\mod[/color]\lib</variable>
      <variable name="VAR2">[COLOR=#ff0000]\\myserver\myshare\mod[/color]\abc</variable>
      <variable name="VAR3">[COLOR=#ff0000]\\myserver\myshare\mod[/color]\def</variable>
    </project>
</projects>
</configuration>

I was planning to do this in C#.


AD AUGUSTA PER ANGUSTA

Thierry
 
How about:
Code:
   <variable name="VAR1" base="EXEDIR">lib</variable>
   <variable name="VAR2" base="customdir">abc</variable>

So VAR1 would be C:\programs\myexe1\lib and VAR2 would be \\myserver\myshare\mod\abc

I'm not sure about C#, but Microsoft C/C++ has a full path function that you could use to put the pieces together.

 
Miros,

Not a bad idee.

I think I will need to create on the fly ID attributes (maybe with some kind of MD5SUM hash) that will be unique, then refer through the ID value as "customdir" might be a bit too simple.

Need to give it some thinking...




AD AUGUSTA PER ANGUSTA

Thierry
 
That works. I'd put a unique identifier on each application too, to prevent confusion between ApplicationX V1.0 and ApplicationX V2.0.

Might as well put 'em on projects too, while you're thinking about it. I'm sure you'll find a use for it sooner or later, and you don't want to be trying to remember how you did it 6 months from now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top