|
-
May 25th, 2004, 04:20 PM
#1
How do I display the results of an xslt tranformation? RESOLVED
I'm hitting a web service and request records. These records are returned as an xml string. When I get this string I have to apply an xsl style sheet to the data and present it as an html table.
If I create an xml file from the retruned string and apply the xsl stylesheet I created, it give nice results. I just can't figure out how to take the string returned and directly apply the style sheet to it and display the results in an asp page.
Can someone point me in the right direction?
Last edited by MarkT; May 30th, 2004 at 03:52 PM.
-
May 27th, 2004, 01:34 PM
#2
I wonder how many charact
XML allows inline style sheets and links
Try appending the stylesheet at the top after the <XML> tag...
try that first.
If that fails or won't work for your project, here's a snippet I lifted out of our project that uses a XSLSortTransform on the elements..
VB Code:
'the next three lines simply load XML from a database,( you can use a file or memorystream, whatever)..
'and assigns appends it a stringbuilder
While dreader.Read
xmlstring.Append(dreader(0))
End While
[b] 'heres the meat[/b]
Dim xmldoc As New System.Xml.XmlDocument
'here we assign the actual XML to an empty XMLdocument
xmldoc.LoadXml(xmlstring.ToString)
'Define a transform...
Dim myXslTransform As New XslTransform
'load the XSLT
myXslTransform.Load(Page.MapPath("DropDownTree.xslt"))
'create a readable stream from the transform
Dim xr As XmlReader = myXslTransform.Transform(xmldoc, Nothing)
'create a new empty doc
Dim Sorteddoc As New System.Xml.XmlDocument
'assign the transformed XML to the new empty doc
Sorteddoc.Load(xr)
In reality, depending on the length of the XSLT... you could simply build a XSLT using a stringbuilder and create an XSLTransform from that... all inside your code.
Last edited by nemaroller; May 27th, 2004 at 01:39 PM.
-
May 30th, 2004, 03:52 PM
#3
Thanks!
I ended up using an XML Control on the web form. I just set the DocumentContent property to the xml string and the TransformSource property to the xsl file. It seems to work pretty well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|