Populating list in xml file where list size is variable using XSLT 1



I am stuck with a problem with writing xsl using XSLT 1.


My original xml is like:



<conf:BasicConfig id="1">
<conf:attributes>
<conf:LIST_value>
<conf:value>5</conf:value>
<conf:value>10</conf:value>
</conf:LIST_value>
</conf:attributes>
</conf:BasicConfig>
<conf:BasicConfig id="2">
<conf:attributes>
<conf:LIST_value>
<conf:value>6</conf:value>
<conf:value>7</conf:value>
</conf:LIST_value>
</conf:attributes>
</conf:BasicConfig>


I have a list of values like 10, 9, 12. (Size of this list may vary) I want to replace these values in the list where BasicConfig id="1"


This way I have final xml like:



<conf:BasicConfig id="1">
<conf:attributes>
<conf:LIST_value>
<conf:value>10</conf:value>
<conf:value>9</conf:value>
<conf:value>12</conf:value>
</conf:LIST_value>
</conf:attributes>
</conf:BasicConfig>
<conf:BasicConfig id="2">
<conf:attributes>
<conf:LIST_value>
<conf:value>6</conf:value>
<conf:value>7</conf:value>
</conf:LIST_value>
</conf:attributes>
</conf:BasicConfig>


I have flexibility to keep these list of values 10, 9, 12 any way in xsl file. For e.g., I can keep it as:



<xsl:param name="list_values" select="'9,10,12'" />


or, I can keep it as:



<xsl:param name="list_values1" select="'9'" />
<xsl:param name="list_values2" select="'10'" />
<xsl:param name="list_values3" select="'12'" />


Or in another way, but the size of this list may vary. Sometimes, my xsl file will contain 1 value or 2 or any n value.


But I have no idea how to bring this much flexibility into xsl file. Can anybody please help me.


No comments:

Post a Comment