procedure TDomNode.transformNode(const stylesheet: IDomNode; var output: DomString); var doc: xmlDocPtr; styleDoc: xmlDocPtr; outputDoc: xmlDocPtr; styleNode: xmlNodePtr; tempXSL: xsltStylesheetPtr; encoding: widestring; length1: longint; CString: PChar; len: integer; meta: widestring; doctype: integer; element: xmlNodePtr; begin doc := fXmlNode.doc; styleNode := GetXmlNode(stylesheet); styleDoc := styleNode.doc; if (styleDoc = nil) or (doc = nil) then exit; tempXSL := xsltParseStyleSheetDoc(styleDoc); if tempXSL = nil then exit; // mark the document as stylesheetdocument; // it holds additional information, so a different free method must // be used (stylesheet.ownerDocument as IDomInternal).set_FtempXSL(tempXSL); // kb2003-09-16: This applies the stylesheet always to the document outputDoc := xsltApplyStylesheet(tempXSL, doc, nil); if outputDoc = nil then exit; doctype := outputDoc.type_; element := xmlDocGetRootElement(outputDoc); encoding := outputDoc.encoding; xmlDocDumpMemoryEnc(outputDoc, CString, @length1, outputDoc.encoding); output := CString; // free the document as a string is returned, and not the document xmlFreeDoc(outputDoc); // if the document is of type plain-text or html if (element = nil) or (doctype = 13) then begin //cut the leading xml header len := pos('>', output) + 2; output := copy(output, len, length1 - len); end; xmlFree(CString); end;