-1

我想使用 XML Parsing 从 xml 检索的 XSLT 值在段落中设置换行符和制表符。遵循 XSLT 代码分隔段落中的每个单词。但是,我想在必要时在段落中分隔换行符,并且我想在开始段落之前设置制表符...

    sample.xml
      <item>
      <id>0</id>
      <desc>Review your resume, and make sure that you can explain everything on it. Arrive at the interview ten minutes early to give yourself an opportunity to collect your thoughts and relax. Be aware that many employers will have their receptionist’s record the time you came in. If you rush in at the last minute, an employer may have serious concerns about your ability to arrive on time for a normal day at work.</desc>
      </item>

    xslt:

     <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:template match="t">
     <p>
     <xsl:apply-templates/>
     </p>
     </xsl:template>
     <xsl:template match="text()" name="insertBreaks">
     <xsl:param name="pText" select="."/>
     <xsl:choose>
     <xsl:when test="not(contains($pText, '&#xA;'))">
     <xsl:copy-of select="$pText"/>
     </xsl:when>
     <xsl:otherwise>
     <xsl:value-of select="substring-before($pText, '&#xA;')"/>
     <br />
     <xsl:call-template name="insertBreaks">
     <xsl:with-param name="pText" select="substring-after($pText, '&#xA;')"/>
     </xsl:call-template>
     </xsl:otherwise>
     </xsl:choose>
     </xsl:template>
     </xsl:stylesheet>
4

1 回答 1

1

要设置换行符,您可以使用:

<xsl:text>&#xa;</xsl:text>
于 2013-08-05T05:48:23.433 回答