Use of following to get unique nodes???

J

johkar

In the below example I am using the following to try to match only the
unique MechanismText nodes within each Subscription node:

select="DeliveryPreferences/DeliveryPreference[not(MechanismText=following::
MechanismText)]"
Right now, the 2nd select populates correctly, but the 1st select is empty.
I know what is going on, but I don't know how to correct it.

I would appreciate any ideas, solutions or pointers you can give me.

Thanks, John

After the transformation, I should have two select lists...one for each
Subscription node.

1st Select:
<select>
<option>Email</option>
<option>Fax</option>
</select>

2nd Select:
<select>
<option>Email</option>
<option>Fax</option>
</select>


XSL TEMPLATES
<xsl:template mode="standard"
match="/myRoot/Response/Subscriptions/Subscription">
<select>
<xsl:apply-templates mode="optionbuilder"
select="DeliveryPreferences/DeliveryPreference[not(MechanismText=following::
MechanismText)]" />
</select>
</xsl:template>

<xsl:template mode="optionbuilder"
match="DeliveryPreferences/DeliveryPreference[not(MechanismText=following::M
echanismText)]">
<xsl:element name="option">
<xsl:choose>
<xsl:when test="..//UserPreferenceFlag = 'Y'">
<xsl:if test="UserPreferenceFlag = 'Y'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
</xsl:when>
<xsl:eek:therwise>
<xsl:if test="DefaultPreferenceFlag = 'Y'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
</xsl:eek:therwise>
</xsl:choose>
<xsl:attribute name="value"><xsl:value-of
select="MechanismCode"/></xsl:attribute>
<xsl:if test="MechanismText != 'NONE'">
<xsl:value-of select="MechanismText"/>
</xsl:if>
</xsl:element>
</xsl:template>

HERE IS THE XML
<myRoot>
<Response>
<Subscriptions>
<Subscription>
<DeliveryPreferences>
<DeliveryPreference>
<TypeCode>10</TypeCode>
<MechanismCode>1</MechanismCode>
<MechanismText>Email</MechanismText>
<FrequencyCode>10</FrequencyCode>
<FrequencyText>1st day of the month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>11</TypeCode>
<MechanismCode>1</MechanismCode>
<MechanismText>Email</MechanismText>
<FrequencyCode>11</FrequencyCode>
<FrequencyText>2nd day of the month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>100</TypeCode>
<MechanismCode>7</MechanismCode>
<MechanismText>Fax</MechanismText>
<FrequencyCode>1</FrequencyCode>
<FrequencyText>Month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>101</TypeCode>
<MechanismCode>7</MechanismCode>
<MechanismText>Fax</MechanismText>
<FrequencyCode>2</FrequencyCode>
<FrequencyText>Quarterly</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>Y</UserPreferenceFlag>
</DeliveryPreference>
</DeliveryPreferences>
</Subscription>
<Subscription>
<DeliveryPreferences>
<DeliveryPreference>
<TypeCode>10</TypeCode>
<MechanismCode>1</MechanismCode>
<MechanismText>Email</MechanismText>
<FrequencyCode>10</FrequencyCode>
<FrequencyText>1st day of the month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>11</TypeCode>
<MechanismCode>1</MechanismCode>
<MechanismText>Email</MechanismText>
<FrequencyCode>11</FrequencyCode>
<FrequencyText>2nd day of the month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>12</TypeCode>
<MechanismCode>1</MechanismCode>
<MechanismText>Email</MechanismText>
<FrequencyCode>12</FrequencyCode>
<FrequencyText>3rd day of the month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>40</TypeCode>
<MechanismCode>1</MechanismCode>
<MechanismText>Email</MechanismText>
<FrequencyCode>40</FrequencyCode>
<FrequencyText>31st day of the month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>Y</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>100</TypeCode>
<MechanismCode>7</MechanismCode>
<MechanismText>Fax</MechanismText>
<FrequencyCode>1</FrequencyCode>
<FrequencyText>Month</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
<DeliveryPreference>
<TypeCode>101</TypeCode>
<MechanismCode>7</MechanismCode>
<MechanismText>Fax</MechanismText>
<FrequencyCode>2</FrequencyCode>
<FrequencyText>Quarterly</FrequencyText>
<DefaultPreferenceFlag/>
<UserPreferenceFlag>N</UserPreferenceFlag>
</DeliveryPreference>
</DeliveryPreferences>
</Subscription>
</Subscriptions>
</Response>
</myRoot>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top