Funkcja XSLT element-available()
Definicja i użycie
Funkcja element-available() zwraca wartość logiczną, która wskazuje, czy procesor XSLT obsługuje określony element.
Funkcja ta może być używana tylko do testowania elementów znajdujących się w ciele szablonu. Te elementy to:
- xsl:apply-imports
- xsl:apply-templates
- xsl:attributes
- xsl:call-template
- xsl:choose
- xsl:comment
- xsl:copy
- xsl:copy-of
- xsl:element
- xsl:fallback
- xsl:for-each
- xsl:if
- xsl:message
- xsl:number
- xsl:processing instruction
- xsl:text
- xsl:value-of
- xsl:variable
Gramatyka
boolean element-available(string)
Parametr
Parametr | Opis |
---|---|
string | Wymagane. Określa element do przetestowania. |
Przykład
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:template match="/"> <html> <body> <xsl:choose> <xsl:when test="element-available('xsl:comment')"> <p>xsl:comment jest wspierany.</p> </xsl:when> <xsl:otherwise> <p>xsl:comment nie jest wspierany.</p> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="element-available('xsl:delete')"> <p>xsl:delete jest wspierany.</p> </xsl:when> <xsl:otherwise> <p>xsl:delete nie jest obsługiwane.</p> </xsl:otherwise> </xsl:choose> </body> </html> </xsl:template> </xsl:stylesheet>