开发者

ASP.NET problem with XSLT transformation

开发者 https://www.devze.com 2023-03-13 07:11 出处:网络
I need help with the following issue. I parse XML and do a XSLT transformation. Everything is fine with Stylus Studio. But with ASP.NET I can\'t parse and output.

I need help with the following issue. I parse XML and do a XSLT transformation. Everything is fine with Stylus Studio. But with ASP.NET I can't parse and output.

min.a开发者_如何学Cspx.vb

Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Imports System.IO


Partial Class Poseidon_min
    Inherits System.Web.UI.Page


    Protected Sub Literal1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Literal1.PreRender

        Dim strXSLTFile As String = "http://www.kiris-alinda.de/Poseidon/Hotelangebote.xslt"
        Dim strXMLFile As String = "http://www.kiris-alinda.de/Poseidon/PosXMLReq/PosXMLReqSearch.php?htc=AYTLIND"



        Dim reader As XmlReader = XmlReader.Create(strXMLFile)

        Dim objXSLTransform As New XslCompiledTransform()

        objXSLTransform.Load(strXSLTFile)

        Dim htmlOutput As New StringBuilder()

        'Dim htmlWriter As TextWriter = New StringWriter(htmlOutput)

        'objXSLTransform.Transform(reader, Nothing, htmlWriter)


        Me.Literal1.Text = htmlOutput.ToString()

        reader.Close()

    End Sub
End Class

Why is it not possible to output <xsl:value-of select="PosXmlResponse/search/date/@min"/> from the XSLT in ASP.NET?


Take a look at this :

XML / XSLT Transformation

You have to use an XML Server Control on the ASPX page and then setting up XSLT Transformation


I use this code:

Public Shared Function Transform(xml As String, xsl As String, argsList As XsltArgumentList) As String
    Dim selectedXml As XDocument = XDocument.Parse(xml)
    Dim xmlTransform As New XslCompiledTransform()

    Dim htmlOutput As New StringBuilder()
    Dim writer As XmlWriter = XmlWriter.Create(htmlOutput)

    xmlTransform.Load(New XmlTextReader(New StringReader(xsl)))
    xmlTransform.Transform(selectedXml.CreateReader(), argsList, writer)

    Return htmlOutput.ToString()
End Function
0

精彩评论

暂无评论...
验证码 换一张
取 消