|
 |
aspx thread: XSLT for a Web Service
Message #1 by afleming@i... on Wed, 6 Dec 2000 10:48:51 -0000
|
|
I'm trying to write a web service that retrieves data from SQL and then
transforms it using an XSLT file before passing it to the client. I have
previously done a similar thing using SQL XML, MSXML and an ASP which
worked fine so thought I would give .NET a go.
I can retrieve the data into a DataSet object and can see that this
exposes that data as XML which is great. I then use the XSLTransform class
to do the transformation. The problem is this will only output the XML to
an XMLWriter, TextWriter or Stream all of which seem geared to writing to
disk. I want to take the resulting XML and do further work with it before
passing it out of my WebMethod. The only way I could find to do this was
to use a MemoryStream object as the output object of the transformation
and then reread the resultant byte array back into a new XMLDataDocument
object. This all seems very messy and convoluted compared with using
MSXML. Am I missing something?
Having got this to work however I then ran into another problem which was
that the XSLTransform class didn't like my XSLT file, saying that
'variable' was an unknown command. My XSLT file does use <xsl:variable> tags but it is
exactly the same file I have used with MSXML. Does the XSLTransform class
use a different XSL standard to MSXML?
Andy Fleming
andyf@i...
Message #2 by =?iso-8859-1?Q?Fredrik_Norm=E9n?= <fredrik.normen@e...> on Wed, 6 Dec 2000 13:04:55 +0100
|
|
Here is an example from the SDK.
Public Sub ReadTransform()
Try
Dim xmldocument as XmlDocument = new XmlDocument()
xmldocument.Load (m_Document)
Dim navigator as DocumentNavigator = new
DocumentNavigator(xmldocument)
Dim xsltransform as XslTransform = new XslTransform()
xsltransform.Load(m_Stylesheet)
Dim reader as XmlReader = xsltransform.Transform(navigator, nothing)
...
Catch e As Exception
Console.WriteLine ("Exception: {0}", e.ToString())
End Try
End Sub
I hope this can help you..
/Fredrik Normén
-----Original Message-----
From: afleming@i... [mailto:afleming@i...]
Sent: den 6 december 2000 11:49
To: ASP+
Subject: [aspx] XSLT for a Web Service
I'm trying to write a web service that retrieves data from SQL and then
transforms it using an XSLT file before passing it to the client. I have
previously done a similar thing using SQL XML, MSXML and an ASP which
worked fine so thought I would give .NET a go.
I can retrieve the data into a DataSet object and can see that this
exposes that data as XML which is great. I then use the XSLTransform class
to do the transformation. The problem is this will only output the XML to
an XMLWriter, TextWriter or Stream all of which seem geared to writing to
disk. I want to take the resulting XML and do further work with it before
passing it out of my WebMethod. The only way I could find to do this was
to use a MemoryStream object as the output object of the transformation
and then reread the resultant byte array back into a new XMLDataDocument
object. This all seems very messy and convoluted compared with using
MSXML. Am I missing something?
Having got this to work however I then ran into another problem which was
that the XSLTransform class didn't like my XSLT file, saying that
'variable' was an unknown command. My XSLT file does use <xsl:variable> tags
but it is
exactly the same file I have used with MSXML. Does the XSLTransform class
use a different XSL standard to MSXML?
Andy Fleming
andyf@i...
|
|
 |