Re: [xslt] Throw error if XPath doesn't match

Andreas Sommer schrieb:
I want to know if it's possible to throw an error if the XPath "foo"
of <xsl:value-of select="foobar" /> does not match anything in the
source file.

Moin Andreas,

place a lethal <xsl:message> inside an appropriate <xsl:if>.

<xsl:message terminate="yes">Aus die Maus!</xsl:message>

For example if the path is an optional element and I want to make sure
that the XSL stylesheet only works if the element is given in the
source file.

You might also want to explore other options, like:

<xsl:apply-templates select="stuff[optional-but-I-want-it-here]"/>

That would only apply-templates to "stuff" if there is at least one
child "optional-but-I-want-it-here".

Michael Ludwig

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]