2

I'm trying to insert a ServerName directive after the corresponding comment in httpd.conf:

#ServerName www.example.com:80

This fails:

defvar sncomment /files/etc/httpd/conf/httpd.conf/#comment[.= 'ServerName  www.example.com:80']
ins directive after $sncomment
defvar snentry /files/etc/httpd/conf/httpd.conf/directive[preceding-sibling::*[1][$sncomment]]
set $snentry 'ServerName'
set $snentry/arg 'www.domain:80'

$sncomment matches the correct line and a blank directive is inserted at the correct point in the tree but $snentry matches every directive in the tree not just the one inserted. How can I match only the inserted directive?

Thanks

1 Answer 1

0

There's a simpler way to match the just inserted directive:

defvar snentry /files/etc/httpd/conf/httpd.conf/directive[. = '']

That will work as long there are no other blank directives in the tree. However, I'd still like to get the preceding-sibling syntax correct if anyone can spot the error in my code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .