how to set newline and tab in paragraph using xslt

六眼飞鱼酱① 提交于 2019-12-23 06:23:59

问题


I want to set newline and tab in paragraph using XSLT values from xml retrieve using XML Parsing.Following XSLT code separates each word in paragraph.But,I want to separate newline in paragraph wherever necessary and also I want to set tab before starting a paragraph...

    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>

回答1:


To set a newline you can use:

<xsl:text>&#xa;</xsl:text>


来源:https://stackoverflow.com/questions/18051289/how-to-set-newline-and-tab-in-paragraph-using-xslt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!