Solved

Rendering an XML Stream II

Posted on 2001-06-24
6
338 Views
Last Modified: 2013-11-20
Hi All,
With XML/XSL adding such great capabilities for formatting output I would like to be able to stream XML data into a CHTMLView. While the XSL sheet can reside in the program directory, the XML is produced dynamically as output from various calculations with the view rendering it in the same way that it does if you load an xml document from the local drive. Is it possible to insert items into an XML document and have it render (using the XSL sheet) as each element is added as with HTML? Can anyone show me a way of going about this?

I have got as far as this:

// Load the default xml document
CString sAppName=AfxGetAppName();
CString sResourceID;
sResourceID.Format("%d", IDR_EMPTY_XML);
CString sNavigatePath;
sNavigatePath ="res://"+sAppName+".exe/"+sResourceID;
Navigate2(sNavigatePath);

Where the resource in this case is inserted as an HTML page containing XML.  ie

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="file://c:\OLSSAMP.xsl"?>
<!-- Here begins the XML data -->
<OUTPUT>
 <METHOD ID="OLS">
   <COMMAND>OLS CONSUME INCOME PRICE / ANOVA PCOV</COMMAND>
 </METHOD>  
</OUTPUT>

This loads an empty (but properly rendered XML document) and from there I was hoping to be able to insert elements and have the view update the element based on the stylesheet.  Using the methods suggested by Dan Rollins:
1) pElem->put_innerHTML( bstrHtml );  using get_body()
  or
2) pPersistStreamInit->Load( pStm );  using CreateStreamOnHGlobal(.)
 
(which are both methods for inserting HTML that is automatically rendered correctly) do not cause the page to render the XML with the XSL formatting - rather the XML is treated as HTML with unrecognised tags ie. inserted as plain text.

Finally if there is an alternative to XSL that will cause the XML stream (or element inserts) to render (eg. dynamic HTML methods of working with XML) than that would be also be fine.

Thanks in advance for any suggestions.  Roll on DXML....

Regards

David
0
Comment
Question by:Rupreck
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6224372
what I do is this

1) load your XML into an XMLDocument
2) load the XSLT into an XMLDocument
3) transform using transformNode
4) load the result into a HTMLDocument
0
 

Author Comment

by:Rupreck
ID: 6227098
Thanks Shaun, this looks useful.  Do you have any sample code that will do this, I have no experience with using the XML Dom object in C++.  

I take it that 1) allows the loading of an xml portion (node) that is then inserted into an existing rendered XML document properly formatted?

Regards
David
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6227660
> Do you have any sample code that will do this

sadly no - I've only ever done this inside webapages - but it is easy to do if you know how to create COM objects

1) create 2 IXMLDOMDocument objects
2) set the async property on both to false
3) load 1 with the xml and the other with the xsl documents
4) BSTR bstrHTML=xmlDoc.transformNode(xslDoc);
5) insert the html into your browser (which you seem to know how to do)
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 9

Accepted Solution

by:
ShaunWilde earned 260 total points
ID: 6227680
> Do you have any sample code that will do this

sadly no - I've only ever done this inside webapages - but it is easy to do if you know how to create COM objects

1) create 2 IXMLDOMDocument objects
2) set the async property on both to false
3) load 1 with the xml and the other with the xsl documents
4) BSTR bstrHTML=xmlDoc.transformNode(xslDoc);
5) insert the html into your browser (which you seem to know how to do)
0
 

Author Comment

by:Rupreck
ID: 6270577
Now I just have to figure how to do it in C++
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6282041
just ask if you have any problems I might be able to help further
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
twoTwo  challenge 35 101
noX challenge 17 112
website content maintenance 3 91
Coldfusion- Create and save form elements in Database 7 72
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now