-
Aug 29th, 2012, 12:43 PM
#1
Thread Starter
Frenzied Member
-
Aug 30th, 2012, 04:10 PM
#2
Addicted Member
Re: Accessing another table from within xsl:for-each
I would expect forum members to respond to your question quickly if they can read a piece of your code. Describing the problem alone is not enough to get a quick response.
-
Aug 30th, 2012, 04:20 PM
#3
Thread Starter
Frenzied Member
Re: Accessing another table from within xsl:for-each
Maybe this will help you understand better. Here's the snipped from the xsl file:
Code:
<table border='1' width='100%'>
<col width="15%" />
<col width="35%" />
<col width="15%" />
<col width="35%" />
<xsl:for-each select ='NewDataSet/FACILITY_INFO'>
<tr>
<td>Facility Number</td><td><xsl:value-of select='FACILITY_NUMBER'/></td>
<td>Layer Name</td><td><xsl:value-of select ='LAYER_ID'/></td>
</tr>
<tr>
<td>Description</td><td><xsl:value-of select='FACILITY_DESC'/></td>
<td>Facility ID</td><td><xsl:value-of select ='SDS_ID'/></td>
</tr>
</xsl:for-each>
</table>
The value that reads 'LAYER_ID' is what I need to use to reference the 'map_layer' table to pull out the 'layer_name'. The layer_name is what actually needs to be displayed in that table cell.
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Aug 31st, 2012, 07:13 AM
#4
Re: Accessing another table from within xsl:for-each
What does your xml look like?
-
Aug 31st, 2012, 07:54 AM
#5
Thread Starter
Frenzied Member
Re: Accessing another table from within xsl:for-each
Here's an example of the xml (the whole file is about 1.5 megs).
Code:
<NewDataSet>
<FACILITY_INFO>
<FACILITY_OID>384</FACILITY_OID>
<INSTALLATION_ID>1000</INSTALLATION_ID>
<LAYER_ID>13</LAYER_ID>
<SDS_ID>Bldg_AGM_1010</SDS_ID>
<RPU_ID />
<FACILITY_TIER>0</FACILITY_TIER>
<FACILITY_ACTIVE>true</FACILITY_ACTIVE>
<GLOC>none</GLOC>
<FACILITY_NUMBER>1010</FACILITY_NUMBER>
<FACILITY_DESC>Ammo Struc Inst</FACILITY_DESC>
<FACILITY_NAME>Ammo Struc Inst</FACILITY_NAME>
<LOCATION>here</LOCATION>
<TYPE_CODE>AGM</TYPE_CODE>
<SUB_CATEGORY_CODE>42142</SUB_CATEGORY_CODE>
<TYPE_CODE_JUSTIFICATION>RPI Import</TYPE_CODE_JUSTIFICATION>
<SUB_CAT_CODE_JUSTIFICATION>RPI Import</SUB_CAT_CODE_JUSTIFICATION>
<OWNER>NFESC</OWNER>
<USING_ORGANIZATION>ESS</USING_ORGANIZATION>
<DRAWING_NUMBER>123</DRAWING_NUMBER>
<LICENSE>456</LICENSE>
<FACILITY_COST>200000</FACILITY_COST>
<OCCUPANTS_MIL>2</OCCUPANTS_MIL>
<REQUIRES_SA>0</REQUIRES_SA>
<EVAL_ZONE_DISTANCE>873.070556640625</EVAL_ZONE_DISTANCE>
<SEARCH_ZONE_DISTANCE>3969</SEARCH_ZONE_DISTANCE>
<LAST_MODIFIED_DATE>2012-08-29T19:06:04.865-04:00</LAST_MODIFIED_DATE>
</FACILITY_INFO>
<MAP_LAYER>
<LAYER_ID>13</LAYER_ID>
<LAYER_NAME>Structure_Existing_Site</LAYER_NAME>
</MAP_LAYER>
</NewDataSet>
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Aug 31st, 2012, 09:36 AM
#6
Re: Accessing another table from within xsl:for-each
There are probably better ways to select the proper map layer node but this should work
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border='1' width='100%'>
<col width="15%" />
<col width="35%" />
<col width="15%" />
<col width="35%" />
<xsl:for-each select ='NewDataSet/FACILITY_INFO'>
<tr>
<td>Facility Number</td>
<td>
<xsl:value-of select='FACILITY_NUMBER'/>
</td>
<td>Layer Name</td>
<td>
<xsl:call-template name='maplayer'>
<xsl:with-param name='layerId'>
<xsl:value-of select ='LAYER_ID'/>
</xsl:with-param>
</xsl:call-template>
</td>
</tr>
<tr>
<td>Description</td>
<td>
<xsl:value-of select='FACILITY_DESC'/>
</td>
<td>Facility ID</td>
<td>
<xsl:value-of select ='SDS_ID'/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name='maplayer'>
<xsl:param name='layerId' />
<xsl:for-each select='//MAP_LAYER'>
<xsl:if test='LAYER_ID = $layerId'>
<xsl:value-of select ='LAYER_NAME' />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
-
Aug 31st, 2012, 09:43 AM
#7
Thread Starter
Frenzied Member
Re: Accessing another table from within xsl:for-each
Thanks! I was having trouble understanding how to pass parameters to templates. This should get me going in the right direction.
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|