G'day,
Running on Windows server 2k8, Xalan v2.7.1.
I wrote a quick xalan java extension to read and return a nodeset of filenames in a directory. Each file in this directory is an xml file containing department information.
I then loop through this nodeset, using the document() function, copy out the main department node from each xml document to a result tree (xsl variable).
I need to turn this result tree fragment into a node-set, so i use xalan:nodeset extension.
I need to generate an alphabetical listing of department links, with an alphabetical link bar at the top of the page, linking down to each letter grouping for departments.
Not sure if this is clear or not.
My main problem is that I'm getting an error on the xsl:key line... invalid tokens.
Here's my code:
Code:
<xsl:variable name="deptIndexNode">
<xsl:for-each
select="dir-ext:fileListAsXml('c:/temp/data')/fileList/name">
<xsl:variable name="dcrXml" select="document(concat('../data/',.))" />
<xsl:copy-of select="$dcrXml/department"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name="accentedChars" select="'ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ'" />
<xsl:variable name="baseChars" select="'AAAEEEEIIOOOUUUC'" />
<xsl:key name="firstLetter" match="xalan:nodeset($deptIndexNode)/department" use="translate(translate(substring(normalize-space(name_en),1,1),$smallcase,$uppercase),$accentedChars,$baseChars)" />
the error is thrown on my xsl:key line:
2014-09-11 08:50:48,651 ERROR [STDERR] SystemId Unknown; Line #27; Column #196; Extra illegal tokens: '(', '$', 'deptIndexNode', ')', '/', 'department'
Am i out to lunch here? is there a better way to do this? I can confirm that my xalan extension does work, and am able to process each xml file without any issue... only when i try to build up the key map on the generated result tree is where i'm stumped.
I'm basing this on Jeni Tennison's article on Muechian grouping method...
thanks for any tips/advice..
Edit: From Jeni's article:
"
Finally, it can be quite complicated to use keys where the nodes that you want to group are spread across different source documents. "
this is pretty much what I'm dealing with here... trying to group department nodes, with each department node in its own xml file.