xsl-list
[Top] [All Lists]

Re: [xsl] XSLT 2.0 contains question

2007-04-09 12:42:48
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.

   <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.


I suppose you mean: fn:contains does not take a sequence of nodes as its first argument. You should specify precisely what you want, so either:

(: first xsd:documentation :)
xsd:documentation[1]

or:

(: all xsd:documentation concatenated :)
string-join(xsd:documentation, '')

or (better):

(: all xsd:annotation having at least one xsd:documentation with 'Deprecated' :)
xsd:annotation[xsd:documentation[contains(., 'Deprecated')]]

HtH,

Cheers,
-- Abel Braaksma



--~------------------------------------------------------------------
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>