1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
---|
2 | |
---|
3 | <xsl:stylesheet version="3.0" |
---|
4 | xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" |
---|
5 | xmlns:xs ="http://www.w3.org/2001/XMLSchema" |
---|
6 | xmlns:ibis="http://www.ibisph.org" |
---|
7 | |
---|
8 | exclude-result-prefixes="ibis xs xsl" |
---|
9 | > |
---|
10 | |
---|
11 | <ibis:doc> |
---|
12 | <name>xml/ComparisonValues</name> |
---|
13 | <summary>Provides XML element creation used community type pages.</summary> |
---|
14 | <description> |
---|
15 | The bulk of this code is to produce the comparison XML structure. |
---|
16 | NOTE: This code is business rules and logic and thus really should |
---|
17 | be put into java code. However, doing so makes it more difficult |
---|
18 | for Lois/Paul to maintain or for other adopters to modify the rules |
---|
19 | so it was coded in XSLT. |
---|
20 | </description> |
---|
21 | </ibis:doc> |
---|
22 | |
---|
23 | |
---|
24 | <xsl:param name="ComparisonValues.defaultNumberOfGroups" select="3"/> |
---|
25 | |
---|
26 | <xsl:param name="ComparisonValues.stateDimensionName" select="'State'"/> |
---|
27 | <xsl:param name="ComparisonValues.stateDimensionValue" select="'NM'"/> |
---|
28 | <xsl:param name="ComparisonValues.usDimensionName" select="'Country'"/> |
---|
29 | <xsl:param name="ComparisonValues.usDimensionValue" select="'US'"/> |
---|
30 | <xsl:param name="ComparisonValues.lowerLimitAncillaryValueName" select="'LowerConfidenceLimit'"/> |
---|
31 | <xsl:param name="ComparisonValues.upperLimitAncillaryValueName" select="'UpperConfidenceLimit'"/> |
---|
32 | |
---|
33 | <xsl:param name="ComparisonValues.yearPeriodDimensionName" select="'Year'"/> |
---|
34 | <xsl:param name="ComparisonValues.defaultPeriodDimensionName" select="'YearDefault'"/> |
---|
35 | <xsl:param name="ComparisonValues.defaultPeriodDimensionValue" select="'unspecified'"/> |
---|
36 | |
---|
37 | |
---|
38 | <!-- GARTH TODO: remove or update as needed. |
---|
39 | <DATASETS> |
---|
40 | <DATASET name="CancerDeathLung.CancerDeathsPer100K"> |
---|
41 | <NAME>CancerDeathLung.CancerDeathsPer100K</NAME> |
---|
42 | |
---|
43 | <VALUE_TYPES> |
---|
44 | <VALUE_TYPE name="RatePer100K"> |
---|
45 | <MEASURE_NAME>CancerDeathsPer100K</MEASURE_NAME> |
---|
46 | <MEASURE> |
---|
47 | ... |
---|
48 | <DIMENSION_COMBINATIONS> |
---|
49 | <DIMENSION_COMBINATION> |
---|
50 | <PERIOD_DIMENSION> |
---|
51 | <NAME>Year</NAME> |
---|
52 | <VALUES> |
---|
53 | <VALUE>2012</VALUE> |
---|
54 | . . . |
---|
55 | <VALUE>1988</VALUE> |
---|
56 | </VALUES> |
---|
57 | </PERIOD_DIMENSION> |
---|
58 | <DIMENSION_1> |
---|
59 | <NAME>US</NAME> |
---|
60 | </DIMENSION_1> |
---|
61 | </DIMENSION_COMBINATION> |
---|
62 | </DIMENSION_COMBINATIONS> |
---|
63 | Generic USAGES struct doesn't work as they need to be contained as a group |
---|
64 | <DIMENSION_USAGES> |
---|
65 | <DIMENSION_USAGE> |
---|
66 | <USAGE>period</USAGE> |
---|
67 | <NAME>Year</NAME> |
---|
68 | <VALUES> |
---|
69 | <VALUE>2012</VALUE> |
---|
70 | . . . |
---|
71 | <VALUE>1988</VALUE> |
---|
72 | </VALUES> |
---|
73 | </DIMENSION_USAGE> |
---|
74 | <DIMENSION_USAGE> |
---|
75 | <USAGE>dimension_1</USAGE> |
---|
76 | <NAME>US</NAME> |
---|
77 | </DIMENSION_USAGE> |
---|
78 | </DIMENSION_USAGES> |
---|
79 | |
---|
80 | IP HAS: |
---|
81 | |
---|
82 | |
---|
83 | maybe simply start with the IP datasets that have the community name/value only combination. ==> COMMUN DATASETS |
---|
84 | IP datasets that have the US only combination. ==> US DATASETS |
---|
85 | |
---|
86 | Get COM and US datasets that of all NON combined years. |
---|
87 | |
---|
88 | Get the US dataset that has period and dim |
---|
89 | |
---|
90 | Get the measure of the US dataset. |
---|
91 | Get the period that is NOT the all combined. |
---|
92 | If not exists then get the first non all combined dimension |
---|
93 | |
---|
94 | |
---|
95 | The request can specify the dims to ComparisonValues. If nothing the XSLT can have default state and US. |
---|
96 | The XSLT can then determine the primary dataset by matching the DIM COMBO |
---|
97 | of community dim/value with period name/value and measure. |
---|
98 | |
---|
99 | the main dimension 1 name and value are on the request URL |
---|
100 | the state ds is the same as the primary. The state dim name and value are |
---|
101 | hard coded values - like the US dim name and value. |
---|
102 | |
---|
103 | The period name and value MUST match across all compare datasets. |
---|
104 | |
---|
105 | Maybe reference a IP VIEW. The IP view specifies: |
---|
106 | - Primary and any other dataset(s). Primary is the one that contains the |
---|
107 | specified community dim name/value. All others are comparisons. However, |
---|
108 | how do determine which dim name and value to use on those other datasets? |
---|
109 | US and STATE can be hard coded. Others??? Maybe the XSLT has a list of |
---|
110 | DIM NAME/VALUE to be tried??? |
---|
111 | - Measure |
---|
112 | - Period dim name |
---|
113 | |
---|
114 | ********** PROBLEM WITH IP VIEW: views rarely contains everything needed. |
---|
115 | The state us is typically by year and does NOT include any other community |
---|
116 | dims. Once in a while you'll get State, Community, US by Sex with all years |
---|
117 | held constant etc. |
---|
118 | --> |
---|
119 | <xsl:template name="ComparisonValues.getIndicatorStateUSComparisonValues" |
---|
120 | ibis:doc="Contains the logic to determine which IP datasets and their |
---|
121 | assoc measures/AV values. These values are then put inside an XML |
---|
122 | struct and returned for consumption. |
---|
123 | |
---|
124 | PERIOD_DIMENSION |
---|
125 | NAME (dimension) |
---|
126 | TITLE (dimension) |
---|
127 | VALUE (dimension value) |
---|
128 | COMMUNITY |
---|
129 | TITLE (dimension) |
---|
130 | VALUE (measure) |
---|
131 | text value |
---|
132 | TITLE |
---|
133 | LOWER_LIMIT |
---|
134 | text value |
---|
135 | TITLE |
---|
136 | UPPER_LIMIT |
---|
137 | text value |
---|
138 | TITLE |
---|
139 | DESIRABLE_VALUE (measure) |
---|
140 | RELIABILITY ComparisonValues.statisticalReliability(communityRecord/MEASURE/VALUE, lowerLimit, upperLimit) |
---|
141 | STATE |
---|
142 | TITLE (dimension) |
---|
143 | VALUE |
---|
144 | text value |
---|
145 | TITLE |
---|
146 | COMPARISON |
---|
147 | CLASS ComparisonValues.comparisonClass(communityMeasureValue, communityLL, communityUL, stateMeasureValue, measureDesirableValue) |
---|
148 | GAUGE_NAME ComparisonValues.gaugeName(stateComparisonClass, measureDesirableValue) |
---|
149 | US - same as STATE |
---|
150 | " |
---|
151 | > |
---|
152 | <xsl:param name="indicator"/> |
---|
153 | <xsl:param name="dimensions"/> |
---|
154 | <xsl:param name="measures"/> |
---|
155 | <xsl:param name="valueTypes"/> |
---|
156 | |
---|
157 | <xsl:param name="communityDimensionName"/> |
---|
158 | <xsl:param name="communityDimensionValue"/> |
---|
159 | <xsl:param name="stateDimensionName" select="$ComparisonValues.stateDimensionName"/> |
---|
160 | <xsl:param name="stateDimensionValue" select="$ComparisonValues.stateDimensionValue"/> |
---|
161 | <xsl:param name="usDimensionName" select="$ComparisonValues.usDimensionName"/> |
---|
162 | <xsl:param name="usDimensionValue" select="$ComparisonValues.usDimensionValue"/> |
---|
163 | |
---|
164 | <xsl:param name="dimension2Name"/> |
---|
165 | <xsl:param name="dimension2Value"/> |
---|
166 | |
---|
167 | <xsl:param name="periodDimensionName"/> |
---|
168 | <xsl:param name="periodDimensionValue"/> |
---|
169 | |
---|
170 | <xsl:param name="measureName"/> |
---|
171 | |
---|
172 | |
---|
173 | <!-- usDS = DATASETs based on DS DIM COMBO - If DIM2 then use else US DIM1, NO DIM 2. |
---|
174 | usPeriodDimensionCombinations = all the period dim combos from the usDS |
---|
175 | usMeasureNames = all the measure names from the usDS |
---|
176 | --> |
---|
177 | <xsl:variable name="usDatasets" select=" |
---|
178 | if(0 = string-length($dimension2Name)) then |
---|
179 | $indicator/DATASETS/DATASET[DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[not(DIMENSION_2/NAME) and DIMENSION_1/NAME = $usDimensionName]] |
---|
180 | else |
---|
181 | $indicator/DATASETS/DATASET[DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[(DIMENSION_2/NAME = $dimension2Name) and DIMENSION_1/NAME = $usDimensionName]] |
---|
182 | "/> |
---|
183 | <xsl:variable name="usPeriodDimensionCombinations" select=" |
---|
184 | if(0 = string-length($dimension2Name)) then |
---|
185 | $usDatasets/DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[not(DIMENSION_2/NAME) and DIMENSION_1/NAME = $usDimensionName]/PERIOD_DIMENSION |
---|
186 | else |
---|
187 | $usDatasets/DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[(DIMENSION_2/NAME = $dimension2Name) and DIMENSION_1/NAME = $usDimensionName]/PERIOD_DIMENSION |
---|
188 | "/> |
---|
189 | <xsl:variable name="usMeasureNames" select="$usDatasets/MEASURE_NAME"/> |
---|
190 | |
---|
191 | |
---|
192 | <!-- do a similar thing for the community Datasets. If US measures match |
---|
193 | community measures then limit the Community Measure Names to those |
---|
194 | that match the US measures else simply use the community measure names. |
---|
195 | NOTE: community and state are in the same dataset. |
---|
196 | --> |
---|
197 | <xsl:variable name="communityDatasets" select=" |
---|
198 | if(0 = string-length($dimension2Name)) then |
---|
199 | $indicator/DATASETS/DATASET[DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[not(DIMENSION_2/NAME) and DIMENSION_1/NAME = $communityDimensionName]] |
---|
200 | else |
---|
201 | $indicator/DATASETS/DATASET[DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[(DIMENSION_2/NAME = $dimension2Name) and (DIMENSION_1/NAME = $communityDimensionName)]] |
---|
202 | "/> |
---|
203 | <xsl:variable name="communityPeriodDimensionCombinations" select=" |
---|
204 | if(0 = string-length($dimension2Name)) then |
---|
205 | $communityDatasets/DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[not(DIMENSION_2/NAME) and DIMENSION_1/NAME = $communityDimensionName]/PERIOD_DIMENSION |
---|
206 | else |
---|
207 | $communityDatasets/DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[(DIMENSION_2/NAME = $dimension2Name) and DIMENSION_1/NAME = $communityDimensionName]/PERIOD_DIMENSION |
---|
208 | "/> |
---|
209 | <xsl:variable name="communityMeasureNames" select=" |
---|
210 | if(0 != count($communityDatasets[MEASURE_NAME = $usMeasureNames]/MEASURE_NAME )) then |
---|
211 | $communityDatasets[MEASURE_NAME = $usMeasureNames]/MEASURE_NAME |
---|
212 | else |
---|
213 | $communityDatasets/MEASURE_NAME |
---|
214 | "/> |
---|
215 | |
---|
216 | |
---|
217 | <!-- Determine the period name if not passed in. |
---|
218 | RULES: |
---|
219 | - If passed as a param then use that. |
---|
220 | - Else if both US and Community have "Year" then use "Year". |
---|
221 | - Else If US Period Dim and not default and US matches Community Period Dim use first match. |
---|
222 | - Else get the first US Period Dim that matches a community period dim (typically theis will be the default/all years). |
---|
223 | - Else community only - try the "Year" with the dim2. |
---|
224 | - Else community only - try the "Year" without dim2. |
---|
225 | - Else use the default combined. Could have done several other checks |
---|
226 | like getting the first non default |
---|
227 | |
---|
228 | - All combined |
---|
229 | - |
---|
230 | --> |
---|
231 | <xsl:variable name="periodName"> |
---|
232 | <xsl:choose> |
---|
233 | <xsl:when test="0 != string-length($periodDimensionName)"> |
---|
234 | <xsl:value-of select="$periodDimensionName"/> |
---|
235 | </xsl:when> |
---|
236 | |
---|
237 | <xsl:when test=" |
---|
238 | exists($usPeriodDimensionCombinations[NAME = $ComparisonValues.yearPeriodDimensionName]) |
---|
239 | and |
---|
240 | exists($communityPeriodDimensionCombinations[NAME = $ComparisonValues.yearPeriodDimensionName]) |
---|
241 | "> |
---|
242 | <xsl:value-of select="$ComparisonValues.yearPeriodDimensionName"/> |
---|
243 | </xsl:when> |
---|
244 | <xsl:when test="exists($usPeriodDimensionCombinations[(NAME != $ComparisonValues.defaultPeriodDimensionName) and (NAME = $communityPeriodDimensionCombinations/NAME)]/NAME)"> |
---|
245 | <xsl:value-of select="($usPeriodDimensionCombinations[(NAME != $ComparisonValues.defaultPeriodDimensionName) and (NAME = $communityPeriodDimensionCombinations/NAME)]/NAME)[1]"/> |
---|
246 | </xsl:when> |
---|
247 | <xsl:when test="exists($usPeriodDimensionCombinations[NAME = $communityPeriodDimensionCombinations]/NAME)"> |
---|
248 | <xsl:value-of select="($usPeriodDimensionCombinations[NAME = $communityPeriodDimensionCombinations/NAME]/NAME)[1]"/> |
---|
249 | </xsl:when> |
---|
250 | |
---|
251 | <xsl:when test="exists($communityPeriodDimensionCombinations[NAME != $ComparisonValues.defaultPeriodDimensionName]/NAME)"> |
---|
252 | <xsl:value-of select="($communityPeriodDimensionCombinations[NAME != $ComparisonValues.defaultPeriodDimensionName]/NAME)[1]"/> |
---|
253 | </xsl:when> |
---|
254 | <xsl:otherwise> |
---|
255 | <xsl:value-of select="$ComparisonValues.defaultPeriodDimensionName"/> |
---|
256 | </xsl:otherwise> |
---|
257 | </xsl:choose> |
---|
258 | </xsl:variable> |
---|
259 | |
---|
260 | <xsl:variable name="measureName" select=" |
---|
261 | if(0 != string-length($measureName)) then $measureName |
---|
262 | else $communityDatasets[(MEASURE_NAME = $communityMeasureNames) and DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[PERIOD_DIMENSION/NAME = $periodName]][1]/MEASURE_NAME |
---|
263 | "/> |
---|
264 | <!-- GARTH TODO: |
---|
265 | <xsl:message select="concat('ComparisonValues.getIndicatorStateUSComparisonValues - count of measure names: ', count($measureName))"/> |
---|
266 | --> |
---|
267 | <xsl:variable name="usDataset" select="$usDatasets [(MEASURE_NAME = $measureName) and DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[PERIOD_DIMENSION/NAME = $periodName]]"/> |
---|
268 | <xsl:variable name="communityDataset" select="$communityDatasets[(MEASURE_NAME = $measureName) and DIMENSION_COMBINATIONS/DIMENSION_COMBINATION[PERIOD_DIMENSION/NAME = $periodName]]"/> |
---|
269 | |
---|
270 | <xsl:variable name="periodValue"> |
---|
271 | <xsl:choose> |
---|
272 | <xsl:when test="0 != string-length($periodDimensionValue)"> |
---|
273 | <xsl:value-of select="$periodDimensionValue"/> |
---|
274 | </xsl:when> |
---|
275 | <xsl:otherwise> |
---|
276 | <xsl:variable name="periodValues"> |
---|
277 | <xsl:for-each select="distinct-values( $communityDataset/DIMENSION_COMBINATIONS/DIMENSION_COMBINATION/PERIOD_DIMENSION[NAME = $periodName]/VALUES/VALUE )"> |
---|
278 | <xsl:sort select="." data-type="text" order="descending"/> |
---|
279 | <VALUE><xsl:value-of select="."/></VALUE> |
---|
280 | </xsl:for-each> |
---|
281 | </xsl:variable> |
---|
282 | <xsl:value-of select=" |
---|
283 | if(string-length($periodValues/VALUE[1]) != 0) then |
---|
284 | $periodValues/VALUE[1] |
---|
285 | else if($periodName = $ComparisonValues.defaultPeriodDimensionName) then |
---|
286 | $ComparisonValues.defaultPeriodDimensionValue |
---|
287 | else |
---|
288 | '' |
---|
289 | "/> |
---|
290 | <!-- GARTH TODO: |
---|
291 | <xsl:message select="'~~~~~~~~~~~~~~~~~~~~~ComparisonValues.getIndicatorStateUSComparisonValueElements - periodValues: '"/> |
---|
292 | <xsl:message select="$periodValues/VALUE"/> |
---|
293 | --> |
---|
294 | </xsl:otherwise> |
---|
295 | </xsl:choose> |
---|
296 | </xsl:variable> |
---|
297 | <!-- GARTH TODO: |
---|
298 | <xsl:message select="concat('~~~~~~~~~~~~~~~~~~~~~~~~~ComparisonValues.getIndicatorStateUSComparisonValueElements - periodValue: ', $periodValue, ', measureName: ', $measureName)"/> |
---|
299 | --> |
---|
300 | |
---|
301 | |
---|
302 | <xsl:variable name="communityRecord" select=" |
---|
303 | if(0 = string-length($dimension2Name)) then |
---|
304 | $communityDataset/RECORDS/RECORD[ DIMENSIONS[ (2 = count(DIMENSION)) and DIMENSION[(NAME = $communityDimensionName) and (VALUE = $communityDimensionValue)] and DIMENSION[(NAME = $periodName) and (VALUE = $periodValue)]]] |
---|
305 | else |
---|
306 | $communityDataset/RECORDS/RECORD[ DIMENSIONS[ DIMENSION[(NAME = $communityDimensionName) and (VALUE = $communityDimensionValue)] and DIMENSION[(NAME = $dimension2Name) and (VALUE = $dimension2Value)] and DIMENSION[(NAME = $periodName) and (VALUE = $periodValue)]]] |
---|
307 | "/> |
---|
308 | <xsl:variable name="stateRecord" select=" |
---|
309 | if(0 = string-length($dimension2Name)) then |
---|
310 | $communityDataset/RECORDS/RECORD[ DIMENSIONS[ (2 = count(DIMENSION)) and DIMENSION[(NAME = $stateDimensionName) and (VALUE = $stateDimensionValue)] and DIMENSION[(NAME = $periodName) and (VALUE = $periodValue)]]] |
---|
311 | else |
---|
312 | $communityDataset/RECORDS/RECORD[ DIMENSIONS[ DIMENSION[(NAME = $stateDimensionName) and (VALUE = $stateDimensionValue)] and DIMENSION[(NAME = $dimension2Name) and (VALUE = $dimension2Value)] and DIMENSION[(NAME = $periodName) and (VALUE = $periodValue)]]] |
---|
313 | "/> |
---|
314 | <xsl:variable name="usRecord" select=" |
---|
315 | if(0 = string-length($dimension2Name)) then |
---|
316 | $usDataset/RECORDS/RECORD[ DIMENSIONS[ (2 = count(DIMENSION)) and DIMENSION[(NAME = $usDimensionName) and (VALUE = $usDimensionValue)] and DIMENSION[(NAME = $periodName) and (VALUE = $periodValue)]]] |
---|
317 | else |
---|
318 | $usDataset/RECORDS/RECORD[ DIMENSIONS[ DIMENSION[(NAME = $usDimensionName) and (VALUE = $usDimensionValue)] and DIMENSION[(NAME = $dimension2Name) and (VALUE = $dimension2Value)] and DIMENSION[(NAME = $periodName) and (VALUE = $periodValue)]]] |
---|
319 | "/> |
---|
320 | |
---|
321 | <xsl:variable name="measure" select="$measures//MEASURE[NAME = $measureName]"/> |
---|
322 | <xsl:variable name="lowerLimit" select="$communityRecord/ANCILLARY_VALUES/ANCILLARY_VALUE[NAME = $ComparisonValues.lowerLimitAncillaryValueName]/VALUE"/> |
---|
323 | <xsl:variable name="upperLimit" select="$communityRecord/ANCILLARY_VALUES/ANCILLARY_VALUE[NAME = $ComparisonValues.upperLimitAncillaryValueName]/VALUE"/> |
---|
324 | <xsl:variable name="formatPattern" select="$valueTypes/VALUE_TYPE[NAME = $measure/VALUE_TYPE_NAME]/XSLT_FORMAT_PATTERN"/> |
---|
325 | <!-- GARTH TODO: remove |
---|
326 | <xsl:variable name="formatPattern" select="'0.0'"/> |
---|
327 | |
---|
328 | <xsl:if test="count($usRecord/MEASURE) > 1"> |
---|
329 | <xsl:message select="$indicatorName"/> |
---|
330 | <xsl:message select="$measureName"/> |
---|
331 | <xsl:message select="$usRecord"/> |
---|
332 | </xsl:if> |
---|
333 | <xsl:if test="count($indicator/NAME) = 'SuicDeath'"> |
---|
334 | <xsl:message select="$indicator/NAME"/> |
---|
335 | <xsl:message select="$periodName"/> |
---|
336 | <xsl:message select="$periodValue"/> |
---|
337 | <xsl:message select="$measure"/> |
---|
338 | </xsl:if> |
---|
339 | |
---|
340 | <xsl:if test="$indicator/NAME = 'SuicDeath'"> |
---|
341 | <xsl:message select="$indicator/NAME"/> |
---|
342 | <xsl:message select="$periodName"/> |
---|
343 | <xsl:message select="$periodValue"/> |
---|
344 | <xsl:message select="$communityRecord"/> |
---|
345 | </xsl:if> |
---|
346 | |
---|
347 | <xsl:if test="$indicator/NAME = 'NutriAdultFruitVeg'"> |
---|
348 | <xsl:message select="'********** ComparisonValues.getIndicatorStateUSComparisonValueElements: NutriAdultFruitVeg Measure Name and DV'"/> |
---|
349 | <xsl:message select="$usDatasets"/> |
---|
350 | <xsl:message select="$usMeasureNames"/> |
---|
351 | <xsl:message select="$communityMeasureNames"/> |
---|
352 | <xsl:message select="$periodName"/> |
---|
353 | <xsl:message select="$periodValue"/> |
---|
354 | <xsl:message select="$measure"/> |
---|
355 | </xsl:if> |
---|
356 | |
---|
357 | <xsl:message select="'garth'"/> |
---|
358 | <xsl:message select="$usRecord"/> |
---|
359 | |
---|
360 | |
---|
361 | <xsl:message select="'xxxxxxxxxxxxxxxxxxxxxxxx communityRecord: '"/> |
---|
362 | <xsl:message select="$communityRecord"/> |
---|
363 | <xsl:message select="$measureName"/> |
---|
364 | <xsl:message select="'xxxxxxxxxxxxxxxxxxxxxxxx end'"/> |
---|
365 | |
---|
366 | <xsl:if test="count($stateRecord/MEASURE/VALUE) > 1"> |
---|
367 | <xsl:message select="'xxxxxxxxxxxxxxxxxxxxxxxx start of dup STATE record: '"/> |
---|
368 | <xsl:message select="$indicator/NAME"/> |
---|
369 | <xsl:message select="$communityDataset/NAME"/> |
---|
370 | <xsl:message select="$stateRecord"/> |
---|
371 | <xsl:message select="'xxxxxxxxxxxxxxxxxxxxxxxx end'"/> |
---|
372 | </xsl:if> |
---|
373 | <xsl:if test="count($usRecord/MEASURE/VALUE) > 1"> |
---|
374 | <xsl:message select="'xxxxxxxxxxxxxxxxxxxxxxxx start of dup US comparison record: '"/> |
---|
375 | <xsl:message select="$indicator/NAME"/> |
---|
376 | <xsl:message select="$usDataset/NAME"/> |
---|
377 | <xsl:message select="$usRecord"/> |
---|
378 | <xsl:message select="'xxxxxxxxxxxxxxxxxxxxxxxx end'"/> |
---|
379 | </xsl:if> |
---|
380 | --> |
---|
381 | |
---|
382 | <xsl:if test="count($communityRecord/*) != 0"> |
---|
383 | <PERIOD_DIMENSION> |
---|
384 | <NAME><xsl:value-of select="$periodName"/></NAME> |
---|
385 | <xsl:copy-of select="$communityDataset//DIMENSION[NAME=$periodName]/TITLE"/> |
---|
386 | <xsl:copy-of select="$dimensions//DIMENSION[NAME=$periodName]/VALUES/VALUE[normalize-space(text()[1]) = $periodValue]"/> |
---|
387 | </PERIOD_DIMENSION> |
---|
388 | <COMMUNITY> |
---|
389 | <xsl:copy-of select="$dimensions/DIMENSIONS/DIMENSION[NAME = $communityDimensionName]/VALUES/VALUE[normalize-space(text()[1]) = $communityDimensionValue]/TITLE"/> |
---|
390 | <VALUE> |
---|
391 | <xsl:value-of select="$communityRecord/MEASURE/VALUE"/> |
---|
392 | <TITLE><xsl:value-of select="ibis:getFormattedNumber($communityRecord/MEASURE/VALUE, $formatPattern)"/></TITLE> |
---|
393 | </VALUE> |
---|
394 | <LOWER_LIMIT> |
---|
395 | <xsl:value-of select="$lowerLimit"/> |
---|
396 | <TITLE><xsl:value-of select="ibis:getFormattedNumber($lowerLimit, $formatPattern)"/></TITLE> |
---|
397 | </LOWER_LIMIT> |
---|
398 | <UPPER_LIMIT> |
---|
399 | <xsl:value-of select="$upperLimit"/> |
---|
400 | <TITLE><xsl:value-of select="ibis:getFormattedNumber($upperLimit, $formatPattern)"/></TITLE> |
---|
401 | </UPPER_LIMIT> |
---|
402 | <xsl:copy-of select="$measure/DESIRABLE_VALUE"/> |
---|
403 | <RELIABILITY> |
---|
404 | <xsl:call-template name="ComparisonValues.statisticalReliability"> |
---|
405 | <xsl:with-param name="measure" select="$communityRecord/MEASURE/VALUE"/> |
---|
406 | <xsl:with-param name="measureLowerLimit" select="$lowerLimit"/> |
---|
407 | <xsl:with-param name="measureUpperLimit" select="$upperLimit"/> |
---|
408 | </xsl:call-template> |
---|
409 | </RELIABILITY> |
---|
410 | </COMMUNITY> |
---|
411 | <STATE> |
---|
412 | <xsl:copy-of select="$dimensions/DIMENSIONS/DIMENSION[NAME = $stateDimensionName]/VALUES/VALUE[normalize-space(text()[1]) = $stateDimensionValue]/TITLE"/> |
---|
413 | <VALUE> |
---|
414 | <xsl:value-of select="$stateRecord[1]/MEASURE/VALUE"/> |
---|
415 | <TITLE><xsl:value-of select="ibis:getFormattedNumber($stateRecord[1]/MEASURE/VALUE, $formatPattern)"/></TITLE> |
---|
416 | <xsl:variable name="stateComparisonClass"> |
---|
417 | <xsl:call-template name="ComparisonValues.comparisonClass"> |
---|
418 | <xsl:with-param name="measureValue" select="$communityRecord/MEASURE/VALUE"/> |
---|
419 | <xsl:with-param name="measureLowerLimit" select="$lowerLimit"/> |
---|
420 | <xsl:with-param name="measureUpperLimit" select="$upperLimit"/> |
---|
421 | <xsl:with-param name="comparativeValue" select="$stateRecord[1]/MEASURE/VALUE"/> |
---|
422 | <xsl:with-param name="desirableValue" select="$measure/DESIRABLE_VALUE"/> |
---|
423 | </xsl:call-template> |
---|
424 | </xsl:variable> |
---|
425 | <COMPARISON> |
---|
426 | <CLASS><xsl:value-of select="$stateComparisonClass"/></CLASS> |
---|
427 | <GAUGE_NAME> |
---|
428 | <xsl:call-template name="ComparisonValues.gaugeName"> |
---|
429 | <xsl:with-param name="comparisonClass" select="$stateComparisonClass"/> |
---|
430 | <xsl:with-param name="desirableValue" select="$measure/DESIRABLE_VALUE"/> |
---|
431 | </xsl:call-template> |
---|
432 | </GAUGE_NAME> |
---|
433 | </COMPARISON> |
---|
434 | </VALUE> |
---|
435 | </STATE> |
---|
436 | <US> |
---|
437 | <xsl:copy-of select="$dimensions/DIMENSIONS/DIMENSION[NAME = $usDimensionName]/VALUES/VALUE[normalize-space(text()[1]) = $usDimensionValue]/TITLE"/> |
---|
438 | <VALUE> |
---|
439 | <xsl:value-of select="$usRecord[1]/MEASURE/VALUE"/> |
---|
440 | <TITLE><xsl:value-of select="ibis:getFormattedNumber($usRecord[1]/MEASURE/VALUE, $formatPattern)"/></TITLE> |
---|
441 | <xsl:variable name="usComparisonClass"> |
---|
442 | <xsl:call-template name="ComparisonValues.comparisonClass"> |
---|
443 | <xsl:with-param name="measureValue" select="$communityRecord/MEASURE/VALUE"/> |
---|
444 | <xsl:with-param name="measureLowerLimit" select="$lowerLimit"/> |
---|
445 | <xsl:with-param name="measureUpperLimit" select="$upperLimit"/> |
---|
446 | <xsl:with-param name="comparativeValue" select="$usRecord[1]/MEASURE/VALUE"/> |
---|
447 | <xsl:with-param name="desirableValue" select="$measure/DESIRABLE_VALUE"/> |
---|
448 | </xsl:call-template> |
---|
449 | </xsl:variable> |
---|
450 | <COMPARISON> |
---|
451 | <CLASS><xsl:value-of select="$usComparisonClass"/></CLASS> |
---|
452 | <GAUGE_NAME> |
---|
453 | <xsl:call-template name="ComparisonValues.gaugeName"> |
---|
454 | <xsl:with-param name="comparisonClass" select="$usComparisonClass"/> |
---|
455 | <xsl:with-param name="desirableValue" select="$measure/DESIRABLE_VALUE"/> |
---|
456 | </xsl:call-template> |
---|
457 | </GAUGE_NAME> |
---|
458 | </COMPARISON> |
---|
459 | </VALUE> |
---|
460 | </US> |
---|
461 | <xsl:copy-of select="$measure"/> |
---|
462 | </xsl:if> |
---|
463 | </xsl:template> |
---|
464 | |
---|
465 | |
---|
466 | <xsl:template name="ComparisonValues.statisticalReliability" |
---|
467 | ibis:doc="Localizes logic needed to determine the approp reliability flag |
---|
468 | measure with 0=RSE lt .3, 1=RSE between .30 - .50, 2=RSE gt .50." |
---|
469 | > |
---|
470 | <xsl:param name="measure"/> |
---|
471 | <xsl:param name="measureLowerLimit"/> |
---|
472 | <xsl:param name="measureUpperLimit"/> |
---|
473 | <!-- GARTH TODO: REMOVE |
---|
474 | <xsl:message select="$measure"/> |
---|
475 | --> |
---|
476 | <!--first off, check for for instances when when the community dimension |
---|
477 | is not present - such as indicators that use selected counties, then |
---|
478 | check for when the indicator value is missing or '**' |
---|
479 | Can also use: string(number($number))='NaN' |
---|
480 | --> |
---|
481 | <xsl:choose> |
---|
482 | <xsl:when test="(string(number($measure)) = 'NaN') |
---|
483 | or ($measureLowerLimit = 'DNA') |
---|
484 | or ($measureUpperLimit = 'DNA') |
---|
485 | ">DNA</xsl:when> |
---|
486 | |
---|
487 | <xsl:otherwise> |
---|
488 | <xsl:variable name="rse"> |
---|
489 | <xsl:call-template name="ComparisonValues.rse"> |
---|
490 | <xsl:with-param name="measure" select="number($measure)"/> |
---|
491 | <xsl:with-param name="measureLowerLimit" select="number($measureLowerLimit)"/> |
---|
492 | <xsl:with-param name="measureUpperLimit" select="number($measureUpperLimit)"/> |
---|
493 | </xsl:call-template> |
---|
494 | </xsl:variable> |
---|
495 | |
---|
496 | <xsl:choose> |
---|
497 | <xsl:when test="number($rse) < 0.3">Stable</xsl:when> |
---|
498 | <xsl:when test="number($rse) > 0.5">Very Unstable</xsl:when> |
---|
499 | <xsl:otherwise>Unstable</xsl:otherwise> |
---|
500 | </xsl:choose> |
---|
501 | </xsl:otherwise> |
---|
502 | </xsl:choose> |
---|
503 | </xsl:template> |
---|
504 | |
---|
505 | |
---|
506 | <xsl:template name="ComparisonValues.rse" |
---|
507 | ibis:doc="Localizes the calc logic used to determine the reliability. |
---|
508 | This value *could* be determined at the time of publishing the |
---|
509 | dataset XML. |
---|
510 | " |
---|
511 | > |
---|
512 | <xsl:param name="measure"/> |
---|
513 | <xsl:param name="measureLowerLimit"/> |
---|
514 | <xsl:param name="measureUpperLimit"/> |
---|
515 | |
---|
516 | <xsl:param name="lowerDifference" select="$measure - $measureLowerLimit"/> |
---|
517 | <xsl:param name="upperDifference" select="$measureUpperLimit - $measure"/> |
---|
518 | <xsl:param name="difference" select="if($lowerDifference > $upperDifference)then $lowerDifference else $upperDifference"/> |
---|
519 | <xsl:value-of select="($difference div 1.96) div $measure"/> |
---|
520 | </xsl:template> |
---|
521 | |
---|
522 | |
---|
523 | <!-- G A U G E G R A P H I C a n d C L A S S I F I C A T I O N --> |
---|
524 | <xsl:template name="ComparisonValues.comparisonClass" |
---|
525 | ibis:doc="Localizes logic needed to determine the approp comparison |
---|
526 | classification/css class. This call is typically used to determine |
---|
527 | the css class for the comparison cell color. |
---|
528 | |
---|
529 | Note this template ONLY handles numeric values - it does NOT deal |
---|
530 | with values which contain character type data. |
---|
531 | |
---|
532 | Value returned: Worse, Below, Similar, Above, Better, ''. |
---|
533 | |
---|
534 | Low target value: |
---|
535 | Better - EXCELLENT: UCL lt Compare Value |
---|
536 | Above - REASON FOR CONCERN: LCL gt Compare Value |
---|
537 | Similar - SAME: when none of the above and number groups = 3 |
---|
538 | Below - WATCH: Value le Compare Value |
---|
539 | Worse - IMPROVEMENT NEEDED: Value ge Compare Value |
---|
540 | |
---|
541 | High target value: |
---|
542 | Better - EXCELLENT: LCL gt Compare Value |
---|
543 | Above - REASON FOR CONCERN: UCL lt Compare Value |
---|
544 | Similar - SAME: when none of the above and number groups = 3 |
---|
545 | Below - WATCH: Value ge Compare Value |
---|
546 | Worse - IMPROVEMENT NEEDED: Value le Compare Value |
---|
547 | " |
---|
548 | > |
---|
549 | <xsl:param name="measureValue"/> |
---|
550 | <xsl:param name="measureLowerLimit"/> |
---|
551 | <xsl:param name="measureUpperLimit"/> |
---|
552 | <xsl:param name="comparativeValue"/> |
---|
553 | <xsl:param name="desirableValue" |
---|
554 | ibis:doc="This is the measureValue/DESIRABLE_VALUE. The current usage |
---|
555 | is an index where 0=low is better and + means high is better. |
---|
556 | The measureValue's DV is numeric to be flexible for future uses - |
---|
557 | e.g. so that actual numeric target type values can be used. |
---|
558 | " |
---|
559 | /> |
---|
560 | <xsl:param name="numberOfGroups" select="$ComparisonValues.defaultNumberOfGroups"/> |
---|
561 | |
---|
562 | <!-- convert to numeric as XSLT defaults to string values --> |
---|
563 | <xsl:variable name="value" select="number($measureValue)"/> |
---|
564 | <xsl:variable name="lcl" select="number($measureLowerLimit)"/> |
---|
565 | <xsl:variable name="ucl" select="number($measureUpperLimit)"/> |
---|
566 | <xsl:variable name="compare" select="number($comparativeValue)"/> |
---|
567 | |
---|
568 | <!-- Only try to determine if all values are numeric. --> |
---|
569 | <xsl:if test="ibis:_isNumeric($value) |
---|
570 | and ibis:_isNumeric($lcl) |
---|
571 | and ibis:_isNumeric($ucl) |
---|
572 | and ibis:_isNumeric($compare) |
---|
573 | "> |
---|
574 | <xsl:if test="'LOW' = $desirableValue"> |
---|
575 | <xsl:choose> |
---|
576 | <xsl:when test="($ucl < $compare)">Better</xsl:when> |
---|
577 | <xsl:when test="($lcl >= $compare)">Worse</xsl:when> |
---|
578 | <xsl:when test="(5 = $numberOfGroups) and ($value <= $compare)">Above</xsl:when> |
---|
579 | <xsl:when test="(5 = $numberOfGroups) and ($value >= $compare)">Below</xsl:when> |
---|
580 | <xsl:when test="('LOW' = $desirableValue)">Similar</xsl:when> |
---|
581 | </xsl:choose> |
---|
582 | </xsl:if> |
---|
583 | |
---|
584 | <xsl:if test="'HIGH' = $desirableValue"> |
---|
585 | <xsl:choose> |
---|
586 | <xsl:when test="($lcl > $compare)">Better</xsl:when> |
---|
587 | <xsl:when test="($ucl <= $compare)">Worse</xsl:when> |
---|
588 | <xsl:when test="(5 = $numberOfGroups) and ($value >= $compare)">Above</xsl:when> |
---|
589 | <xsl:when test="(5 = $numberOfGroups) and ($value <= $compare)">Below</xsl:when> |
---|
590 | <xsl:otherwise>Similar</xsl:otherwise> |
---|
591 | </xsl:choose> |
---|
592 | </xsl:if> |
---|
593 | </xsl:if> |
---|
594 | </xsl:template> |
---|
595 | |
---|
596 | |
---|
597 | <xsl:template name="ComparisonValues.gaugeName" |
---|
598 | ibis:doc="Localizes creation of gauge graphic name. This call is |
---|
599 | typically used to determine the gauge graphic to display. |
---|
600 | |
---|
601 | Value returned: compareIndex _ desired value _ number of groups: |
---|
602 | better_low_3 or 4, better_high_3 or 4, |
---|
603 | above_low_3 or 4, above_high_3 or 4, |
---|
604 | below_low_3 or 4, below_high_3 or 4, |
---|
605 | similar_low_3 or 4, similar_high_3 or 4, |
---|
606 | worse_low_3 or 4, worse_high_3 or 4, |
---|
607 | na, insufficient. |
---|
608 | " |
---|
609 | > |
---|
610 | <xsl:param name="comparisonClass"/> |
---|
611 | <xsl:param name="measureValue"/> |
---|
612 | <xsl:param name="measureLowerLimit"/> |
---|
613 | <xsl:param name="measureUpperLimit"/> |
---|
614 | <xsl:param name="comparativeValue"/> |
---|
615 | <xsl:param name="desirableValue" |
---|
616 | ibis:doc="This is the MEASURE/DESIRABLE_VALUE. The current usage |
---|
617 | is an index where 0=low is better and + means high is better. |
---|
618 | The measure's DV is numeric to be flexible for future uses - |
---|
619 | e.g. so that actual numeric target type values can be used. |
---|
620 | " |
---|
621 | /> |
---|
622 | <xsl:param name="numberOfGroups" select="$ComparisonValues.defaultNumberOfGroups"/> |
---|
623 | |
---|
624 | <xsl:variable name="comparisonClass"> |
---|
625 | <xsl:if test="0 != string-length($comparisonClass)"><xsl:value-of select="$comparisonClass"/></xsl:if> |
---|
626 | <xsl:if test="0 = string-length($comparisonClass)"> |
---|
627 | <xsl:call-template name="ComparisonValues.comparisonClass"> |
---|
628 | <xsl:with-param name="measureValue" select="$measureValue"/> |
---|
629 | <xsl:with-param name="comparativeValue" select="$comparativeValue"/> |
---|
630 | <xsl:with-param name="measureLowerLimit" select="$measureLowerLimit"/> |
---|
631 | <xsl:with-param name="measureUpperLimit" select="$measureUpperLimit"/> |
---|
632 | <xsl:with-param name="desirableValue" select="$desirableValue"/> |
---|
633 | <xsl:with-param name="numberOfGroups" select="$numberOfGroups"/> |
---|
634 | </xsl:call-template> |
---|
635 | </xsl:if> |
---|
636 | </xsl:variable> |
---|
637 | <xsl:value-of select="if('' != $comparisonClass) then concat(lower-case($comparisonClass), '_', lower-case($desirableValue), '_', $numberOfGroups) else 'na'"/> |
---|
638 | </xsl:template> |
---|
639 | |
---|
640 | |
---|
641 | |
---|
642 | <xsl:template name="ComparisonValues.publishedIndicators" |
---|
643 | ibis:doc="builds a simple list struct: |
---|
644 | INDICATOR |
---|
645 | NAME |
---|
646 | TITLE - complete |
---|
647 | COMMUNITY |
---|
648 | xxx |
---|
649 | STATE |
---|
650 | xxx |
---|
651 | US |
---|
652 | xxx |
---|
653 | VALUE_TYPE |
---|
654 | " |
---|
655 | > |
---|
656 | <xsl:param name="publishedIndicators"/> |
---|
657 | <xsl:param name="indicatorProfileXMLFilePath"/> |
---|
658 | <xsl:param name="communityDimensionName"/> |
---|
659 | <xsl:param name="communityDimensionValue"/> |
---|
660 | <xsl:param name="stateDimensionName"/> |
---|
661 | <xsl:param name="stateDimensionValue"/> |
---|
662 | <xsl:param name="usDimensionName"/> |
---|
663 | <xsl:param name="usDimensionValue"/> |
---|
664 | <xsl:param name="valueTypes"/> |
---|
665 | <xsl:param name="measures"/> |
---|
666 | |
---|
667 | <xsl:for-each select="$publishedIndicators"> |
---|
668 | <xsl:sort select="SORT_ORDER" data-type="number" order="ascending"/> |
---|
669 | <xsl:sort select="NAME" data-type="text" order="ascending"/> |
---|
670 | |
---|
671 | <xsl:variable name="indicator" select="document(concat($indicatorProfileXMLFilePath, '/', NAME, '.xml'), /)/INDICATOR"/> |
---|
672 | <xsl:variable name="community" select="$indicator//DATASET//RECORD[ DIMENSIONS/DIMENSION[(NAME = $communityDimensionName) and (VALUE = $communityDimensionValue)] ]"/> |
---|
673 | <xsl:message select="concat('C M N: ', $community/MEASURE/NAME, ', state found: ', count($indicator//DATASET//RECORD[ DIMENSIONS/DIMENSION[(NAME = $stateDimensionName) and (VALUE = $stateDimensionValue)] and MEASURE/NAME = $community/MEASURE/NAME]) )"/> |
---|
674 | |
---|
675 | <xsl:if test="exists($community/*)"> |
---|
676 | <INDICATOR> |
---|
677 | <xsl:copy-of select="$indicator/NAME"/> |
---|
678 | <TITLE><xsl:value-of select="ibis:getIndicatorTitle($indicator)"/></TITLE> |
---|
679 | |
---|
680 | |
---|
681 | <COMMUNITY><xsl:copy-of select="$community"/></COMMUNITY> |
---|
682 | <STATE><xsl:copy-of select="$indicator//DATASET//RECORD[ DIMENSIONS/DIMENSION[(NAME = $stateDimensionName) and (VALUE = $stateDimensionValue)] and (MEASURE/NAME = $community/MEASURE/NAME) ][last()]"/></STATE> |
---|
683 | <US><xsl:copy-of select="$indicator//DATASET//RECORD[ DIMENSIONS/DIMENSION[(NAME = $usDimensionName) and (VALUE = $usDimensionValue)] and (MEASURE/NAME = $community/MEASURE/NAME) ][last()]"/></US> |
---|
684 | <xsl:copy-of select="$valueTypes//VALUE_TYPE[NAME = $measures//MEASURE[NAME = $community/MEASURE/NAME]/VALUE_TYPE_NAME]"/> |
---|
685 | </INDICATOR> |
---|
686 | </xsl:if> |
---|
687 | </xsl:for-each> |
---|
688 | </xsl:template> |
---|
689 | |
---|
690 | </xsl:stylesheet> |
---|
691 | <!-- ============================= End of File ============================= --> |
---|