Вот несколько разных способов для C #
List<string> lines = new List<string>(new string[]{
"twelve drummers drumming,\n\r"
, "eleven pipers piping,\n\r"
, "ten lords a-leaping,\n\r"
, "nine ladies dancing,\n\r"
, "eigth maids a-milking,\n\r"
, "seven swans a-swimming,\n\r"
, "six geese a-laying,\n\r"
, "five gold rings,\n\r"
, "four calling birds,\n\r"
, "three french hens,\n\r"
, "two turtle doves, and \n\r"
, "a partridge in a pear tree."
});
string[] day = {
"first"
,"second"
,"thrid"
,"forth"
,"fifth"
,"six"
,"seventh"
,"eigth"
,"ninth"
,"tenth"
,"eleventh"
,"twelth"
};
for (int i = 0; i < 12; i++)
Console.WriteLine(string.Format("On the {0} day of christmas, my true love gave to me\n\r{1}", day[i], string.Concat(lines.GetRange(11 - i, i + 1).ToArray())));
не очень приятно. но его мало. :)
Uses
XMLDoc, XMLIntf;
function Transform(XMLContent : string; XSLContent : string) : WideString;
var
XML : IXMLDocument;
XSL : IXMLDocument;
begin
XML := LoadXMLData(XMLContent);
XSL := LoadXMLData(XSLContent);
XML.DocumentElement.TransformNode(XSL.DocumentElement, Result)
end;
Если вам нужны только преобразования, вы можете использовать TXMLDocument
, сохранить на диск и затем отобразить результат в TWebBrowser
(через Navigate ('file: /// ...')
).
Лично у меня были проблемы с MSXML, поэтому я начал использовать DIXML .
I used an MSXML library to do the XSLT transformation in Delphi. It was a long time ago. Worked like a charm!
I'm not sure what output format your XSLT will generate, but knowing that will help you figure out how to display it. We generated HTML from XML via XSLT, and displayed it using an ActiveX Web Browser (IE) control on a pane in our application.
Here's a link on MSSXML and Delphi that might help.
BTW: If this is your first time working with XSLT, you can manually edit an XML file, and add in a directive to get it to display using a specific XSLT. When you open the XML in Firefox after the edit, the XSLT will be applied, and it will show you what will be the output of your MSXML calls. Вот строка, которую вы добавляете вручную в xml:
<?xml-stylesheet type="text/xsl" href="myStyleSheet.xsl"?>
Вы можете попробуйте установить AltovaXML, он может называться COM +. Это бесплатно и может быть загружено с: http://www.altova.com/altovaxml.html
MsXml может работать только с xslt 1.0, но AltovaXml может работать с xslt 2.0