XSLT <xsl:strook-spasie>
❮ Voltooi XSLT-elementverwysing
Definisie en gebruik
Die <xsl:strip-space> element word gebruik om die elemente te definieer waarvoor wit spasie verwyder moet word.
Let wel: Die behoud van wit spasie is die verstekinstelling, so die gebruik van die <xsl:preserve-space> element is slegs nodig as die <xsl:strip-space> element gebruik word.
Let wel: Die <xsl:preserve-space>-element en die <xsl:strip-space>-element is topvlakelemente.
Sintaksis
<xsl:preserve-space elements="list-of-element-names"/>
<xsl:strip-space elements="list-of-element-names"/>
Eienskappe
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 |
Voorbeeld 1
In die voorbeeld hieronder bewaar ons witspasienodusse vir titel- en kunstenaarelemente, en verwyder witspasienodusse vir land-, maatskappy-, prys- en jaarelemente:
<?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>
❮ Voltooi XSLT-elementverwysing