Search and replace: Use XPath in replace expression
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 6
- Joined: Thu Sep 30, 2010 12:16 pm
Search and replace: Use XPath in replace expression
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
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Search and replace: Use XPath in replace expression
Hello,
Unfortunately you cannot evaluate that XPath expression in context to use its result as a replace pattern. There is a messy way to do this with regular expressions but to be safe you should use an XSLT stylesheet or XQuery.
Regards,
Adrian
Unfortunately you cannot evaluate that XPath expression in context to use its result as a replace pattern. There is a messy way to do this with regular expressions but to be safe you should use an XSLT stylesheet or XQuery.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service