xml - XSL match node on multiple values -



xml - XSL match node on multiple values -

i have xml document looks abit like

<a> <somenode att="1"></somenode> </a> <a01> <apple att="2"></apple> <somenode att="1"></somenode> </a01>

what im trying match when node name 'a' or followed 1 number (a0) , followed 2 number (a01), ideas on how can ?

i have next far

<xsl:apply-templates select="node()[starts-with(name(),'a')]">

but select apple aswell, how multiple matches , or/and ?

in xslt 2.0 pretty simple:

<xsl:apply-templates select="node()[matches(name(),'^a\d?\d?$')]">

in xslt 1.0, regex isn't available, it's little trickier, next should work:

<xsl:apply-templates select="node()[starts-with(name(), 'a') , string-length(name()) &lt;= 3 , translate(name(), '0123456789', '') = 'a']" />

the 3 parts joined "and" here ensure that:

the name starts "a" the name 3 characters or less all remains when digits removed name string "a" (meaning characters besides single "a" digits).

xml xslt

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

How do you set up a perforce server to work over the internet? -

ios - Lagging ScrollView with UIWebview inside -