Add StyleSheet processing Instruction to TXMLDocument

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Add StyleSheet processing Instruction to TXMLDocument

Postby jimmyfloyd » Mon Dec 03, 2007 9:28 am

I am wondering how I can go about adding a Stylesheet reference to a TXMLDocument?

Basically I want to add the line

Code: Select all
 ?xml-styles heet type="text/xsl" href="stylesheet.xsl"?>
(Space added between ? and xml)
To the document so that it can be viewed when saved.

I have tried this:

Code: Select all
tmpNode = OutputXMLDocument->CreateNode("xml-stylesheet" ,ntProcessingInstr  );
 tmpNode->SetAttribute("type","text/xsl");
 tmpNode->SetAttribute("href", "stylesheet.xsl");
  OutputXMLDocument->DocumentElement->GetChildNodes()->Add(tmpNode);


But all this gives me is an error stating "Attributes are not supported on this node type"

I then changed it to read:

Code: Select all
  tmpNode = OutputXMLDocument->CreateNode("xml-stylesheet type=\"text/xsl\" href=\"stylesheet.xsl\"" ,ntProcessingInstr  );


With this, I get the error "This name may not contain the ' ' character"

Am I doing something wrong, or is this not supported by TXmlDocument?
Intermediate programmer
C++ Builder 2007 novice
jimmyfloyd
Top Poster
Top Poster
 
Posts: 42
Joined: Mon Sep 24, 2007 11:37 am
Location: binghamton, ny

Postby jimmyfloyd » Wed Dec 05, 2007 1:41 pm

ok, dug a little deeper and found that there are two options with MSXML.

The first is to use the transformNode property. I try this, but so far have had no luck in getting it to give me back my HTML that i have setup in the XSLT. All I get back are the actual Values, with all the HTML markup deleted.

The second option I found is to use the IXSLTemplate and IXSLProcessor methods, which from what I read, allows more control over the items. Unfortunately, i have not been able to find an example using this in C++, nor have I been able to implement it myself.

Does anyone know of an example that would show the proper way to use this?

Thanks
Intermediate programmer
C++ Builder 2007 novice
jimmyfloyd
Top Poster
Top Poster
 
Posts: 42
Joined: Mon Sep 24, 2007 11:37 am
Location: binghamton, ny


Return to Technical

Who is online

Users browsing this forum: No registered users and 18 guests

cron