The XSLT needs to output something like:
Mathematics
ID
ID
ID
PSE
ID
I currently get:
MathematicsID
ID
ID
PSEID
It seems that when it gets the <Subject>
it also gets all the other elements, in this case ID where i want it to get the <Subject>
then collect the relevant ID'.
Here is my XML:
<ArrayOfSchoolClass>
<SchoolClass>
<ExtensionData />
<Subject>Mathematics</Subject>
<ID>9</ID>
</SchoolClass>
<SchoolClass>
<ExtensionData />
<Subject>PSE</Subject>
<ID>9</ID>
</SchoolClass>
<SchoolClass>
<ExtensionData />
<Subject>Mathematics</Subject>
<ID>9</ID>
</SchoolClass>
<SchoolClass>
<ExtensionData />
<Subject>Mathematics</Subject>
<ID>9</ID>
</SchoolClass>
</ArrayOfSchoolClass>
And the XLST:
<xsl:key name="SchoolClass" match="SchoolClass" use="Subject"/>
<xsl:template match="ArrayOfSchoolClass">
<ArrayOfSchoolClass>
<xsl:for-each select="SchoolClass[generate-id()=generate-id(key('SchoolClass',Subject)[1])]">
<SchoolClass>
<xsl:copy-of select="Subject"/>
<xsl:for-each select="key('SchoolClass',Subject)">
<xsl:copy-of select="*[not(self::Subject)]"/>
<br />
</xsl:for-each>
</SchoolClass>
</xsl:for-each>
</ArrayOfSchoolClass>
</xsl:template>
Im really trying to create a menu where <Subject>
is the Heading and <ID>
is the link underneath without getting multiple <Subject>
headings that arent unique, if I can just work out how to select the elements correctly ....
Something like:
<ul>Mathematics
<li>9</li>
<li>9</li>
</ul>
<ul>PSE</ul>
<li>9</li>
</ul>