XSLT Select with 2 contains -


we using following select nodes 'experienceinfo' contains '582':

<xsl:apply-templates disable-output-escaping="yes" select="td:benutzer_zu_gastro[contains(td:experienceinfo, '582')]"> 

and select nodes 'kategorien' contains 'restaurant':

<xsl:apply-templates disable-output-escaping="yes" select="td:benutzer_zu_gastro[contains(td:kategorien, 'restaurant')]"> 

how combine 2 1 statement nodes selected experienceinfo contains 582 , kategorien contains restaurant?

many help!

it's simple must have thought "no, can't it":

<xsl:apply-templates select="   td:benutzer_zu_gastro[     contains(td:experienceinfo, '582')      , contains(td:kategorien, 'restaurant')   ] "> 

if xml looks <td:experienceinfo>582</td:experienceinfo> (etc.) can made simpler.

<xsl:apply-templates select="   td:benutzer_zu_gastro[     td:experienceinfo = '582' , td:kategorien = 'restaurant'   ] "> 

two general notes

  • if xml has delimited lists <td:experienceinfo>582,693</td:experienceinfo> (please doesn't) need use contains() might idea include separator character avoid false positives:

    contains(concact(',', td:experienceinfo, ','), ',582,') 
  • disable-output-escaping="yes" not standard feature of xslt processors. michael kay points out in comments, it's not syntactically valid on <xsl:apply-templates> in first place.
    try rid of it. sometimes can't avoided, indicates design flaw - enables output of ill-formed xml , sign of improper separation of data , structure.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -