xsl:template match doesn't find matches

Posted by dmo on Stack Overflow See other posts from Stack Overflow or by dmo
Published on 2008-11-07T18:58:25Z Indexed on 2010/06/08 15:22 UTC
Read the original article Hit count: 226

Filed under:
|
|

I'm trying to convert some Xaml to HTML using the .NET XslCompiledTransform and am running into difficulties getting the xslt to match Xaml tags. For instance with this Xaml input:

<FlowDocument PagePadding="5,0,5,0" AllowDrop="True" NumberSubstitution.CultureSource="User" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  <Paragraph>a</Paragraph>
</FlowDocument>

And this xslt:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>

  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates />
      </body>
    </html>
  </xsl:template>

  <xsl:template match="FlowDocument">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="Paragraph" >
    <p>
      <xsl:apply-templates />
    </p>
  </xsl:template>

I get this output:

<html>
    <body>
  a
</body>
</html>

Rather than the expected:

<html>
   <body>
      <p>a</p>
   </body>
</html>

Could this be a problem with the namespace? This is my first attempt at an xsl transform, so I'm at a loss.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about Xml