xsl-list
[Top] [All Lists]

Re: [xsl] XSLT 2.0 contains question

2007-04-09 12:12:29
At 2007-04-09 15:07 -0400, I wrote:
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.

Sorry, David, I incorrectly cited the word "any" ... I interpreted you implying with "that has a xsd:documentation element" that if there are more than one of them that any of them can have the word "Deprecated" in it.

The rest of the post stands, I just realized that I incorrectly wrote my first paragraph.

   <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(_at_)CraneSoftwrights(_dot_)com
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>