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="total-by-service" match="BudgetSubTotLangCategXML" use="Service" />
<xsl:key name="total-by-service-cat" match="BudgetSubTotLangCategXML" use="concat(Service, ' ', Category)" />
with this xslt :
<xsl:for-each select="BudgetSubTotLangCategXML[count(. | key('total-by-service', Service)[1]) = 1]">
<xsl:variable name="serv_totals" select="key('total-by-service', Service)" />
<xsl:for-each select="$serv_totals[generate-id() =generate-id(key('total-by-service-cat',concat(Service, ' ',Category))[1])]"> <!-- Wrong ?!? -->
<xsl:value-of select="Total"/>
<!-- should return me "5 , 0.6" and "700 , 0" but only get "5" -->
</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="BudgetSubTotLangCategXML[count(. | key('total-by-service', Service)[1]) = 1]">
<xsl:variable name="cat_totals" select="key('total-by-service', Service)" />
<xsl:for-each select="$cat_totals[Category]"> <!-- Wrong ?!? -->
<xsl:value-of select="Total"/><br/>
<!-- should return me "5 , 0.6" and "700 , 0" items but get a hole list "5 , 0.6 , 700 , 0" -->
</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-)
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="total-by-service" match="BudgetSubTotLangCategXML" use="Service" />
<xsl:key name="total-by-service-cat" match="BudgetSubTotLangCategXML" use="concat(Service, ' ', Category)" />
with this xslt :
<xsl:for-each select="BudgetSubTotLangCategXML[count(. | key('total-by-service', Service)[1]) = 1]">
<xsl:variable name="serv_totals" select="key('total-by-service', Service)" />
<xsl:for-each select="$serv_totals[generate-id() =generate-id(key('total-by-service-cat',concat(Service, ' ',Category))[1])]"> <!-- Wrong ?!? -->
<xsl:value-of select="Total"/>
<!-- should return me "5 , 0.6" and "700 , 0" but only get "5" -->
</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="BudgetSubTotLangCategXML[count(. | key('total-by-service', Service)[1]) = 1]">
<xsl:variable name="cat_totals" select="key('total-by-service', Service)" />
<xsl:for-each select="$cat_totals[Category]"> <!-- Wrong ?!? -->
<xsl:value-of select="Total"/><br/>
<!-- should return me "5 , 0.6" and "700 , 0" items but get a hole list "5 , 0.6 , 700 , 0" -->
</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-)