Subject: Re: [xsl] XSLT 2.0 contains question From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 09 Apr 2007 15:11:25 -0400 |
At 2007-04-09 14:51 -0500, David Carver wrote:Under XSLT 1.0, I can do the following to filter out any xsd:element that has a xsd:documentation element that has the word "Deprecated" in it.
Actually, no ... your code only filters out any xsd:element whose *first* xsd:documentation child element has the word "Deprecated" in it, not "any" as you say.
<xsl:template match="xsd:schema"> <xsl:copy> <xsl:copy-of select="@*"/>
<xsl:for-each select="xsd:element | xsd:complexType">
<xsl:if test="count(xsd:annotation[contains(xsd:documentation, 'Deprecated')]) = 0">
<xsl:apply-templates select="."/>
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
However, under XSLT 2.0, I get an error because contains can't take a more than xsd:documentation element. What is correct way to handle this under XSLT 2.0.
The correct way to handle this in both XSLT 1 and XSLT 2 is as follows:
<xsl:if test="not(xsd:annotation/xsd:documentation[contains(.,'Deprecated')])">
This expression will check all xsd:documentation children of xsd:annotation.
I hope this helps.
. . . . . . . . . . Ken
-- World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT 2.0 contains questio, G. Ken Holman | Thread | Re: [xsl] XSLT 2.0 contains questio, Abel Braaksma |
Re: [xsl] XSLT 2.0 contains questio, G. Ken Holman | Date | Re: [xsl] Removing namespaces witho, Abel Braaksma |
Month |