Hi!
I have a somewhat unusual problem. I want to match an xsl:if test to the
first occurrence of an element with an attribute of a particular value. An
example snippet of XML to be transformed:
<TestElement xmlid="testID">
<adder xmlid="personal" cost="2" alias="personal computers" />
<adder xmlid="handheld" cost="2" alias="handheld computers" />
<adder xmlid="network" cost="2" alias="networked computers" />
<adder xmlid="mainframe" cost="2" alias="mainframe" />
</TestElement>
The test needs to find all the TestElements whose xmlid is
'testID''. Then find the first child element whose xmlid matches any of
those listed. Then change that child element's "cost" attribute to "0".
Leave the other "cost" attributes alone.
So, the above snippet would be changed to:
<TestElement xmlid="testID">
<adder xmlid="personal" cost="0" alias="personal computers" />
<adder xmlid="handheld" cost="2" alias="handheld computers" />
<adder xmlid="network" cost="2" alias="networked computers" />
<adder xmlid="mainframe" cost="2" alias="mainframe" />
</TestElement>
The following snippet:
<TestElement xmlid="testID">
<adder xmlid="Not_In_The_Set_To_Be_Recognized"
<adder xmlid="handheld" cost="2" alias="handheld computers" />
</TestElement>
would be changed to:
<TestElement xmlid="testID">
<adder xmlid="Not_In_The_Set_To_Be_Recognized" cost="1" alias="Not In The
Set We Care About" />
<adder xmlid="handheld" cost="0" alias="handheld computers" />
</TestElement>
And the following:
<TestElement xmlid="testID">
<adder xmlid="Not_In_The_Set_To_Be_Recognized" cost="1" alias="Not In The
Set We Care About" />
<adder xmlid="handheld" cost="2" alias="handheld computers" />
<adder xmlid="Not_In_The_Set_To_Be_Recognized" cost="1" alias="Not In The
Set We Care About" />
<adder xmlid="personal" cost="2" alias="personal computers" />
</TestElement>
<TestElement xmlid="testID">
<adder xmlid="personal" cost="2" alias="personal computers" />
<adder xmlid="handheld" cost="2" alias="handheld computers" />
<adder xmlid="Not_In_The_Set_To_Be_Recognized" cost="1" alias="Not In The
Set We Care About" />
</TestElement>
would become:
<TestElement xmlid="testID">
<adder xmlid="Not_In_The_Set_To_Be_Recognized" cost="1" alias="Not In The
Set We Care About" />
<adder xmlid="handheld" cost="0" alias="handheld computers" />
<adder xmlid="Not_In_The_Set_To_Be_Recognized" cost="1" alias="Not In The
Set We Care About" />
<adder xmlid="personal" cost="2" alias="personal computers" />
</TestElement>
<TestElement xmlid="testID">
<adder xmlid="personal" cost="0" alias="personal computers" />
<adder xmlid="handheld" cost="2" alias="handheld computers" />
<adder xmlid="Not_In_The_Set_To_Be_Recognized" cost="1" alias="Not In The
Set We Care About" />
</TestElement>
Any help would be much appreciated. Note that the "xmlid" attributes being
used are -not- unique. They will re-occur.
--->Ben
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list