title: Converting XHTML to XAML using XSLT
body: <p>I have the following XML</p>
  
  <pre><code>User entered text : Normal **Bold** *Italic* 
  u&amp;#x332;n&amp;#x332;d&amp;#x332;e&amp;#x332;r&amp;#x332;l&amp;#x332;i&amp;#x332;n&amp;#x332;e&amp;#x332;
  ***BoldItalic*** ***B&amp;#x332;o&amp;#x332;l&amp;#x332;d&amp;#x332;I&amp;#x332;t&amp;#x332;a&amp;#x332;l&amp;#x332;i&amp;#x332;c&amp;#x332;U&amp;#x332;n&amp;#x332;d&amp;#x332;e&amp;#x332;r&amp;#x332;l&amp;#x332;i&amp;#x332;n&amp;#x332;e&amp;#x332;***
  </code></pre>
  
  <p>The resulting XHTML string is stored in the database table.</p>
  
  <pre><code>  &lt;QuestionText xml:space="preserve"&gt;
      &lt;p&gt;Normal 
      &lt;b&gt;Bold &lt;/b&gt; 
      &lt;i&gt;Italic &lt;/i&gt;
      &lt;u&gt;Underline &lt;/u&gt;
  
      &lt;b&gt;Bold &lt;i&gt;BoldItalic &lt;/i&gt;Bold &lt;/b&gt; 
  
      &lt;b&gt;&lt;i&gt;BoldItalic &lt;/i&gt;&lt;/b&gt; 
      &lt;b&gt;&lt;i&gt;&lt;u&gt;BoldItalicUnderline&lt;/u&gt;&lt;/i&gt;&lt;/b&gt; 
      &lt;/p&gt;
      &lt;p/&gt;
      &lt;p/&gt;
      &lt;p/&gt;
    &lt;/QuestionText&gt;
  </code></pre>
  
  <p>I need to transform to .Net X(A)ML as follows</p>
  
  <pre><code>&lt;Section&gt;
    &lt;Paragraph&gt;
      &lt;Span Text="Nornal " /&gt;
      &lt;Span FontWeight="Bold" Text="Bold " /&gt;
      &lt;Span FontStyle="Italic" Text="Italic " /&gt;
      &lt;Span Text="Underline " UnderlineDecoration="Line" /&gt;
  
      &lt;Span FontWeight="Bold" Text="Bold " /&gt;
      &lt;Span FontStyle="Italic" FontWeight="Bold" Text="BoldItalic " /&gt;
      &lt;Span FontWeight="Bold" Text="Bold " /&gt;
  
      &lt;Span FontStyle="Italic" FontWeight="Bold" Text="BoldItalic " /&gt;
      &lt;Span FontStyle="Italic" FontWeight="Bold" Text="BoldItalicUnderline" UnderlineDecoration="Line" /&gt;
    &lt;/Paragraph&gt;
    &lt;Paragraph/&gt;
    &lt;Paragraph/&gt;
    &lt;Paragraph/&gt;
  &lt;/Section&gt;
  </code></pre>
  
  <p>I tried with this XSLT with no luck</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt"&gt;
    &lt;xsl:output method="xml" indent="yes"/&gt;
  
    &lt;xsl:template match="QuestionText"&gt;
        &lt;Section&gt;
          &lt;xsl:apply-templates/&gt;
        &lt;/Section&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="b|i|u|p/text()" &gt;
  
      &lt;span&gt;
        &lt;xsl:attribute name="Text"&gt;
          &lt;xsl:value-of select="current()"/&gt;
        &lt;/xsl:attribute&gt;
        &lt;xsl:attribute name="name"&gt;
          &lt;xsl:value-of select="name()"/&gt;
        &lt;/xsl:attribute&gt;
        &lt;xsl:attribute name="parent"&gt;
          &lt;xsl:value-of select="name(..)"/&gt;
        &lt;/xsl:attribute&gt;
  
        &lt;xsl:if test=".=i"&gt;
          &lt;xsl:attribute name="FontStyle"&gt;italic&lt;/xsl:attribute&gt;
        &lt;/xsl:if&gt;
  
        &lt;xsl:if test=".=b"&gt;
          &lt;xsl:attribute name="FontWeight"&gt;bold&lt;/xsl:attribute&gt;
        &lt;/xsl:if&gt;
  
        &lt;xsl:if test=".=u"&gt;
          &lt;xsl:attribute name="UnderlineDecoration"&gt;line&lt;/xsl:attribute&gt;
        &lt;/xsl:if&gt;
      &lt;/span&gt;
  
      &lt;xsl:apply-templates/&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="p"&gt;
      &lt;Paragraph&gt;
        &lt;xsl:apply-templates/&gt;
      &lt;/Paragraph&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Any help on XSLT is highly appreciated.</p>