XSLT <xsl:공간 보존>
❮ 완전한 XSLT 요소 참조
정의 및 사용
<xsl:preserve-space> 요소는 공백이 보존되어야 하는 요소를 정의하는 데 사용됩니다.
참고: 공백을 유지하는 것이 기본 설정이므로 <xsl:preserve-space> 요소를 사용하는 것은 <xsl:strip-space> 요소가 사용되는 경우에만 필요합니다.
참고: <xsl:preserve-space> 요소와 <xsl:strip-space> 요소는 최상위 요소입니다.
통사론
<xsl:preserve-space elements="list-of-element-names"/>
<xsl:strip-space elements="list-of-element-names"/>
속성
Attribute | Value | Description |
---|---|---|
elements | list-of-element-names | Required. A white space separated list of element names for which white space should be preserved/removed. Note: The list can also contain "*" and "prefix:*" so that all elements or all elements from a particular namespace can be joined |
실시예 1
아래 예에서는 제목 및 아티스트 요소에 대한 공백 노드를 유지하고 국가, 회사, 가격 및 연도 요소에 대한 공백 노드를 제거합니다.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="country company price year" />
<xsl:preserve-space elements="title artist" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="catalog/cd">
<p>
<xsl:value-of select="title" /><br />
<xsl:value-of select="artist" /><br />
<xsl:value-of select="country" /><br />
<xsl:value-of select="company" /><br />
<xsl:value-of select="price" /><br />
<xsl:value-of select="year" />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
❮ 완전한 XSLT 요소 참조