Xpath, C# and code-generation

minder dan 1 minuut gelezen

I tend to use code-generation to avoid "dumb" work where possible. Xslt is a valueable tool to create the templates for the code that is to be generated. The available functions in Xpath have been limited in number; with the advent of C# the following becomes possible:

<BLOCKQUOTE dir=ltr style=”MARGIN-RIGHT: 0px”><PRE>
<stylesheet version=”1.0” xmlns=”http://www.w3.org/1999/XSL/Transform
xmlns:msxsl=”urn:schemas-microsoft-com:xslt” xmlns:user=”http://pareto.nl/PAS”>
     <![CDATA[ </PRE> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><PRE> public string CamelCase(string value)
  return value[0].ToString().ToLower() + value.Substring(1);
 public string UpperCase(string value)
  return value.ToUpper();

Although it'll probably be some time before we can use this within an application as client-side script, it sure does make the Xsl/Xpath-combination a more powerful solution for generating code.