你是说用XSL转还是用JAVA的API?

解决方案 »

  1.   

    //test.xml
    <?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type='text/xsl' href='test.xsl'?>
    <test>aaaaaaa&#13;bbbbbbbbbb&#13;&#13;cccccc&#13;</test>
    //test.xsl
    <?xml version="1.0"  encoding="GB2312"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="gb2312" /><xsl:template match="/">
      <xsl:apply-templates/>
    </xsl:template><xsl:template match="text()">
      <xsl:call-template name="break"/>
    </xsl:template><xsl:template name="break">
      <xsl:param name="text" select="."/>
      <xsl:choose>
        <xsl:when test="contains($text, '&#13;')">
          <xsl:value-of select="substring-before($text, '&#13;')"/>
          <br/>
          <xsl:call-template name="break">
            <xsl:with-param name="text" select="substring-after($text, '&#13;')"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$text"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template></xsl:stylesheet>