I'm working on XSLT for an XML file that has a bunch of values for a particular "ID". I need to run this through my converter, which outputs those values to a database, but all I have to identify the values is the ID. What I need to identify the values is the description which is in another file. This description should become the output XML's element name, rather than the ID, which is what I'm using now. The same counter IDs are in the separate file and contain the description I need to use as the element name. Here is an example, just in case I'm confusing you.
<!-- XML with values -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<series>
<sampleInfo>
<timestamp>1/1/2013 12:00 AM</timestamp>
<timestamp>1/2/2013 12:00 AM</timestamp>
<timestamp>1/3/2013 12:00 AM</timestamp>
<timestamp>1/4/2013 12:00 AM</timestamp>
</sampleInfo>
<value>
<series>
<value>
<int>0</int>
<int>9</int>
<int>0</int>
<int>9</int>
</value>
<id>
<counterID>100</counterID>
.
.
</id>
</series>
<series>
<value>
<int>3</int>
<int>6</int>
<int>3</int>
<int>6</int>
</value>
<id>
<counterID>120</counterID>
.
.
.
</id>
</series>
</value>
</series>
</root>
Basically, each timestamp has its own value for each of the corresponding counterIDs. Now here is a sample of the other XML file, the one I'm grabbing information from.
<!-- XML with descriptions -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<counterInfo>
<id>100</id>
<description>Blah</description>
</counterInfo>
<counterInfo>
<id>120</id>
<description>Derp</description>
</counterInfo>
</root>
So once I convert the original document (the one with the values), my output (flat) XML looks sorta like:
<root>
<element>
<timestamp>1/1/2013 12:00 AM</timestamp>
<C100>0</C100> <!-- Since XML doesn't allow numeric element fields, I add a C -->
<C120>3</C120>
</element>
<element>
<timestamp>1/2/2013 12:00 AM</timestamp>
<C100>9</C100>
<C120>6</C120>
</element>
<element>
<timestamp>1/3/2013 12:00 AM</timestamp>
<C100>0</C100>
<C120>3</C120>
</element>
<element>
<timestamp>1/4/2013 12:00 AM</timestamp>
<C100>9</C100>
<C120>6</C120>
</element>
</root>
What I then need to do is transform the already flat XML, like above, to show this instead.
<root>
<element>
<timestamp>1/1/2013 12:00 AM</timestamp>
<Blah>0</Blah>
<Derp>3</Derp>
</element>
<element>
<timestamp>1/2/2013 12:00 AM</timestamp>
<Blah>9</Blah>
<Derp>6</Derp>
</element>
<element>
<timestamp>1/3/2013 12:00 AM</timestamp>
<Blah>0</Blah>
<Derp>3</Derp>
</element>
<element>
<timestamp>1/4/2013 12:00 AM</timestamp>
<Blah>9</Blah>
<Derp>6</Derp>
</element>
</root>
I did a bit of searching, and most results suggest parameters, but the way I convert these may make this a little difficult. I have a converter in Java that's part of a large repository of converters, and it pulls the XSLT from that repository to transform files passed to it. In the converter, we extract files that need to be converted from archives and then do them each individually. So my problem is... how do I give the XSLT that filename when the converter gets to that file in the list, and how do I pass that filename to the XSLT?
So am I over-complicating things? Is there any easy way of accomplishing this? Let me know if I need to clear anything up.