HI,
trying to pass parameter to my XSLT from a VB application.
What we have:
XSLT/Xpath 2.0
Windows
VB 2008 .NET 3.5
As you can see I've tried with addParam and SetParameter which one
should I use, and how?
Thx for your help, AGAIN
Michel
Here a subset of code that I use:
---------VB Code
Imports System.IO
Imports System.Xml
Imports Saxon.Api
Imports System.Xml.XPath
Imports System.Xml.Xsl
Private Function ParseFile(ByVal source As String, ByVal target As
String) As ParseResponse
Dim response As New ParseResponse()
Dim memStream As New MemoryStream()
Dim processor As New Processor()
Dim xhtmlDoc As New XmlTextReader(source)
Dim xslDoc As New XmlTextReader(myParseProperties.XSL)
Dim input As XdmNode =
processor.NewDocumentBuilder().Build(xhtmlDoc)
Dim transformer As XsltTransformer =
processor.NewXsltCompiler().Compile(xslDoc).Load()
Dim xslArg As XsltArgumentList = New XsltArgumentList
'transformer.SetParameter(New QName("", "", "target"), New
XdmAtomicValue("A Value"))
'xslArg.AddParam("target", "", target)
'Create an XmlTextWriter to handle the output.
Dim writer As XmlTextWriter = New XmlTextWriter("orderout.xml",
Nothing)
transformer.InitialContextNode = input
Dim serializer As New Serializer()
serializer.SetOutputFile(target)
'serializer.SetOutputWriter(Console.Out)
response.SourceFile = source
response.TargetFile = target
response.Timestamp = Now()
Try
transformer.Run(serializer)
response.Message = "Successfully parsed and transformed"
Catch ex As Exception
response.Message = "Error: " & ex.Message
End Try
Return response
End Function
--------- XSLT Code
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xhtml" >
<xsl:output method="xml" indent="yes" encoding="windows-1252"
exclude-result-prefixes="xhtml" ></xsl:output>
<xsl:strip-space elements="*"/>
<xsl:key name="keyrefname" match="ref"
use="lower-case(normalize-space(.))"/>
<xsl:variable name="file_gccore" as="document-node()"
select="document('validated_gccore_terms.xml')" />
<xsl:variable name="file_gctct" as="document-node()"
select="document('validated_gctct_terms.xml')" />
<xsl:variable name="target" select="target" />
<xsl:template match="xhtml:html" exclude-result-prefixes="xhtml" >
<root>
<xsl:value-of select="$target"/>
</root>
</xsl:stylesheet>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--