-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 に答える