Subject: RE: RE: [xsl] VB 2008 Passing Parameter to XSLT 2.0 From: "Knight, Michel" <michel.knight@xxxxxxxx> Date: Fri, 10 Jul 2009 15:07:54 -0400 |
Got My anwser:-) Here it is for the futur reader My error was on the XSLT file, you need to use <xsl:param name="target"> <xsl:param/> The VB file is OK, Just need to change the XSLT file here the new file. <?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:param name="target"></xsl:param> <xsl:param name="target1"></xsl:param> <!--xsl:variable name="target" select="target" /--> <!--xsl:variable name="target1" select="target1" /--> <xsl:template match="xhtml:html" exclude-result-prefixes="xhtml" > <root> Start <xsl:value-of select="$target"></xsl:value-of> <xsl:copy-of select="$target1"></xsl:copy-of> End </root> </xsl:template> <!--*****************************************--> </xsl:stylesheet> -----Original Message----- From: Knight, Michel Sent: July 10, 2009 12:08 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Cc: 'michel.knight@xxxxxxx' Subject: RE: RE: [xsl] VB 2008 Passing Parameter to XSLT 2.0 Thx for the info I've remove everything and only kept the section that you've mention. So the code look like this and it goes and execute, but it doesn't pass the parameters, any ideal what's missing? I'm testing with 2 parameters. Do I need to pass more parameter to-->transformer.Run(serializer), or is it at the XSLT level that I'm not retrieving properly? ----------------------- VB Code 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() transformer.SetParameter(New QName("", "", "target"), New XdmAtomicValue("A Value")) transformer.InitialContextNode = input transformer.SetParameter(New QName("", "", "target1"), New XdmAtomicValue(target)) 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 2.0 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:variable name="target" select="target" /> <xsl:variable name="target1" select="target1" /> <xsl:template match="xhtml:html" exclude-result-prefixes="xhtml" > <root> Start <xsl:value-of select="$target"></xsl:value-of> <xsl:copy-of select="$target1"></xsl:copy-of> End </root> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] VB 2008 Passing Paramete, Martin Honnen | Thread | [xsl] Announce: Hands-on XQuery/XS, G. Ken Holman |
Re: [xsl] VB 2008 Passing Paramete, Martin Honnen | Date | Re: [xsl] Forcing a blank page, Brandon Ibach |
Month |