Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml XSL中的换行_Xml_Xslt - Fatal编程技术网

Xml XSL中的换行

Xml XSL中的换行,xml,xslt,Xml,Xslt,我曾尝试使用XSL在XML文件中输出客户列表,但值之间没有分隔线 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD

我曾尝试使用XSL在XML文件中输出客户列表,但值之间没有分隔线

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output 
  method="html"
  encoding="ISO-8859-1"
  doctype-public="-//W3C//DTD HTML 4.01//EN"
  doctype-system="http://www.w3.org/TR/html4/strict.dtd"
  indent="yes" />
    <xsl:template match="/">
        <xsl:apply-templates select="//client"/>
    </xsl:template>

    <xsl:template match="//client">
     <xsl:value-of select="./nom/." />
    </xsl:template>
</xsl:stylesheet>
通常我想得到

Doe
Nam
Pelluro

我让indent=“yes”但这不起作用

首先,提供的XSLT代码非常奇怪

<xsl:template match="//client">
  <xsl:value-of select="./nom/." />
</xsl:template>
<xsl:template match="client">
 <xsl:value-of select="nom" />
</xsl:template>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="client">
  <xsl:value-of select="nom" />
  <xsl:if test="not(position()=last())">
    <br />
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>
A<br/>B<br/>C
如果您希望生成xHtml输出(而不仅仅是文本),则必须生成

元素,而不是NL字符:

<xsl:template match="//client">
  <xsl:value-of select="./nom/." />
</xsl:template>
<xsl:template match="client">
 <xsl:value-of select="nom" />
</xsl:template>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="client">
  <xsl:value-of select="nom" />
  <xsl:if test="not(position()=last())">
    <br />
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>
A<br/>B<br/>C


现在,输出为

<xsl:template match="//client">
  <xsl:value-of select="./nom/." />
</xsl:template>
<xsl:template match="client">
 <xsl:value-of select="nom" />
</xsl:template>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="client">
  <xsl:value-of select="nom" />
  <xsl:if test="not(position()=last())">
    <br />
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>
A<br/>B<br/>C
A
B
C
并在浏览器中显示为

<xsl:template match="//client">
  <xsl:value-of select="./nom/." />
</xsl:template>
<xsl:template match="client">
 <xsl:value-of select="nom" />
</xsl:template>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="client">
  <xsl:value-of select="nom" />
  <xsl:if test="not(position()=last())">
    <br />
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>
A<br/>B<br/>C
我发现

<xsl:strip-space elements="*" />

成功了。


<xsl:for-each select="allowedValueList/allowed">
**<br/>**<xsl:value-of select="." />
</xsl:for-each>
**
**
只需添加:

标签。 这对我有用