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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to transform one XML into format of another?

Status
Not open for further replies.

angelleye

Technical User
Feb 4, 2003
36
US
This all starts because I'm trying to use Adobe Illustrator 10 to dynamically create maps based on data from an access database. The data that is pulled is simply a number (avg. days in transit) that will go next to each state label on a map of the U.S.

In Illustrator I set all of the numbers to be dynamic and they're all set as a variable with the name of the state abbreviation. For example, the number next to the state of MO on my Illustrator document is set as a dynamic text variable with the name "MO".

Illustrator generates an XML file for me which is setup as a template. Right now it consists of one dataset called template and every variable is set to 0.0. The format of the XML file that illustrator puts out is as follows:

<v:sampleDataSet dataSetName=&quot;Template&quot;>
<AL>
<p>0.0</p>
</AL>
<AR>
<p>0.0</p>
</AR>
<AZ>
<p>0.0</p>
</AZ>
<CA>
<p>0.0</p>
</CA>
.
. and so on...

As you can see the dataset is named: dataSetName=&quot;Template&quot; and then a value is given for each variable. The variables are created in the XML file above this code like this:

<variables>
<variable varName=&quot;AL&quot; trait=&quot;textcontent&quot; category=&quot;&ns_flows;&quot;/>
<variable varName=&quot;AR&quot; trait=&quot;textcontent&quot; category=&quot;&ns_flows;&quot;/>
<variable varName=&quot;AZ&quot; trait=&quot;textcontent&quot; category=&quot;&ns_flows;&quot;/>


The data that I need to use is in Access. The table in Access is setup like this:

TERM STATE TERMOB
KCM AL 2.4
KCM AR 2.1
KCM CA 3.4
.
. and so on...

This shows that from Kansas City, MO (KCM) it takes an average of 2.4 days to get to Alabama (AL). Same goes for each record. From KCM to AR is 2.1 days, etc. So the first 55 rows of my table have a TERM of KCM. The next 55 rows would have a different TERM, etc.

The XML file exported from Access is setup like this:

<avgDaysOB>
<TERM>KCM</TERM>
<STATE>AL</STATE>
<TERMOB>2.4</TERMOB>
</avgDaysOB>
<avgDaysOB>
<TERM>KCM</TERM>
<STATE>AR</STATE>
<TERMOB>2.1</TERMOB>
</avgDaysOB>
<avgDaysOB>
<TERM>KCM</TERM>
<STATE>CA</STATE>
<TERMOB>3.4</TERMOB>
</avgDaysOB>

What I need is to take the data from the Access generated XML file and populate the Illustrator generated XML file. So for the example of KCM I would need a result XML to be formatted as such:

<v:sampleDataSet dataSetName=&quot;KCM&quot;>
<AL>
<p>2.4</p>
</AL>
<AR>
<p>2.1</p>
</AR>
<CA>
<p>3.4</p>
</CA>
.
. and so on...

I'm brand new to XML/XSL. I have read through all of the tutorials at w3schools.com and xml.com and many others, but I'm just not seeing the way I would have to setup my XSL sheet. I'm getting thrown off because while the TERM shows up 55 times in the Access generated XML file, I only want it to show up once in the Illustrator generated XML file as the name of the dataset. (ie. dataSetName=&quot;KCM&quot;) Then fill in the XML variables &quot;AL&quot; &quot;AR&quot; etc, with the numbers from the Access XML file.

I would be more than happy to provide the actual XML files that I'm working with so you can better see what I'm trying to do. I hope I've described what I'm doing well enough. Eventually, I need to have one XML file that contains datasets for every single TERM in my Access database. Then I can drop this back into Illustrator and select from a drop down list of all my dataSetName's and it will replace the numbers accordingly.

Any help on how I can go about doing this would be GREATLY appreciated. This will literally save me weeks of time when I get big orders.

Thanks!

Drew Angell


 
Hi friends,
I have some doubts.
In Visio (Microsoft's) Software, i want to know how the are storing the files that is in what way they are storing the project files and what concept behind that. That is what kind of UML concept they were used while creating the visio software.

Please mail me any tips behind that.
My e-mail id is dinesh_spp@hotmail.com

thanks.
bye,
m.dinesh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top