XSLT output formatting: keep line breaks, remove indent

后端 未结 1 1764
梦如初夏
梦如初夏 2021-01-27 15:14

Here\'s my XML:


  
- T 1
相关标签:
1条回答
  • 2021-01-27 15:37

    If you don't strip and don't indent, but transform white space text nodes to a line break, as in

    <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="comment()"/>
    
    <xsl:template match="@class" />
    
      <xsl:template match="node()[not(self::doc|self::texte|self::author|self::style|self::span)]|@*" >
        <xsl:copy>
          <xsl:apply-templates select="node()[not(self::author)]|@*"/>
        </xsl:copy>
      </xsl:template>
    
    <xsl:template match="text()[not(normalize-space())]">
        <xsl:text>&#10;</xsl:text>
    </xsl:template>
    
    </xsl:stylesheet>
    

    then the result is hopefully what you want.

    0 讨论(0)
提交回复
热议问题