Click here to Skip to main content
16,015,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: S/W career - programmers Pin
led mike23-May-08 4:29
led mike23-May-08 4:29 
AnswerRe: S/W career - programmers Pin
Michael Schubert23-May-08 4:37
Michael Schubert23-May-08 4:37 
AnswerRe: S/W career - programmers Pin
Hamid_RT23-May-08 5:36
Hamid_RT23-May-08 5:36 
GeneralRe: S/W career - programmers Pin
ptr_Electron24-May-08 1:34
ptr_Electron24-May-08 1:34 
GeneralRe: S/W career - programmers Pin
Hamid_RT24-May-08 6:38
Hamid_RT24-May-08 6:38 
GeneralRe: S/W career - programmers Pin
ThatsAlok16-Jul-09 20:59
ThatsAlok16-Jul-09 20:59 
AnswerRe: S/W career - programmers Pin
CPallini23-May-08 23:23
mveCPallini23-May-08 23:23 
QuestionMSXML2::IXMLDOMDocument2 transformNodeToObject Pin
Maximilien23-May-08 4:05
Maximilien23-May-08 4:05 
(XML API/stuff I'm not really used to work with)

I'm trying to transform an XML with an external XSL file ( to add indentation and line-feed to the output file)

In one instance ( on one generated XML file ) it works very well, on another instance (other generated XML file), it does not, it "copies"
the XSL to the outgoing XML (when applying the transformation).

Both the generated XML and the XSL files are valid XML files, and when using an external tool (XmlPad) to apply the transformation
on the XML file with the XSL file it works :

The code looks like this : The return value from transformNodeToObject is S_OK even if it looks to not work.
CString sInputPath;// valid input path initialized.
sInputPath+= "StyleSheet.xsl";

MSXML2::IXMLDOMDocument2Ptr pXMLDocResult;
CMtXmlParser xlsParser; // our own XML parser.
xlsParser.InitDoc();


VARIANT_BOOL vResult = xmlParser.LoadDocument(sInputPath);
if( ((BOOL)vResult ) == false ) // fail!
{
  // if cannot load the XLS file, just save as-is.
  hr = xmlParser.SaveDocument( sPath );
  return FAILED( hr );
}

MSXML2::IXMLDOMDocument2Ptr pXslStyleSheet;
pXslStyleSheet = xmlParser.GetDOMDocument();

hr = CoCreateInstance( MSXML2::CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER,  MSXML2::IID_IXMLDOMDocument2, (void**)&pXMLDocResult);
ASSERT( !FAILED(hr));


IDispatch* pDispatch;
hr = pXMLDocResult->QueryInterface(IID_IDispatch, (void**)&pDispatch);
ASSERT( !FAILED(hr));

VARIANT vOutput;
vOutput.vt = VT_DISPATCH;
vOutput.pdispVal = pDispatch;

try
{
  // Apply transform to doc before saving ...
  HRESULT hr = pXMLDoc->transformNodeToObject( pXslStyleSheet, vOutput );
  ASSERT( !FAILED(hr));
}
catch ( ... )
{
  // if cannot transform, just save as-is.
  hr = xmlParser.SaveDocument( sPath );
  return FAILED( hr );
}

BSTR s = xmlParser.AsciiToBSTR(sPath );
hr = pXMLDocResult->save(s);
ASSERT(!FAILED(hr));


The XSL file is :
<xsl:stylesheet version="1.0">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>


Anyone used transformNodeToObject and have any insights ?

Thanks.

Max.

Maximilien Lincourt
Your Head A Splode - Strong Bad

AnswerRe: MSXML2::IXMLDOMDocument2 transformNodeToObject Pin
Doc Lobster25-May-08 0:09
Doc Lobster25-May-08 0:09 
QuestionCombo box problem .... Pin
tina->newcoder23-May-08 3:12
tina->newcoder23-May-08 3:12 
AnswerRe: Combo box problem .... Pin
Nelek23-May-08 3:19
protectorNelek23-May-08 3:19 
GeneralRe: Combo box problem .... Pin
tina->newcoder23-May-08 3:25
tina->newcoder23-May-08 3:25 
GeneralRe: Combo box problem .... Pin
Nelek23-May-08 3:27
protectorNelek23-May-08 3:27 
Questionstatic variable issue! Pin
ganesa moorthy23-May-08 2:50
ganesa moorthy23-May-08 2:50 
AnswerRe: static variable issue! Pin
led mike23-May-08 4:26
led mike23-May-08 4:26 
GeneralRe: static variable issue! Pin
ganesa moorthy25-May-08 20:06
ganesa moorthy25-May-08 20:06 
AnswerRe: static variable issue! Pin
Michael Schubert23-May-08 4:45
Michael Schubert23-May-08 4:45 
GeneralRe: static variable issue! Pin
ganesa moorthy25-May-08 20:08
ganesa moorthy25-May-08 20:08 
Questionconnecting to SqlServer through VC6.0 Pin
ramarajendra23-May-08 2:46
ramarajendra23-May-08 2:46 
AnswerRe: connecting to SqlServer through VC6.0 Pin
ShilpiP23-May-08 3:05
ShilpiP23-May-08 3:05 
AnswerRe: connecting to SqlServer through VC6.0 Pin
ptr_Electron23-May-08 3:59
ptr_Electron23-May-08 3:59 
AnswerRe: connecting to SqlServer through VC6.0 Pin
Hamid_RT23-May-08 5:30
Hamid_RT23-May-08 5:30 
QuestionUpper to lower case conversion in Russian language???????? Pin
sumit.durg23-May-08 2:42
sumit.durg23-May-08 2:42 
AnswerREPOST! PLEASE IGNORE Pin
Rajesh R Subramanian23-May-08 2:59
professionalRajesh R Subramanian23-May-08 2:59 
AnswerRe: Upper to lower case conversion in Russian language???????? PinPopular
Hamid_RT23-May-08 5:30
Hamid_RT23-May-08 5:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.