开发者

How can I add line break into text that I am creating with XSLT?

I am trying to create text output from an xml file using xslt. It is actually an xslt that creates SQL code. Here is a part that outputs CREATE TABLE statements:

CREATE TABLE dbo.[<xsl:value-of select="@PhysicalName"/>] (
  <xsl:for-each select="EntityAttributes/EntityAttribute">
    <xsl:apply-templates select="Attributes/Attribute[@AttributeID = current()/@EntityAttributeID]"/> ...
  </xsl:for-each>)

I want to have a line break after the "(" in the first line but cannot开发者_如何学Python manage to find out how to do so. Can anyone help?


As for line breaks, I myself prefer more explicit/readable way.

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


If you put

<xsl:text>
</xsl:text>

in your XSLT it will give a line break. It is not clear where you wish to put this. I am guessing you want:

<xsl:text>CREATE TABLE dbo.[</xsl:text><xsl:value-of select="@PhysicalName"/><xsl:text>] (
</xsl:text>

In general you should always wrap text output in ... it looks slightly horrid in the XSL but it preserves the spacing. Note that you can break the lines in the XSLT without affecting the result - e.g.

<xsl:text>CREATE TABLE dbo.[</xsl:text>
<xsl:value-of select="@PhysicalName"/>
<xsl:text>] (&#xa;</xsl:text>

and yes, I agree about the explicit line break character. As you can see the XSLT is not very readable but it gets the right answer


use tags it's easy

Example:
<div>TOTAL STAR POINTS EARNED </div>
<div>TOTAL STAR POINTS REDEEMED </div>
<div>BALANCE STAR POINTS AVAILABLE </div>

output:

TOTAL STAR POINTS EARNED 
TOTAL STAR POINTS REDEEMED 
BALANCE STAR POINTS AVAILABLE 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜