I've been trying to piece together various code snippets to create a lookup table inside my xslt without the need for a supplemental xml file. Here is what I have so far. As of now, it does not return anything in the output. I would love to be able to query the xref:factor table to retrieve the value of xref:factor/lookup
Here is a sample of the xml file:
Code:
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "*">]> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xref="http://www.dummy.com/xref" extension-element-prefixes="xref"> <xsl:output method="html" version="3.0" encoding="iso-8859-1" indent="yes"/> <xref:factor> <lookup factorcode="K">Test 1</lookup> <lookup factorcode="I">Test 2</lookup> <lookup factorcode="B">Test 3</lookup> <lookup factorcode="G">Test 4</lookup> </xref:factor> <xsl:key name="factor" match="xref:factor/lookup" use="@factorcode" /> <xsl:variable name="factors" select='document("")//xref:factor' /> <xsl:template match="/CREDITDATA"> <html> <head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head> <body> <xsl:for-each select="scoreinformation"> <xsl:variable name="origfactor" select="normalize-space(factor1)"/> <xsl:for-each select='$factors'> <xsl:value-of select='key("factor", $origfactor)'/> </xsl:for-each> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
Code:
<CREDITDATA> <scoreinformation ID="1"> <score>0519</score> <factor1>K</factor1> <factor2>I</factor2> <factor3>B</factor3> <factor4>G</factor4> <model>B</model> </scoreinformation> </CREDITDATA>
Comment