[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

VB 2008 Passing Parameter to XSLT 2.0

Subject: VB 2008 Passing Parameter to XSLT 2.0
From: "Knight, Michel" <michel.knight@xxxxxxxx>
Date: Thu, 9 Jul 2009 15:23:16 -0400
 VB 2008  Passing Parameter to XSLT 2.0
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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.