I have a xslt file that contains a xsl variable that I am using like a lookup table.
<xsl:variable name="TestLookup">
<lookup code="A" means="Test A"/>
<lookup code="B" means="Test B"/>
<lookup code="C" means="Test C"/>
</xsl:variable>
Then I call it like this.
<xsl:value-of select="document('')/*/xsl:variable[@name='TestLookup']/lookup[@code=current()]/@means"/>
When I call the Transform method in .NET I get the following errors:
An error occurred while loading document ''
This operation is not supported for a relative URI.
Basically it is telling me that it can't find the document.
I need some way of creating a lookup table in the xslt file and be able to call it with the Transform command in .NET.
This article had the same problem but I didn't see an answer. Something about p/2 function?
It also listed the node-set() but I can't find any good article on using node-set as a lookup table.
using document() function in .NET XSLT generates error
Adding More Code
.NET CODE
' get the xml from SQL
Dim xmlData As String = sqlXmlReader.Item("XmlData").ToString()
' read the xslt file
Using styleSheet = New StreamReader("XSLTTestFile.xslt")
' load the stylesheet from a resource
Using styleSheetReader As XmlReader = XmlReader.Create(styleSheet)
Dim xslt = New XslCompiledTransform()
Dim xsltSettings = New XsltSettings(True, False)
xsltSettings.EnableDocumentFunction = True
' load the stylesheet for transformation
xslt.Load(styleSheetReader, xsltSettings, New XmlUrlResolver())
Using stringWriter As New System.IO.StringWriter
' transform the xml document along with the stylesheet
Dim xmlDoc = New XmlDocument()
xmlDoc.LoadXml(xmlData)
xslt.Transform(xmlDoc, Nothing, stringWriter)
' dump the transformation to the browser control
_htmlString.Append(stringWriter.ToString())
End Using
End Using
End Using
XsltSettings. Did you try that?