【问题标题】:XSLT's XAML XMLNSXSLT 的 XAML XMLNS
【发布时间】:2013-11-12 11:31:44
【问题描述】:

我正在尝试转换这样的 XAML 文档

<Section xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve" TextAlignment="Left" LineHeight="Auto" IsHyphenationEnabled="False" xml:lang="en-us" FlowDirection="LeftToRight" NumberSubstitution.CultureSource="User" NumberSubstitution.Substitution="AsCulture" FontFamily="Arial" FontStyle="Normal" FontWeight="Normal" FontStretch="Normal" FontSize="12" Foreground="#FF000000" Typography.StandardLigatures="True" Typography.ContextualLigatures="True" Typography.DiscretionaryLigatures="False" Typography.HistoricalLigatures="False" Typography.AnnotationAlternates="0" Typography.ContextualAlternates="True" Typography.HistoricalForms="False" Typography.Kerning="True" Typography.CapitalSpacing="False" Typography.CaseSensitiveForms="False" Typography.StylisticSet1="False" Typography.StylisticSet2="False" Typography.StylisticSet3="False" Typography.StylisticSet4="False" Typography.StylisticSet5="False" Typography.StylisticSet6="False" Typography.StylisticSet7="False" Typography.StylisticSet8="False" Typography.StylisticSet9="False" Typography.StylisticSet10="False" Typography.StylisticSet11="False" Typography.StylisticSet12="False" Typography.StylisticSet13="False" Typography.StylisticSet14="False" Typography.StylisticSet15="False" Typography.StylisticSet16="False" Typography.StylisticSet17="False" Typography.StylisticSet18="False" Typography.StylisticSet19="False" Typography.StylisticSet20="False" Typography.Fraction="Normal" Typography.SlashedZero="False" Typography.MathematicalGreek="False" Typography.EastAsianExpertForms="False" Typography.Variants="Normal" Typography.Capitals="Normal" Typography.NumeralStyle="Normal" Typography.NumeralAlignment="Normal" Typography.EastAsianWidths="Normal" Typography.EastAsianLanguage="Normal" Typography.StandardSwashes="0" Typography.ContextualSwashes="0" Typography.StylisticAlternates="0">
<Table CellSpacing="1" Margin="0,0,0,0"><Table.Columns><TableColumn Width="264" /></Table.Columns><TableRowGroup><TableRow><TableCell Padding="0,0,0,0">
<Paragraph FontFamily="Times New Roman" FontSize="10.666666666666666" Margin="0,0,0,0">
   <Span FontWeight="Bold"><Run>some text</Run></Span><Run> </Run>
   <Span Foreground="#FF00681C"><Run>some more text</Run></Span>
</Paragraph>
</TableCell></TableRow></TableRowGroup></Table>
</Section>

转换成 HTML

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<xsl:output method="html"/>

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

但结果是空白的

我怀疑这是由于 XSLT 中缺少命名空间声明,但我添加的那些没有帮助。

【问题讨论】:

    标签: html xaml xslt xslt-1.0


    【解决方案1】:

    您的 XSL 有效。它给出了这个,

    <html xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
       <body>
    
    
          some text 
          some more text
    
    
    
       </body>
    </html>
    

    HTML 输出:

    some text some more text
    

    也看到这个,

    XSL:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <xsl:output omit-xml-declaration="yes" indent="yes" />
       <xsl:strip-space elements="*" />
       <xsl:output method="html"/>
       <xsl:template match="/">  
    <html>
        <body>
        <xsl:apply-templates/>
        </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    

    输出:

    <html>
       <body>
    
    
          some text 
          some more text
    
    
    
       </body>
    </html>
    

    HTML 输出:

    some text some more text 
    

    【讨论】:

    • 正确。似乎是我的软件在转换步骤上不太清楚:)
    猜你喜欢
    • 2020-10-19
    • 2011-03-31
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-16
    • 1970-01-01
    相关资源
    最近更新 更多