Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transformation : grouping problem

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi,


I made many grouping using muenchian method without problem
here i don't understand why i get this :

when i try to group and get all elements having the same service/then category


<xsl:key name=&quot;total-by-service&quot; match=&quot;BudgetSubTotLangCategXML&quot; use=&quot;Service&quot; />
<xsl:key name=&quot;total-by-service-cat&quot; match=&quot;BudgetSubTotLangCategXML&quot; use=&quot;concat(Service, ' ', Category)&quot; />

with this xslt :

<xsl:for-each select=&quot;BudgetSubTotLangCategXML[count(. | key('total-by-service', Service)[1]) = 1]&quot;>
<xsl:variable name=&quot;serv_totals&quot; select=&quot;key('total-by-service', Service)&quot; />
<xsl:for-each select=&quot;$serv_totals[generate-id() =generate-id(key('total-by-service-cat',concat(Service, ' ',Category))[1])]&quot;> <!-- Wrong ?!? -->
<xsl:value-of select=&quot;Total&quot;/>
<!-- should return me &quot;5 , 0.6&quot; and &quot;700 , 0&quot; but only get &quot;5&quot; -->
</xsl:for-each>
</xsl:for-each>


I get only the first element of each category not the two elements of each category


here is what i get :

Translation Doc translation XltDocWord Word Arabic English (UK)
Translation Other translation XltTranslatorHour Hour Arabic English (UK)


And when i try this xslt :


<xsl:for-each select=&quot;BudgetSubTotLangCategXML[count(. | key('total-by-service', Service)[1]) = 1]&quot;>
<xsl:variable name=&quot;cat_totals&quot; select=&quot;key('total-by-service', Service)&quot; />
<xsl:for-each select=&quot;$cat_totals[Category]&quot;> <!-- Wrong ?!? -->
<xsl:value-of select=&quot;Total&quot;/><br/>
<!-- should return me &quot;5 , 0.6&quot; and &quot;700 , 0&quot; items but get a hole list &quot;5 , 0.6 , 700 , 0&quot; -->
</xsl:for-each>
</xsl:for-each>

My selection doesn't work it gives me all items not each item for each different category


Do you know what's wrong in my xPath grouping selection ?

TIA
regards,

Elise

-----------------------------------------------------------------------------------------------------------------------------------------

my XML : (generated and cannot be changed)

<BudgetSubTotLangCategXML>
<Service>Translation</Service>
<Category>Doc translation</Category>
<LANGS_Name>Arabic</LANGS_Name>
<LangName>English (UK)</LangName>
<Total>5</Total>
</BudgetSubTotLangCategXML>
<BudgetSubTotLangCategXML>
<Service>Translation</Service>
<Category>Doc translation</Category>
<LANGS_Name>English</LANGS_Name>
<LangName>Swedish</LangName>
<Total>0.6</Total>
</BudgetSubTotLangCategXML>

<BudgetSubTotLangCategXML>
<Service>Translation</Service>
<Category>Other translation</Category>
<LANGS_Name>Arabic</LANGS_Name>
<LangName>English (UK)</LangName>
<Total>700</Total>
</BudgetSubTotLangCategXML>
<BudgetSubTotLangCategXML>
<Service>Translation</Service>
<Category>Other translation</Category>
<LANGS_Name>English</LANGS_Name>
<LangName>Swedish</LangName>
<Total>0</Total>
</BudgetSubTotLangCategXML> Best regards,
Elise, XML learning girl X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top