Search and replace: Use XPath in replace expression
Posted: Thu Sep 30, 2010 12:53 pm
Hello,
I have the following exemplary tei tagging structure:
I would like to insert an xml:id attribute to those div tags that consist of the xml:id attribute of the text tag plus an underscore and an counter.
Searching with an
for the text
works. It would find the seacrhed text in children of those divs as well, but there are no children with such a type attribute.
Now I would like to replace that text with
And the expression has to be something like
The counter could even be derived from the position of the div within the body tag.
Is there anything like this possible? Writing a transformation to do this would be an alternative, but I was wondering if XPath in replace expressions is supported somehow...
Best regards,
Christian Kirchhoff
I have the following exemplary tei tagging structure:
Code: Select all
<text type="art_miscellanea" n="[212.1]" xml:id="ar212mi01">
...
<body>
<div type="misc_undef">...</div>
<div type="misc_undef">...</div>
Searching with an
Code: Select all
XPath //text[@type='art_miscellanea']/body/div[@type='misc_undef']
Code: Select all
type="misc_undef"
Now I would like to replace that text with
Code: Select all
type="misc_undef" xml:id="<expression>"
Code: Select all
concat(parent::body/parent::text/@xml:id, '_', counter())
Is there anything like this possible? Writing a transformation to do this would be an alternative, but I was wondering if XPath in replace expressions is supported somehow...
Best regards,
Christian Kirchhoff