how to detect tags whose attributes contain a particular string ...

how to detect tags whose attributes contain a particular string ...

Post by lehmann » Fri, 22 Aug 2003 00:03:53


hello,
My problem is quite difficult to express (in english), I'll try to do
my best ...
here is a xml file example:

<tag1>
<tag2 att="a,b,c"/>
<tag2 att="b,c,d"/>
<tag2 att="d,c,b"/>
<tag2 att="a,c,d"/>
</tag1>

Il would like to count how many tag2 have a "att" attribute that
contains the "b" letter (or string)
Or more simply I would like to know wheter one of tag2's att contains
the b letter ...

to try to be clearer, I would like to put a test in my xsl file such
as
<xsl:template match="tag1">
<xsl:if test="??">
...
</xsl:if>
</xsl:template>

where ?? would be a function that would return "3" or "true" for the
example below ...

something like "count(contains(tag2/@att, b))" but this is not correct
....

any idea anyone?
G
 
 
 

1. how do u invoke Tag b's Tag Handler from within Tag a's tag Handler?

2. Delete sections defined by particular section delimiters if the sections contain a particular string

Hi all

I'd like to process a file (input.txt, see below) with this goal in
mind:

Delete everything between the strings "section {" and "}" (including
those strings!) but only if the section contains the string
"pattern=foo".

This is the (simplified) content of the file "input.txt":

*** Beginning of input.txt ***
111
222
333
section {
aaa
bbb
pattern=foo
ccc
ddd
}
section {
eee
fff
pattern=foo
ggg
hhh
}
section {
iii
jjj
pattern=bar
kkk
lll
}
*** End of input.txt ***

Thus, I am looking for results such as

*** Beginning of output.txt ***
111
222
333
section {
iii
jjj
pattern=bar
kkk
lll
}
*** End of output.txt ***

If the section delimiters were blank lines I would use something like
this:

sed -e '/./{H;$!d;}' -e 'x;/pattern=foo/!d;' input.txt

Unfortunately, even after much reading, I don't manage to create what
I have described above.

Any hints or examples using tools such as awk, sed, grep, perl, ...
are welcome. Actually, awk is preferred, this is why I post this
question here.

My plattform is Linux (CentOS).

Thanks, David

3. output lines from text file whose string contains a specific word.

4. In XPath, how to get alll the nodes whose name contains a certain string?

5. How to detect a string contains certain string

6. Editable Tag Attribute for onLoad attribute of <body> tag

7. Regular expression to match only strings NOT containing particular words

8. Excel -find records which DO NOT contain a particular text string

9. Change attributes of entire row when a particular string is found in row

10. check if a string contains a particular character

11. Does string contain A, and if so, does a section of string contain B

12. Regular expression to match only strings NOT containing particular words

13. find the last file containing a particular string

14. Specifying string array as an attribute in HTML tag

15. JSP custom tag, passing a non-string attribute