我有一个问题,而忽略大小写获取值。发生的情况是,当用户输入他们使用的设备数据时,他们可能会输入38e135作为设备编号,但稍后在表单中他们可能会输入38e135。当我循环遍历设备id时,我需要将它们视为一个。
当我尝试这样做时,我得到它们作为两个不同的设备编号。
<xsl:key name="distinctEquipNum" match="//EquipmentNumber" use="."/>
当我尝试使用翻译函数时,我只得到其中一个。
<xsl:key name="distinctEquipNum" match="//EquipmentNumber" use="translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
这是我用来获取数据
的循环<xsl:for-each select=".//EquipmentNumber[generate-id() = generate-id(key('distinctEquipNum', .)[1])]">
<xsl:variable name="equipNum" select="."></xsl:variable>
<td><xsl:value-of select="$equipNum"/></td>
是否有一种方法可以让我循环遍历设备编号并忽略大小写?
这是我正在使用的XML示例,
<Timesheet>
<Equipment>
<EquipmentWorkOrder>
<EquipmentWorkOrderNumber>220923134</EquipmentWorkOrderNumber>
<EquipmentDetail>
<EquipmentMileage>1123</EquipmentMileage>
<EquipmentHourMeter>Hour Meter</EquipmentHourMeter>
<EquipmentType>Bucket truck</EquipmentType>
<EquipmentNumber>38e135</EquipmentNumber>
<MondayHours>6</MondayHours>
<TuesdayHours>Tuesday</TuesdayHours>
<WednesdayHours>1</WednesdayHours>
<ThursdayHours>Thursday</ThursdayHours>
<FridayHours>Friday</FridayHours>
<SaturdayHours>Saturday</SaturdayHours>
<SundayHours>Sunday</SundayHours>
</EquipmentDetail>
</EquipmentWorkOrder>
<EquipmentWorkOrder>
<EquipmentWorkOrderNumber>220923378</EquipmentWorkOrderNumber>
<EquipmentDetail>
<EquipmentMileage>72155</EquipmentMileage>
<EquipmentHourMeter>Hour Meter</EquipmentHourMeter>
<EquipmentType>4x4 Pickup</EquipmentType>
<EquipmentNumber>2a3557</EquipmentNumber>
<MondayHours>6</MondayHours>
<TuesdayHours>3</TuesdayHours>
<WednesdayHours>5</WednesdayHours>
<ThursdayHours>2</ThursdayHours>
<FridayHours>Friday</FridayHours>
<SaturdayHours>2</SaturdayHours>
<SundayHours>Sunday</SundayHours>
</EquipmentDetail>
</EquipmentWorkOrder>
<EquipmentWorkOrder>
<EquipmentWorkOrderNumber>220923134</EquipmentWorkOrderNumber>
<EquipmentDetail>
<EquipmentMileage>Mileage</EquipmentMileage>
<EquipmentHourMeter>133</EquipmentHourMeter>
<EquipmentType>Back Hoe</EquipmentType>
<EquipmentNumber>122</EquipmentNumber>
<MondayHours>Monday</MondayHours>
<TuesdayHours>8</TuesdayHours>
<WednesdayHours>3</WednesdayHours>
<ThursdayHours>Thursday</ThursdayHours>
<FridayHours>Friday</FridayHours>
<SaturdayHours>Saturday</SaturdayHours>
<SundayHours>Sunday</SundayHours>
</EquipmentDetail>
</EquipmentWorkOrder>
<EquipmentWorkOrder>
<EquipmentWorkOrderNumber>220925520</EquipmentWorkOrderNumber>
<EquipmentDetail>
<EquipmentMileage>72155</EquipmentMileage>
<EquipmentHourMeter>Hour Meter</EquipmentHourMeter>
<EquipmentType>Bucket truck</EquipmentType>
<EquipmentNumber>38E135</EquipmentNumber>
<MondayHours>6</MondayHours>
<TuesdayHours>Tuesday</TuesdayHours>
<WednesdayHours>1</WednesdayHours>
<ThursdayHours>Thursday</ThursdayHours>
<FridayHours>Friday</FridayHours>
<SaturdayHours>Saturday</SaturdayHours>
<SundayHours>Sunday</SundayHours>
</EquipmentDetail>
</EquipmentWorkOrder>
</Equipment></Timesheet>
您需要对用于从键检索的值应用与定义时使用的相同的转换,即,如果键是
<xsl:key name="distinctEquipNum" match="EquipmentNumber"
use="translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
则Muenchian分组表达式需要做相同的translate
<xsl:for-each select=".//EquipmentNumber[generate-id() =
generate-id(key('distinctEquipNum',
translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')
)[1])]">
(注意在键的match
表达式中不需要//
,只需使用match="EquipmentNumber"
)