本文整理汇总了VB.NET中System.Xml.Xsl.XsltArgumentList.AddExtensionObject方法的典型用法代码示例。如果您正苦于以下问题:VB.NET XsltArgumentList.AddExtensionObject方法的具体用法?VB.NET XsltArgumentList.AddExtensionObject怎么用?VB.NET XsltArgumentList.AddExtensionObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了XsltArgumentList.AddExtensionObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Sample
' 导入命名空间
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Public Class Sample
Public Shared Sub Main()
' Create the XslCompiledTransform and load the stylesheet.
Dim xslt As New XslCompiledTransform()
xslt.Load("prices.xsl")
' Create an XsltArgumentList.
Dim xslArg As New XsltArgumentList()
' Add an object to calculate the new book price.
Dim obj As New BookPrice()
xslArg.AddExtensionObject("urn:price-conv", obj)
Using w As XmlWriter = XmlWriter.Create("output.xml")
' Transform the file.
xslt.Transform("books.xml", xslArg, w)
End Using
End Sub
' Convert the book price to a new price using the conversion factor.
Public Class BookPrice
Private newprice As Decimal = 0
Public Function NewPriceFunc(ByVal price As Decimal, ByVal conv As Decimal) As Decimal
Dim tmp As Decimal = price * conv
newprice = Decimal.Round(tmp, 2)
Return newprice
End Function 'NewPriceFunc
End Class
End Class