gpt4 book ai didi

xml - 在 xsl 报告中的输出周围添加括号

转载 作者:行者123 更新时间:2023-12-05 04:09:16 25 4
gpt4 key购买 nike

我正在尝试使带有括号的 extendedDescription 字段与描述内联,除非没有 extendedDescription。

我找到了很多关于格式化输出和 if 语句的答案。但是,我不是程序员,无法让任何东西按照我希望的方式工作。

如果有人能帮助我,我将不胜感激。谢谢!

代码如下:

 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:inr="http://mycompany.com/mynamespace">
<xsl:include href="../format.xsl"/>
<!-- TDS CR5 Format -->
<xsl:output method="text" media-type="text/plain" encoding="iso-8859-1"/>
<xsl:template match="/">
<xsl:variable name="gridOut" select="inr:SetGridOut(number(InRoads/@outputGridScaleFactor))" />
<xsl:choose>
<xsl:when test="$xslShowHelp = 'true'">
<xsl:call-template name="StyleSheetHelp"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="//GeometryPoint[@name]">
<xsl:text/>
<xsl:value-of select="@name"/><xsl:text>,</xsl:text>
<xsl:value-of select="inr:northingFormat(number(@northing), $xslNorthingPrecision)"/><xsl:text>,</xsl:text>
<xsl:value-of select="inr:eastingFormat(number(@easting), $xslEastingPrecision)"/><xsl:text>,</xsl:text>
<xsl:value-of select="inr:elevationFormat(number(@elevation), $xslElevationPrecision)"/><xsl:text>,</xsl:text>
<xsl:value-of select="@description"/>(<xsl:value-of select="@extendedDescription"/>)<xsl:text>&#xd;</xsl:text>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="StyleSheetHelp">
<xsl:text>Notes&#xd;&#xd;</xsl:text>
<xsl:text> You must include at least one cogo point in the Cogo&#xd;</xsl:text>
<xsl:text> Points &gt; Include field or one horizontal alignment with&#xd;</xsl:text>
<xsl:text> named points in the Horizontal Alignments &gt; Include&#xd;</xsl:text>
<xsl:text> field on the Tools &gt; XML Reports &gt; Geometry command to&#xd;</xsl:text>
<xsl:text> get results from this report.&#xd;&#xd;</xsl:text>
<xsl:text> Most style sheets in the DataCollection directory do&#xd;</xsl:text>
<xsl:text> not honor Tools &gt; Format Options with the exception of&#xd;</xsl:text>
<xsl:text> precision, where practical.&#xd;&#xd;</xsl:text>
<xsl:text>Copyright 2006 Bentley Systems, Inc&#xd;</xsl:text>
</xsl:template>
</xsl:stylesheet>

这里的输出很好,除了没有 extendedDescription 的时候,因为我在结果文件中得到了 ()。

示例输出(当前):

CS300,848822.7010,617517.7670,1022.26,6615(SES#44) 
CSG002,859658.2240,607167.2050,998.76,6652()

示例输出(需要):

CS300,848822.7010,617517.7670,1022.26,6615(SES#44) 
CSG002,859658.2240,607167.2050,998.76,6652

再次感谢任何能帮助我的人。

最佳答案

尝试改变:

(<xsl:value-of select="@extendedDescription"/>)

到:

<xsl:if test="string(@extendedDescription)">
<xsl:value-of select="concat('(',@extendedDescription,')')"/>
</xsl:if>

关于xml - 在 xsl 报告中的输出周围添加括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46288685/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com