איך ניתן לשלב for ו שאילתה ב XSLT?
שלום, יש לי XML שמכיל במקום אחד רשימה של מילים ותחת כל מילה את רשימת ה tests שבוצעו על המילה והתוצאות של כל אחת מהן. במקום אחר ב XML יש רשימה של כל סוגי ה tests שבוצעו בכלל. אני רוצה לרוץ בלולאה על הרשימה שמפרטת את כל סוגי ה tests שבוצעו בכלל ואת לספור לכמה מילים יש test כזה עם attribute מסוג passed בעל ערך True. חשבתי לעשות משהו בסגנון
שלום, יש לי XML שמכיל במקום אחד רשימה של מילים ותחת כל מילה את רשימת ה tests שבוצעו על המילה והתוצאות של כל אחת מהן. במקום אחר ב XML יש רשימה של כל סוגי ה tests שבוצעו בכלל. אני רוצה לרוץ בלולאה על הרשימה שמפרטת את כל סוגי ה tests שבוצעו בכלל ואת לספור לכמה מילים יש test כזה עם attribute מסוג passed בעל ערך True. חשבתי לעשות משהו בסגנון
<xsl:for-each select="compare/info/list[@type='tests']/item"> <xsl:variable name="tname" select="@name" /> <xsl:value-of select="translate('count(/compare/comparison/word/test[@name="%s" and @passed="True"]/parent::node()/@lemma)','%s'$tname"/> </xsl:for-each>
אבל זה ממש לא עובד. אני אשמח אם מישהו יכל לעזור לי עם זה. הנה דוגמה למסמך ה XML:<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="compare.xsl"?> <compare> <info> <file type="semcor">/freespace/stud/omerholz/NLP/SemCor/Compare/scstat_br-ca01_wf.xml</file> <file type="rawresults">/freespace/stud/omerholz/NLP/results/2009-01-03-12-47/raw_results/prob_ss_given_W_final_ca01.xml</file> <list type="tests"> <item type="test" name="firstequal">Test whether the supersense with the highest rank is identical</item> <item type="test" name="hresholdnonordered">Test whether the group of highest ranked supersenses is identical, not checking whether the order is identical</item> <item type="test" name="hresholdordered">Test whether the group of highest ranked supersenses is identical, not checking whether the order is identical</item> </list> </info> <comparison> <word lemma="shot"> <test name="firstequal" passed="False" description="True"> <description>Test whether the supersense with the highest rank is identical</description> <sense type="semcor" rank="1">noun.act</sense> </test> <test threshold="0.8" name="hresholdnonordered" passed="True" description="True"> <description>Test whether the group of highest ranked supersenses is identical, not checking whether the order is identical</description> <sense type="semcor" rank="1" sense="noun.act">1.0</sense> </test> <test threshold="0.8" name="hresholdordered" passed="False" description="True"> <description>Test whether the group of highest ranked supersenses is identical, not checking whether the order is identical</description> <sense type="semcor" rank="1" sense="noun.act">1.0</sense> </test> </word> <word lemma="office"> <test name="firstequal" passed="False" description="True"> <description>Test whether the supersense with the highest rank is identical</description> <sense type="semcor" rank="1">noun.group</sense> </test> <test threshold="0.8" name="hresholdnonordered" passed="True" description="True"> <description>Test whether the group of highest ranked supersenses is identical, not checking whether the order is identical</description> <sense type="semcor" rank="1" sense="noun.group">1.0</sense> </test> <test threshold="0.8" name="hresholdordered" passed="False" description="True"> <description>Test whether the group of highest ranked supersenses is identical, not checking whether the order is identical</description> <sense type="semcor" rank="1" sense="noun.group">1.0</sense> </test> </word> </comparison>
תודה רבה