XSLT <xsl: message> Element
Definicja i Wykorzystanie
<Xsl: message> Element do wyjścia napisać wiadomość. Element ten jest wykorzystywany przede wszystkim do zgłaszania błędów.
Ten element może zawierać prawie wszystkich innych elementów XSL (<xsl: text> <xsl: value-of>, etc.).
wypowiedzenia atrybut pozwala wybrać, gdy wystąpi błąd, proces ma zakończyć lub kontynuować leczenie.
gramatyka
<xsl:message terminate="yes|no">
<!-- Content:template -->
</xsl:message>
<!-- Content:template -->
</xsl:message>
nieruchomość
属性 | 值 | 描述 |
---|---|---|
terminate | yes no |
可选。"yes":在消息写入输出后,终止处理。"no":在消息写入输出后,继续进行处理。默认是 "no"。 |
Przykład 1
Wykrywanie, czy artysta jest pusty ciąg. Jeśli tak, to rzucić procesor XSL i wyświetla komunikat:
<?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:for-each select="catalog/cd">
<p>Title: <xsl:value-of select="title"/><br />
Artist:
<xsl:if test="artist=''">
<xsl:message terminate="yes">
Error: Artist is an empty string!
</xsl:message>
</xsl:if>
<xsl:value-of select="artist"/>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="catalog/cd">
<p>Title: <xsl:value-of select="title"/><br />
Artist:
<xsl:if test="artist=''">
<xsl:message terminate="yes">
Error: Artist is an empty string!
</xsl:message>
</xsl:if>
<xsl:value-of select="artist"/>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Kompletna instrukcja XSLT element odniesienia